Why I'm Not a React Native Developer
arielelkin.github.io
arielelkin.github.io
He also makes some of the React examples quite a bit more complicated than they need to be. Declarative UI is very simple!
Here's the same code, using both class and functional styles (whichever you prefer), in a much more succinct style (11 LOC vs 49):
class Root extends Component {
render() {
var isConnected = Math.floor(Math.random() * 10) > 5;
return <ConnectivityIndicatorView isConnected={isConnected} />;
}
}
function ConnectivityIndicatorView(props: {isConnected: boolean}) {
const color = props.isConnected ? 'green' : 'red';
return <View style={{backgroundColor: color, width: 20, height: 20}} />;
}
The point is, much like many things in software, it's all about perceptions and familiarity. He's not familiar with JS, and I don't fault him for that - it's a quirky language. But for the many, many developers who have built up a tolerance to JS and built/use tools to tame it, moving to React Native is a breath of fresh air vs learning Android & iOS toolchains and idiosyncrasies. var weAreConnected = Math.floor(Math.random() * 10) > 5;
if (weAreConnected === true) {
this.setState({
isConnected: true
})
}
else {
this.setState({
isConnected: false
})
}
}
turns into var weAreConnected = Math.floor(Math.random() * 10) > 5;
this.setState({
isConnected: weAreConnected
});
It's almost like he wrote it in the most obtuse way possible to prove his point. Unless he writes like that normally; If so then I can see where he's getting all these errors from. let weAreConnected: Bool = arc4random()%10 > 4
self.isConnected = weAreConnectedAnd bad code by what criteria? In this case, it's a little more verbose than it needs to be, but hurts nothing.
constructor() {
super()
this.state = {
isConnected: Math.floor(Math.random() * 10) > 5
}
}That's definitely not a fair characterization of this article.
Concerns about roadmap and patent usage show up before any concerns about JS.
Edit: Though I agree, a strangely large amount of the article is dedicated to "Why I just don't like Javascript."
2 minutes in a 5 minute animation short are the credits.
Here's a 2:18 animation with 1:06 credits -- way more than the ratio I gave: https://www.youtube.com/watch?v=8ZRLlyxvr6E
Credits --crew members, voice talent, sponsors, thanks, etc-- can rise almost linearly with the length of an animation, and even more so with increases in its production value.
A 5 minute short can have almost the same team size as a feature animation (which requires > 2 minute credits). The fact that they'll be employed for shorter time doesn't mean they don't get their names on the credits.
I sure am glad to know about the patent considerations in this simple criticism in this JavaScript, as I've decided not to use React because of them.
> Then why don't you drink this glass of 70% orange juice and 30% motor oil, since by your definition it's "simply orange juice".
I think a more proper correlation of your analogy vs OP's argument would be if you held it up and claims "why I won't be putting this motor oil into my car" and OP pointed out "that's because it contains mostly orange juice." Its intended to be an article about the con's of React Native, but is mostly an article about the cons of Javascript. Its a very well written article and (imho) its best parts are the concerns of long-term development of an entirely distinct ecosystem.
It's purely a misconception in the same way that 30% motor oil is pure orange juice -- which is to say, it's not a misconception, by my reading. I wonder what my IP laywer would say about it, will post if I decide to ask.
Unless I am looking at the wrong comment, @pluma's explanation is just that it's not a problem as long as you don't sue Facebook. But this is equivalent to saying that as long as you give up your only recourse in the event FB violates your IP, you'll be fine. To me it seems like a mentality that makes sense primarily if a person doesn't ever expect to do anything worth patenting, or doesn't ever plan on patenting for some other reason. Don't sell yourself short.
> doesn't ever plan on patenting for some other reason
I personally don't believe patents, outside of a few very special circumstances, should be allowed to exist. The idea that Facebook could copy one of my ideas and out-compete me based on their size is, imho, a perfectly reasonable thing for them to do. That being said, the current environment seems to demand that one patent any and everything they can as a pre-emptive defense. Hmm.
It's not like he's saying "Javascript sucks," he's outlining specific places where it can cause issues in development compared to the alternative.
Yes, if you use React you're basically agreeing not to sue Facebook over patents. Except if Facebook was acting in bad faith they'd probably have enough patents you could be found in violation of to ruin you anyway. If your software is non-trivial, it's already violating patents you probably never even heard of.
But the real kicker is that if you're not using React you're probably already using open source software. And in the JS ecosystem that probably means you're using software under MIT, BSD and ISC licenses, which have no patent provisions whatsoever.
Fun fact: AngularJS uses the MIT license and does NOT contain a patent grant whatsoever. If you use AngularJS, Google can sue you over any patents it holds that are relevant to AngularJS -- they don't even have to wait until you sue them first.
Ember? Same thing (MIT license without patent grant).
jQuery? Although it was dual-licensed as MIT/GPL at some point it's now only MIT-licensed and again contains no patent grant.
In other words: unless you have an explicit patent grant, you're at risk of being sued by the owners of whatever patents you happen to be infringing upon. The only difference is that you're entirely reliant upon the goodwill of the patent owners while React explicitly shields you unless you sue Facebook over patents.
http://en.swpat.org/wiki/Patent_clauses_in_software_licences...
React, like most JS projects, is licensed under an MIT/BSD style license (they're too similar to be worth the distinction in this context).
The alternative to having the FB patent grant wouldn't be to have the Apache 2.0 patent grant. It would be having no patent grant, as is the case with AngularJS, Ember and jQuery.
Which is completely beside the most important point: if you don't use React, you might be still affected by React-related patents owned by Facebook and there's no patent grant preventing them from suing you -- and this holds true for all patents owned by everybody else.
The default for JS projects is no patent grant. FB is actually more benign than any of the alternatives by providing a patent grant at all.
Not only is the argument entirely theoretical (If FB doesn't sue you over React patents, they might still sue you over non-React patents or someone else might sue you over React patents FB doesn't hold) but it's also invalid (FB doesn't benefit from offering a patent grant compared to not offering a patent grant -- which would have been the default for open source projects like React).
If you just want to argue that FB could have done more, yes of course they could have. But that's like shouting at someone giving you a free penny why they don't give you a free dollar.
The problem is the startup I work for relies on patents for a big part. And if we use any Facebook stuff, which I actually wanted to do as the main developer (react and react-native), they can use our stuff without caring about our patents! Because we can't sue them!
So basically, with that license Facebook on the one hand protects itself against patent trolls. Good, fine.
On the other hand though they grant themselves the right to use any patent of any company that uses their products, because you can't sue them any more! No? That's how I read it after having read a lot of discussions, none of which talk about that major issue, because for most people in this discussion defending their own patent(s) against Facebook is not an issue, so the discussion is very heavily one-sided towards people who don't have that problem.
If FB has patents that cover parts of React, the same patents also cover similar parts in other projects, including your own.
By using React you prevent FB from using those patents against you within the project in which you use React instead of your own analogous code.
They can enforce their patents against you if you infringe on them in your code. They can't enforce their patents against you if you infringe on them by using React.
This is a protection you only get by using React. And it's the only thing that changes if you sue them over patents.
The only difference is that if you don't use React, depending on the exact patents, they might not be able to determine you are infringing on their patents without looking at your code (whereas if you use React they know which of their patents cover React).
But as I said, this "drawback" really pales in comparison to the very real risk of infringing on patents without even using React in the first place. Facebook might hold the patent for some ubiquitous aspect of your application and they could still sue you over that if they want to at any moment.
That said, if you run a software company and intend to sue Facebook over patents, you better believe that they have an arsenal that can take you off the market for good if they want to.
Besides, why would you want to use open source software created, maintained and sponsored by a company you're planning to sue?
As to the roadmap, it's open-source with a vibrant community, if FB steps down, people in the community can fork, step up and continue maintaining... That's the whole reason behind open-source is that you can continue it.
Also, re: your edit.. yeah, far too much... yes JS has oddities, but the null reference issue is present in most OO languages, not to mention a lot of the other issues are well known and/or present in a lot of other languages as well.
Most JS specific oddities can be warned against with linters, and you can use TS/flow if you really want type checking at build.
From the blog post:
> JavaScript’s deficiencies seem to impress everyone except JavaScript developers, for whom the aspects of JavaScript that I outlined above are not awful warts, they’re “quirks” or “gotchas” that you, not your language, have to be on the lookout for.
I think his point is that calling JS "quirky" makes it sound benign, or even cute. However, JS's quirks are actually serious shortcomings compared to other languages.
For native iOS and Android developers React Native has a huge intrinsic appeal, for all the reasons he outlined at the start of the post. It's really tempting. Plus, the enthusiasm and scale of the JS community can sometimes ovrshadow concerns non-JS devs have about the language.
To me the post seems helpful. From my experience React Native will certainly not be all puppies and roses for people coming from Java, Swift or Obj-C.
One of shortcomings of language listed by author is precisely this: shortcomings in language are not fixed by fixing the language but by adding new community-supported library.
function ConnectivityIndicatorView(props: {isConnected: boolean}) {.. props.isConnected ..}
vs function ConnectivityIndicatorView({isConnected}) {.. isConnected.. }?
This is a lot more than "simply a list of things the author doesn't like about JS". The first part of the post in fact is totally orthogonal to JS, and all about React Native as a platform/project.
While I'm at it, I find the graphs towards the end claiming, for example, that using Xamarin (or Appcelerator) is more productive than React Native, or implying Swift is barely shy of perfectly safe to stretch credulity.
Finally, Javascript's "slow" state of development is a feature as well as a weakness, just as Swift's rapid pace of development is both a weakness and a feature. React itself progresses at a breakneck pace.
The reason ES2015 was so huge and so delayed was actually that ES5 was pretty much the lowest common denominator everyone was able to agree on after the proposals for ES4 went up in flames. ES5 is necessarily incremental and ES2015's delay was mostly caused by the repercussions of ES4's failure -- ES4 failed because it valued innovation over backwards compatibility.
I mean TC39 has announced that they will make a new release every year, batching whatever proposals are stable at that point. How can anyone call that particularly "slow" with a straight face?
Do I resent the guy who comes by once a year and reminds me chainsaws exist? No I do not.
That said, some of the more recent changes from MS have me interested in .Net again... I've even played around with some of the core/mono onbuild docker containers, which wasn't a bad experience at all.
I am a javascript programmer AND an iOS programmer. I work with React to build web apps at work. And lately I have played around with react native, but I felt uneasy jumping ship to use solely react native for the very same reason.
I instead decided to learn Android programming. There's really nothing to lose going that route (after all, you're learning Java, which is arguably the #1 popular language in the world, so even if you end up giving up on Android, you still know Java), compared to spending the same time learning React Native which has very uncertain future (I would trust it much more if it was not from a corporate entity like Facebook)
I would say the patent issue is more FUD than a real issue; he praises Swift but Swift has a very similar patent grant and termination clause. The key difference is that the Swift grant terminates if you end up in a patent dispute with Apple over something related to Swift; the React grant terminates if you end up in any patent dispute with Facebook.
So the whole issue boils down to "what if you get into a patent dispute with Facebook over a patent that doesn't relate to their core web UI tech". Which...I dunno, is that a real concern?
> “nice quantum physics technology you have here, would be a shame if something bad were to happen to your app”
Yeah, okay. But if my core business is making apps, then every patent I might have is likely to be covered by both patent grant termination clauses. So the issue is...?
(Also, the author is conflating the license to use React with the license to use any patents, if any, which cover React. If, as is entirely possible, no Facebook patent covers any React technology, then having the patent grant terminate would not concern you.)
But anyway, this patent issue is just one part of the larger issue, which is uncertainty. When Apple or Android changes the API policy in the future, you'll be struggling to adapt to the new reality with what you have. Sometimes it works, but sometimes it doesn't. Currently it does make sense for some people to build using react native, but if I were you, I would rather learn Android. Really, if you already have iOS experience, a lot of the paradigm is pretty similar and it won't be super difficult to learn.
This "cross platform" concept used to be valuable maybe in 2010 when it wasn't clear what mobile platforms would be dominant (with windows phones, blackberries, and even samsung launching their own developer platforms). But it's 2016 now, and we're pretty sure it's either iOS or Android. All you need is just those two platforms.
it's web, android, iOS, and PC. That's 4 platforms, if you consider web and PC separate, and more if you consider windows and linux as separate.
Crossplatform is more valuable than ever. But react-native may not be the answer.
And the concept of cross-platform is not only for "similar" platforms like mobile, but across disparate platforms, like mobile AND PC. Otherwise, what's the point of cross-platform?
I'm not completely sold on ReactNative compared to Phonegap and Electron as targets with React web... however, I can indeed see the appeal.
Yes!
On one hand, tons of HN commenters claim to be opposed to 1) NPEs going after smaller software concerns 2) giant ecosystem software vendors being the only choice when it comes to mobile/web technologies, but then this amateurish ¯\_(ツ)_/¯ mindset carries the day on easily graspable concepts that directly affect the likelihood of patent infringement.
> But if my core business is making apps, then every patent I might have is likely to be covered by both patent grant termination clauses. So the issue is...?
Given the increasingly broader markets that Facebook, Amazon, et al. want to break into, the issue is for businesses whose core business doesn't relate to apps but that still want to leverage modern software (aka all of them).
Stop brushing off issues you don't understand and calling them FUD.
> Notwithstanding the foregoing, if Facebook or any of its subsidiaries or corporate affiliates files a lawsuit alleging patent infringement against you in the first instance, and you respond by filing a patent infringement counterclaim in that lawsuit against that party that is unrelated to the Software, the license granted hereunder will not terminate under section (i) of this paragraph due to such counterclaim.
When I started my current job, I was talking to our tech director on how ive been using react native a bit. Been meaning to do an internal demo for it. I do find some of the development tools awesome, but really when we already have experienced iOS and android devs in house, why not keep growing in that area instead? React Native could be a way to do some quicker business wins, with clients that need cross platform in a short time frame. But I'm not convinced it's the right solution outside of that.
if (weAreConnected === true) {
this.setState({
isConnected: true
})
}
else {
this.setState({
isConnected: false
})
}
That is just verbose unnecessarily: this.setState({ isConnected: weAreConnected });
And probably not so popular, but this: var color;
if (this.state.isConnected) {
color = 'green'
}
else {
color = 'red'
}
Would be simplified often to: var color = this.state.isConnected ? 'green' : 'red';An enterprise developer.
Someone with an interesting development development history (maybe C?), with little grasp of the idioms of newer coding styles.
I've seen some coding rules/guides that explicitly forbid short form of 'if' statement usage.
- It works, really well.
- Iteration speed alone has helped us retain at an extremely high DAU/MAU ratio compared to years past.
- Both my apps have near 5 star rating across the board, probably the highest rated in the Sports category since we released, and none of our users notice that it is a RN app, which is really surprising b/c RN on Android is not up to par with iOS.
React-Native is not for every scenario, but I disagree with the author's final conclusion, that "the pros do not outweigh the cons". It's really quite the opposite in our case. The pros (OTA and productivity) heavily outweigh the cons.
Would love to see something better come out, but the recommended alternatives by the author wouldn't make the cut for us.
What scenario isn't it for?
Stuff in the background would be like video/audio calls, playing music, actively monitoring motion/gps (MapMyRun/Ride/Swim/etc), and a few other things that escape me at the moment.
If you are looking to release games quickly, the choice is generally Unity, although I hate how all the Unity games take forever to load, but it's a great way to get your game out quickly, and the good games will overcome the load times issue.
I'm the author of a couple of modules that allow your RN app to operate in the background:
https://github.com/transistorsoft/react-native-background-fe...
https://github.com/transistorsoft/react-native-background-ge...
Both of these modules were ported from Cordova and have since been ported to NativeScript.
So I guess that developers familiarity with the language is what makes it so popular (as in often-used) and is also why we suddenly start using it for arbitrary scripting and mobile app development. The obligatory use of JavaScript in web development led to a whole range of developers growing accustomed to it and now, in spite of its limitations, trying to transfer their ideas to other fields of development.
React Native is just a neat way for JavaScript (React) developers to be able to script UIs for mobile OS's without changing their toolset. And I think for that it's perfectly fine. Obviously if you've never been big into JavaScript I can totally see how cannot make much sense of it all and yeah a lot of the things pointed out are perfectly legitimate. Yet I still think the question whether it makes the language unusable for one scenario or the other is very very opinionated.
And unlike some languages used for app programming, an error doesn't have the potential to hand you a segfault.
And that is a good thing why? So you don't realise there was an error and your app runs on in a corrupted state?
He also rants about using the best language that catches the most errors but then picks Swift as his solution. I have a feeling there's lots of other devs that would not rank Swift at the top of languages that catch the most errors and therefore the author is being hypocritical in ranting that you should always use the best since they're arguably not using the best.
The article did make some other interesting points
I am so sad right now
That is because he is weighing solutions for developing native apps on Apple devices, where Swift is one of the best options.
> Perhaps more importantly, your software development platforms also shape you as a software engineer. A software development platform encourages (or forces) the use of one language over another, prioritises certain architectures over others, requires using specific tools and workflows, and marries you to an entire ecosystem and its developer community.
People talk about the "right tool for the job" and "good developers are polyglots." This is true to an extent, but there are still communities with different priorities, and they often form around languages and tools.
Likewise, there's not a single JavaScript community, but there's a bunch of communities around specific tools and frameworks. As you'd expect.
But I, when interviewing, expect good developers to be capable of learning new paradigms - the fact that they know nothing but node.js and node.js's ways is irrelevant, if they are capable of learning.
The author has very low expectations compared to me. And I don't feel I've been proven wrong yet by any of the hires I said yes to.
The license granted hereunder will terminate, automatically and without notice, if you (or any of your subsidiaries, corporate affiliates or agents) initiate directly or indirectly, or take a direct financial interest in, any Patent Assertion: (i) against Facebook or any of its subsidiaries or corporate affiliates, (ii) against any party if such Patent Assertion arises in whole or in part from any software, technology, product or service of Facebook or any of its subsidiaries or corporate affiliates, or (iii) against any party relating to the Software.
In other words you have no MIT or BSD licensed dependencies, or in fact no open source dependencies that don't either come with an explicit non-revocable patent grant and aren't licensed under Apache 2.0, GPLv3 or MPL 2.0 (all of which by the way still terminate the patent grant if you sue over infringement of patents within the licensed code itself).
Lucky you?
The MIT license, the BSD licenses, and so on, don't contain a patent grant. Only the Apache 2.0, GPLv3 and MPL 2 licenses do.
If you use an open source project which doesn't come with a patent grant, you can be sued for patent infringement over that project.
Facebook's patent grant prohibits Facebook from suing you over patent infringement for using React, except if you sue them over patents first.
So nothing in your stance is specific to Facebook. If you use AngularJS, Google can sue you over any patents used in AngularJS.
Facebook's patent grant acts as a kind of "no first strike" policy they have to obey for React-related patents: they can't sue you over React-related patents unless you sue them first.
Yes, Facebook can still sue you over other patents. Everybody can do this, even if you don't use their software.
Is Facebook's patent grant as permissive as those in the Apache 2.0, MPL 2.0 and GPLv3 licenses? No -- these only allow retaliation if you sue over the projects the licenses cover specifically.
But the patent grant is considerably better than not having a patent grant. If React is covered by patents (nothing in the grant requires Facebook to actually own any relevant patents), it's extremely likely similar libraries are just as likely to be covered by them (without a patent grant from Facebook) and open you up for liability.
Patents are not specific to software. If something React does is covered by a patent and another project also does it, that's still covered by the patent even if the code isn't from React, even if the author wasn't even aware of React doing it and never heard of the patent.
So, yes, if you exclusively use GPLv3/Apache 2.0/MPL 2 licensed projects, you're safe -- except for all the other patents you might be infringing on that aren't owned by the maintainers (and that the maintainers therefore can't give you a patent grant for).
But there is no scenario whatsoever where using React opens you up to more patent woes than using an alternative implementation -- or a comparable project (like AngularJS, Ember, etc) that doesn't come with a patent grant.
If you're concerned about React, be concerned about AngularJS first. Because if you use AngularJS, Google can sue you over patents without having to wait for you to sue them first.
I wouldn't have used angular anyways, though...
At best, that demonstrates that its fine...if you have lots of lawyers.
You left with nothing.
Oh, and your scenario only works if you sue FB/Instagram over your patents first. They can't revoke the patent grant willy-nilly except in retaliation.
It's software patents you should be worried about, not open source projects that try to offer you even the tiniest amount of protection from them.
> It's software patents you should be worried about, not open source projects that try to offer you even the tiniest amount of protection from them.
Amen to that.
So if the reciprocity clause in Facebook's patent grant is a problem, all recent MIT licensed software out there without a patent grant would also be off limits.
Obviously the conclusion that follows is that I think React Native is going to be a revolution for mobile development. Not only will it succeed, it will get copied, and you'll have many variants of the same like-minded platform (open source, developer-oriented, low-barrier language).
Regarding the article, my point of view is that some points in this article are valid, but are trivially obvious:
- Javascript is Javascript, take it or leave it. Flow and Typescript is an evolution that to me looks good. It is one language that was adopted to be user-facing in React Native. According to Apple's Developer terms 3.3.2 and 3.3.3 only interpreted languages that run on JavascriptCore are allowed to be pushed to market.
- You can't know what the future holds. I was part of the Ruby community at the start, then Node, then Go. I was hard core into .NET, and before that Java. I saw platforms and technologies rise and fall, and was surprised over and over. I was much into Silverlight, a technology that Microsoft wanted to take over native development on the Web. Guess what happened to Silverlight? THAT was very nasty. We all know how that feels, but that's nothing to attribute just to React Native.
- Regarding patents: I believe we will have alternatives to React Native long-term, with the same properties but we'll still choose React Native :). However I also believe Facebook doesn't use patents in a bad way that the author hints at, as far as we know and as far as we've seen. I also met with core React Native developers, and they're awesome.
Practical advise: I'd suggest for the author to meet with the React Native core team.
Where can I find them?
Same with switch fallthrough, same with error handling, same with half his issues with JS.
There are some legitimate grievances tucked in there, but the author lost me by pretending that his preferences were universal.
RN supports iOS, Windows, and Android. Plus RN is somewhat close to React, so some code could be reused between the two. Plus you get out-of-band code updates!
Xamarin supports iOS, Windows, and Android. But there is no web story. Or is there?
The JavaScript toolchain is more than good enough to build the kinds of applications that React Native targets. Most of these applications aren't stellar apps that require critical performance or rigorous type checking, they're just dumb front-ends to REST endpoints. If you're going to build an awesome app, then use better tools.
The reason I would use React over Xamarin is simple: Speed of training and development. I can hire, train and get a React developer up and running and building proof-of-concepts a lot quicker than on Xamarin.
Because targetting javascript has a lot of advantages, being cross platform is a major one of them. You basically get the type-safety of swift, with the ability to target multiple platforms.
The fact that it transpiles to JS is irrelevant, you can provide a safe interface to something unsafe. Take Elm for example, it transpiles to JS and yet guarantees that you will never produce a runtime exception.
TypeScript has a flag that prohibits switch fallthrough, for instance, though that's an easy one to set up a linter to catch.
One reason I prefer NativeScript to React Native; they are embracing TypeScript and Angular vs. React. I find Angular 2 to be more flexible, but that I freely admit is a preference.
With a proper type system (see: Haskell, Scala) and parametrized types, you can do everything that’s reasonable in a dynamically typed language, too.
I've worked on large production codebases in the past, for servers written in both Java (at company [a]), and JavaScript with Node.js (at company [b]).
The Java codebase was much easier to read, understand, navigate around, and debug. If a function took an argument "SomeClass foo" I could look up "SomeClass" and know exactly what it was.
In the Node codebase, if have argument "foo", you're lost with no easy way to figure out exactly what this "foo" is. You would have to run the code, set a breakpoint, and inspect "foo".
In addition, JavaScript encouraged a lot of bad coding practices that almost made me want to cry.
In the Java server, we used a JSON library where you would annotate a class, and the library would construct an object for that class. This guaranteed the JSON was well-formed, among other things.
In the Node.js codebase, people would pull something out of Mongo, chuck it in a variable "data", and then do "data.foo.bar[1].qux". (Yes, the "[1]" is real.) It was terrible.
The company that used Node.js had far less reliable code overall, and their services (written in JavaScript) would crash frequently, most commonly due to type errors.
And this is just a tip of the iceberg. There were so many problems that attributable to the choice of JavaScript as the language for a large, complex back-end system, and the failure to use any tool for type checking (like Flow), in addition to bad coding practices.
[a] Amplify Education, Inc. https://www.amplify.com/
[b] Lifion, a division of ADP. http://www.lifion.com/
You can, but you can't get any guarantee that said assertion will never fail.
Granted, that benefit is probably minor, but it is a benefit in TypeScript's favor.
At a previous job we tried TypeScript but it took around 20 seconds to build our front end. Since then I hear speed has improved.
I would say that a very fast edit-run cycle is an advantage of dynamic languages -- especially if you can edit code live without restarting the application -- but that's not always the norm.
* Look up member names
* Look up object hierarchy structures
* Run code (or tests) to verify that you've done the above correctly
When the compiler knows the types, it can bring your code up to 90% correct. Half the time you don't even need to specify types: TypeScript can guess them from context.
You need to specify parameter types and return types; if you're declaring a variable without initializing it, or assigning it an empty array or object, you need to specify its type. Other than that you generally get type inference from TypeScript (at least as of 2.0).
It just makes the dynamic typing safer. It absolutely should be considered a best practice; anything that can accelerate development by 100% or more should be.
While it can be tremendous help, calling it a best practice misses the point.
And having ES2015 features (+async/await) is very useful: var should be deprecated, arrow functions should be standard, etc.
Tiny projects? Sure, do whatever you want. But I've started switching even my one-file, 2-3 screens of code Node servers over to TypeScript, and it's not only useful, it accelerates development by 100% simply because you don't need to run your code to know that you've got the types correct.
I stand by "best practice."
I strongly believe statically typed language are objectively superior to dynamically typed ones. Many might say that this is my subjective opinion or just a matter of personal preference, but I absolutely disagree.
[†] (a bit of) my experience explained here: https://news.ycombinator.com/item?id=12594616
I wouldn't even consider dealing with a big JS codebase without either Flow or Typescript now.
The funniest/alarming example for me though was immutablility. The documentation exhorts the developer to take care not to make assignments to immutable objects. And there's your immutability: just don't change object and it will be immutable.
For complex applications I'm as leery of it as anyone else.
In this case, I half agree, because I think mobile development is best done using native platforms. But if you're doing web development, JavaScript is a must. And React is an elegant way to handle browser UI (Flow/Redux is also quite nice way to handle browser state, if a bit verbose).
I do share his concerns about the patent clause, and about Facebook's long-term commitment to the project, but at the level of personal projects, these concerns have not been enough to scare me away.
Right. And JavaScript is not that language, unless you are doing web stuff.
Do I hear an echo in here?
"I think mobile development is best done using native platforms. But if you're doing web development, JavaScript is a must."
Hey, RMS, Abelson, Sussman, Steele, Guido, Larry, Matz, Richard Gabriel, ESR, DHH, Flatt, and Felleisen, it turns out you're not true programmers! Okay, cool.
Needless to say, I claim No True Scottsman.
However, if the error occurs inconsistently, this approach can be much harder to use.
The problem I think the OP is talking about is when there is an error thrown somewhere in the react library code (e.g. in renderComponent) and the stack trace doesn't even touch any of your code. That makes it really hard to find the fault behind the error.
This is a lot more common with libraries like RxJS, but I've seen it with React as well.
The only way I know of to deal with these situations is to put console.log calls everywhere in my code until I've narrowed down the source of the bug.
https://www.facebook.com/groups/reactnativeoss/permalink/159...
This man, my friend, is an idiot.
I am not a React Native developer, but I am a React Web developer (not by choice). The author summed up my feelings about React and JS in general so eloquently. The Swamp Castle and Freedom from Digging bits were so on point.
I am betting that my comment will get buried in the bottom of the comment avalanche, but if the author is reading, thank you for making my day!
1. RN releases a new version every 2 weeks breaking my app every time. NS is a lot more conservative between releases.
2. I don't like mixing presentation and logic, RN encourages doing so, NS does not.
3. TypeScript is a first-class citizen in the NS environment, it is not in RN.
4. Angular 2 > React
5. NS created a smaller executable with better performance than RN for my test app.
6. I couldn't get RN to work with one of my older devices (KitKat), and even though dozens of developers had already reported the issue, they don't care. NS worked in the same device just fine.
7. All the tooling around the RN ecosystem is very confusing.
Apparently the free version has usage restrictions? I do consider free w/ Visual Studio Pro license not really free.
EDIT: The licensing pages are confusing but you're right, my mistake.
Sounds pretty reasonable to me.
Titanium has always been a pretty advanced product however ever since Appcelerator introduced it's licensing/arrow stuff, Titanium (and Alloy) uptake seems to have fallen off a cliff.
And TypeScript solves 80% of his complaints. A good linter with ruleset hits most of the remaining 20%.
Cross-platform is the way to go in 2016. It's a waste to write in Swift and Java to cover two platforms.
However, there are also some pretty excellent benefits that come with all the Bad of React Native and JS so for the moment, it can be very much worth the trade offs. I've been working with it for over a year, and for now I'll be sticking with it.
The exact same thing could happen to the React community. I'd say stick to true open source projects and descentralized communities.
Besides React is not a platform like Parse was and it should not impact the community to the same degree even if Facebook pulls out.
console.log(a === b) // true
console.log(1/a === 1/b) // false
That's perfect math you mean, of course -Infinity != Infinity, what did you expect?
I think you should rather think harder, learn math possibly, and your 'safety' problems with arrays are not problems at all, it's the opposite for other people
== is only defined for numbers, too.
1/0 and 50/0 aren’t the same, for example.
Oh the irony, when stating that 1/0 = infinity. If you'd learn maths yourself, you'd know that 1/0 is undefined.
1/0 is like 1/0⁺ (limit of 1/x in ]0,+∞[ when x->0) == Infinity.
1/-0 is like 1/0⁻ (limit of 1/x in ]-∞,0[ when x->0) == -Infinity.
1/Infinity is 0 ....
0/0 is however an indefinite form, so it's NaN
so the behavior of JS makes sense
And even if 1/0 and 1/-0 returned NaN, they wouldn't be equal to each other too
No, you just forgot to put `this` in front of `width` and `height`. (Arguments do default to `undefined`, though.)
What are some examples of good apps currently in the store, written in React Native?
return {{a: 4}}
Isn't valid anyways. ESLint easily flags it as an error.
But I think TypeScript should also be considered a best practice, and between the two that would solve pretty much all of his complaints.
Well, that and using "==" to compare to null, vs. "===" to compare to everything else. But the linters all can make that distinction as well.
But he explicitly hates on linters in the article as well. And dismisses TypeScript and Flow ... because his coworkers aren't being forced to use it? THAT is the real problem, I think...
Didn't say this explicitly, but TypeScript will, by default, prohibit unreachable code as well. [1]
[1] "allowUnreachableCode" defaults to false: https://www.typescriptlang.org/docs/handbook/compiler-option...
"The fact that millions of drivers productively drive cars without wearing a seatbelt isn’t a good argument for cars with no seat belt. Similarly, the fact that millions of JavaScript developers productively use an inherently unsafe language isn’t a good argument for the use of unsafe languages."
If you're going to RN, go Pure Native at the same damn time ;) It's awfully ironic since they market RN to rid us of the need for Pure Native. Or, is it ironic? It seems this clause and their marketing efforts are truly shield and sword. I'm not really surprised; it's a very cunning way to hijack ideas from other people.
I have used RN, though, and it's a blast to develop with it. Thankfully, none of my kooky ideas are going to be important enough for this fine print to apply to me.
From what I remember, the final version of Angular 2 added a lot of performance, which pushed it ahead of the latest React in performance.
I did find this:
http://webscripts.softpedia.com/blog/recent-benchmark-shows-...
But the Auth0 benchmarks disagree and show React is faster:
https://auth0.com/blog/more-benchmarks-virtual-dom-vs-angula...
Angular 1 is terrible performance-wise; that much is certain.
Fool me once, Angular team...
Javascript is like democracy. It works best when:
- lots of people participate
- we understand its warts
- it's allowed to evolve
- the powerful aren't allowed to write the rules
I will be very happy to see an app in React Native, just to check if it is as responsive as Objective C or Swift.
If you just want something easily replaceable, use something like cordova.
If you want perfectly native and guaranteed support, use the native SDKs.
If you want simplicity with a javascript framework that compiles to native with the concerns of it being made by facebook then use react native.
React native solves a lot of peoples problems especially if they are starting an app from scratch.
I rest my case. There's a place for manual memory management. It's not in application code.
Of course, ARC has its own problems... Hope anybody implementing graphs knows what they're doing, or you'll leak memory like Niagra Falls.
For instance, nobody uses Objective-C for iOS development any more (see: Swift). And modern Java is a decent language to develop in (with Rx and the like). You can even develop for Android in kotlin, which gives many of the advantages of JavaScript, but with a static type system and deep IDE integration.
I won't argue with you on how good the languages are. It's a matter of opinion, and I'll never change your mind.
Besides, establishing one langauge as better than another was never my point.
> Compared to React Native, both Xamarin and Appcelerator have better prospects at longevity. Appcelerator (the maker of Titanium) (runs on apps installed on 350 million devices) was acquired in January 2016
Last time I tried (circa 2013) Appcelerator seemed a bit unpolished and the tooling was sub-par (I vaguely remember of some hacks needed to get their custom IDE runnning on Windows), I would like to know how are they doing now. Could anyone familiar with it summarise their recent developments?
In big companies app releases are a huge problem when 100+ committers and tens of features are released to the same app sometimes within the same app update. React Native has the potential to enable feature teams independently update the app.
Maybe I'm misinterpreting this, but is the author actually advocating for Java-style checked exceptions? I can't even remember the last time I heard somebody say something positive about them (other than just now, possibly).
Yeah, Android is growing, but iOS still has substantial market share. Switching to React Native will definitely not give a > 100x increase in outreach.
You're right about the last part, though. You won't literally get a 100x increase in reach from just switching to React Native. Being able to develop on two platforms at once might help a little bit there, though, which is what I think the author was trying to say.
Similarly, Flow/Purescript/Elm have every ability to provide a safe interface to javascript.
Is this really true? Or is the author referring to the dev. edit/view loop?
It's an ML-like language with built in functional reactive framework similar to React, but built to work naturally with the language rather than requiring the FFI binding you'd need if you use Purescript.
Also, you still need FFI in Elm. elm-lang/virtual-dom is basically just a wrapper around the native virtual-dom library. Also, afaik there's nothing like react native for virtual-dom.
[0] https://github.com/arthur-xavier/purescript-react-native
1. uncertain roadmap
It's open-source, and given the amount of contribution and efforts to get third party targets for windows, ubuntu and mac I seriously doubt it's going anywhere any time soon.
If you look at React proper, it's not much different, and that has gone incredibly well... React has some of the best diagnostic information in terms of error/warning states of any web ui tooling I've used.
2. Patent grant
The reason for the separate patent grant is because a copyright license, particularly a permissive one like BSD (or MIT, ISC, etc) do not specify patented parts of the application. MS-PL iirc was basically an MIT-like license with a patent grant (with nuclear deterrent) attached.
Most large companies that are publishing larger open-source tools have similar clauses to their patent grants. That said, I'm against software patents as a rule, so this concerns me very little.
Hell, Apple's swift license has a similar provision...
... If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
3. JavaScriptI won't argue the merits of JS over other languages... I will say that I've enjoyed working with it, it's my favorite language, warts and all, and that you can write horrible code in any language.
There's TS, flow, eslint and many other tools to help with issues there.
The cartoon illustration predates npm, es6 and a lot of other work towards making things a lot better. Also, you've already invested into React*, then you may as well invest in babel/es7+, redux and a handful of other options that do add a direction.
3. Dependencies
That's the nature of large software projects... also, with node ecosystem, it means that React doesn't have to re-create a lot of work that has already been done.
4. Alternatives
As to Xamarin and Appcelerator, what about web and desktop targets? You will have to re-create a large amount of your codebase, and even non-ui bits in order to support them.
SUMMARY:
In general, I understand your arguments... but you're missing one... You can use a single unifying platform and language for all of your front end and back-end code while being able to target pretty much every platform in wide use with minimal changes.
The JS/npm ecosystem is one of the most vibrant in developer history, while a mixed blessing sometimes, it does work incredibly well.
He briefly mentions hot reloading and declarative UI at the start, but it's drowned out by his ranting on JS and doesn't seem to earn it any points in the end. But those two are huge boons for UI development, to the point where it's worth putting up with JS's flaws as a language. Flexbox and media queries make CSS pretty decent for layouts. Dynamic languages are a double-edged sword - for UI you often want something up and running and useable to see if it actually feels right, without worrying about interfaces and types too much. Objective-C and Java can feel clunky in comparison.
Are you really trying to say that React Native makes Java not relevant for Android and ObjectiveC/Swift not relevant on iOS. Maybe you are correct if you want to build Hello World application, when you will be needing something more optimized sooner or later you'll have to rewrite it in Java/Swift.
So, question for people who use React Native - how long does it take to go from [100% front end developer familiar with React] ...to [writing solid native apps] with React Native? And how much platform-specific knowledge outside of RN do you need to absorb in order to do this well?