Why I'm not a React Native developer
arielelkin.github.io
arielelkin.github.io
1. Uncertain Roadmap - Does anyone seriously doubt FB's commitment to RN? When they themselves dogfood it? Or is it more likely they are just too busy making progress (since as the author points out they release every 1-2 weeks) to release a multiyear ROADMAP?
2. Patents - Is anyone here planning on suing FACEBOOK? Who amongst us has the team of lawyers to undergo that? This is for 99.999% of people not a legitimate concern. This is an RMS concern.
3. Javascript - New versions of Javascript address the vast majority of this. Type errors? Use well supported Typescript or Flow
4. Dependencies - This is a result of the Javascript communities overly enthusiastic packaging efforts. This is not an apples to apples comparison, but of all the cons mentioned, sure this is legit.
5. Alternatives - ...and Windows Phone? Seriously? I was rooting like hell for MSFT, but this is just not a thing. I'd rather cover 99.6% of users twice as fast than 99.999 of users painfully using Appcelerator
> (iii) against any party relating to the Software.
Downvoted for FUD. That license is about patents, not copyright.
After the shutdown of Parse, I don't see how anyone could avoid having doubt about Facebook's commitment to React Native, or to anything else outside of their core business.
In the Instagram app, really only the settings screens and the bookmarks feature are written in RN - 2 of the simplest features in the entire app.
Most portions of the app is rendered using Component Kit.
Push Notifications, Edit Profile, Photos Of view, Post Promote, Comment Moderation, Lead Gen Ads, SMS Captcha...and that was in February. They are ramping up their usage all the time.
I want to see examples of React Native usage in the feed or the main profile architecture. Something critical.
The FB app uses RN for very esoteric and small portions of the flows. It has 230MB (at least) of compiled binary.
Instagram also uses it minimally, mainly to replace what used to be webviews.
Those are not "major parts".
They announced it in Jan 2016 and gave one years warning and shut it down in Jan 2017. Parse open sourced many of its components and provided an easy migration path for applications depending on it.
React Native, IMHO, is a fundamental part of their core business. Among many things, it lets them ship updates and more efficiently A/B test features more frequently. If Facebook gets sick of RN, at least it's a completely open source library that's able to be transitioned to fully community supported.
I don't think it is wise to think about this in these narrow terms. Consider the following scenario:
Avoidance of these problematic license terms becomes "a thing" in the industry that moves and shakers, but not the likes of us, are worried about.
You might have aspirations to sell your company to BigCo, or get investment from VCs.
Now we have a concern that use of problematic license code is a poison pill that these investors are not willing to swallow. You aren't considering suing Facebook, but they might think about it.
We saw exactly this with GLP'ed code in the past (I have signed a couple of deals where I had to pledge on a stack of bibles that we did not have any GPL code in our tree).
Your company or startup should focus on building a great product and attracting users.
1: https://code.facebook.com/posts/895897210527114/dive-into-re...
That is not true; Messenger uses React Native for some features.
[0] https://code.facebook.com/posts/1189117404435352/react-nativ...
First, "RMS concerns" dismissed as silly and fantastic by "practical people" have been mostly proven totally valid. His dystopian essay "The Right to Read" [0] only becomes more relevant every year.
I've had to check my Amazon account 3-4 times to see if the book a friend and I were discussing supported "borrowing" it out for a limited time. Each time I've checked, it hasn't. Circumventing Amazon's controls puts my Amazon account at risk, which is hooked to my life in a lot of significant ways (AWS anyone?).
RMS may lack social graces but he is not a dummy. If anything, calling something an "RMS concern" should only call extra attention to its importance, by indicating that there's likely an understated risk that will go unrecognized by others for years.
-------
Second, you never know when you'll be in the 0.001%, and that's not a position you want to find yourself in if you are. Facebook is concerned about maintaining its position as the dominant social platform. When you're on a meteoric tear, they're going to bring suit against you whether it's justified or not just to try to starve you out and get you to fold, and ideally to find some reason why an injunction should be issued forbidding your site's continued operation. This license could certainly aid in that.
Things don't have to be very common to be unacceptably risky. Most unacceptable risks are in fact quite rare; you can go years riding in a car without a seatbelt or riding a motorbike without a helmet and be no worse for the wear.
The problem is that one time, years down the road, when it does matter. When failing to do that little thing will result in permanent, massive loss and/or damage. Maybe it won't happen to you, but it's so easy not to take the risk, that it's stupid to ever do so.
If you're building a product that you hope succeeds, it's stupid to use React or other software that contains a legal poison pill like this. It may not matter most of the time, but when it does matter, it really matters. The comparative cost of using Mithril or Preact or Vue is much, much more attractive than the cost of engaging in a multi-million dollar legal controversy with one of the world's most important companies, on one of the rare occasions when it really does matter.
But really, those charts at the end say it all for this particular developer - if he feels only 60% "Productivity" using React Native compared to 90% on competing platforms, his choice is obvious. I imagine for many developers the opposite (or even more so) is the case.
You also don't get very far with React Native if you only know JavaScript. I've had to write a lot of Objective C and Java for native modules, and I picked up C# to integrate libraries for Windows Phone.
Stallman is on record as saying he's fine with the patent clause. :)
https://github.com/arielelkin/arielelkin.github.io/commits/m...
2. Not everyone is a small company with nothing to lose.
Now I have to admit I don't know if their patents clause has any validity when we don't do business in the US, though.
Qt is still widely used despite lots of insane company merges (Trolltech -> Nokia -> Microsoft -> Digia -> Qt company). Probably because it's opensource.
> 2. Patents
If Facebook has patent for dynamic rebuilding of GUI from xml-like tree, then it may sue you for using XUL, XAML or your own code that does the same.
> 3. Javascript
Complains about type safety is laughable when compared to building apps directly in Java and Objective C.
> 5. Alternatives
> Appcelerator
Oh lol
if (weAreConnected === true) {
this.setState({
isConnected: true
})
}
else {
this.setState({
isConnected: false
})
}
}
instead of this.setState({
isConnected: weAreConnected
}) this.setState({
isConnected: Boolean(weAreConnected)
})
If you want to be super obvious, and aren't using a type system. this.setState({ isConnected: !!weAreConnected }) bo-tab(
is only two more characters :)which only applies if you're writing code for yourself. you can't expect everyone to know that idiom. same with using the + operator to cast to number, or an extreme case, the tadpole operator https://blogs.msdn.microsoft.com/oldnewthing/20150525-00/?p=...
Code should be written so that it is understandable by other professional programmers, not people who started programming two weeks ago.
People who only start coding for two weeks can't understand any code.
People who start has enough experience to work, but only start in this project for two weeks, will understand "!!" idiom.
> I would leave a note to a student for using this to be honest - too unclear, and (as this thread denotes) not well known enough to put in production worthy code.
You've done a total disservice to your students that understood negative unary operations then. Given how many upvotes my initial post on this thread has (currently 38) I don't think the thread denotes what you think it does at all.
The '!!expr' is the idiom most people use whenever the need for a canonical 0/1 representation arises.
WalterSear's solution solves the issue since both `null` and `undefined` would become `false`:
this.setState({
isConnected: Boolean(weAreConnected)
})
but in your case you could set `isConnected` to `null` or `undefined`so if later in code someone makes the mistake of writing:
if (this.state.isConnected === false) { /* do stuff */ }
they could have a bad surprise. if (!this.state.isConnected) { /* do stuff */ }
(which still works as expected even when dealing with null or undefined).Or if you pass down that `isConnected` down to a library where for some reason they assumed `null` should default to `true`
Of course it's very unlikely, but my point is you can't know all use cases of `this.state.isConnected` in advance on a large project so as you say it doesn't hurt to sanitize the input.
seems 100% equivalent
Bad languages don't allow a nice life.
So, how we can claim to "developer good software" in front of our customers and defend tools like this?
if isConnected {
backgroundColor = .green
} else {
backgroundColor = .red
}
bit, which should be a ternary.I figure that a good rule is: if the feature existed in C, you should know and understand it. If that feature is convenient and doesn't sacrifice performance, then you should use it.
Then there's this blatant misuse of the arc4random API, which I'm pretty sure the manpage tells you about.
let weAreConnected: Bool = arc4random()%10 > 4"if (isConnected) {} else {}" emphasizes to me that there are two branches of code which depends on `isConnected` state. It may have only one thing to do right now. But this is major branch. Future git diff will probably show that the code in the body the branch are added/removed.
Ternary expression emphasizes on modification of a single attribute.
The three main disadvantages of React native brought up are:
- lack of commitment from Facebook about maintaining it for a long time. This one is the most bothering to me but it's not a dealbreaker.
- doesn't like Javascript and its related ecosystem. This doesn't bother me in the slightest, I love modern JS.
- the whole all your patents are belong to us thing that comes up every so often. I'm not a startup founder or a lawyer so I will leave such concerns to them. If my employer wants to let me develop in React, all the better for me.
There are plenty of people who are quite happy with what they have, and they see no reason to change. Then there are people (thankfully) who are never satisfied and who keep progress rolling.
“Here's to the crazy ones. The misfits. The rebels. The troublemakers.”
I will admit that Swift is a much better language, but I prefer working with modern JavaScript these days.
Is your employer _aware_ of this particular razor blade in the candyfloss?
I know managers should check these things with legal but most of the time people sort of assume that since it's open source and everyone else is using it - it must be fine.
Even TypeScript won't get you close to Swift's compile and runtime security.
If Xamarin worked on GNU/Linux, we likely would've built our app using it and F#. Until it comes to the Linux world and stops doing things the MS way (open sourcing is a good start), Xamarin is going to be missing out on a number of developers.
Im curious, what kind of code do you share between your server and app-client?
That is indeed pretty awesome, but wouldn't it be even better were it a better language than JavaScript being bridged to? I'm thinking Lisp, or Python, or TCL, or pretty much anything other than INTERCAL or JavaScript.
- How is perf in a large app with lots of network IO? - How does animation/ transition fit with reacts render loop and how does it perform, especially during network IO? - How much is lost from not being able to do multithreading? - How hard is it to achieve the last 20% fine tuning of feel and perf? - How much flux is the community driven deps typically causing? - Is memory management an issue? GC stutters, leaks? - Do some UI parts simply not scale well enough, requiring native code instead? e.g. infinite scrolling, charts, complex transitions? - How mature is the tool chain? Build time? - Frequency of breaking changes from core? from common deps? Cost of staying up to date?
Developing in JS, with all the pros/cons of the JS language, is the very premise of the react native deal. Most issues raised would apply just as well to any web app.
class Person {
get isImmortal() {
return false; // noone is immortal
}
}
p = new Person();
p.isImmortal
// >>> false
p.isImmortal = true;
p.isImmortal
// >>> false
I mean, even plain untyped JavaScript can do that!And sure, Object.freeze exists, but almost none of the JS code I've seen uses it. And what's the point really when assignments to frozen fields don't even throw an exception, just fail silently. Same for getters. None of those tricks are gonna make JS into a good language in the eyes of people who don't for whatever reason consider it good already.
The bulk of the gripes about JavaScript are entirely fair, but I'd think that most people who use React Native would be aware of them already?
I'll list the annoyances:
- npm is a mess, and many libraries in the ecosystem handle sub-dependencies improperly. Facebook has contributed to yarn but has not established a very clear contract for what a properly organized package should be. Thus it is not possible to easily determine which package or sub-package, or sub-sub package (etc) is misbehaving. I estimate that this issue has eaten up easily 10% of the productivity gains that React Native has offered. Facebook generally ignores the github issues about this stuff, in spite of hundreds and hundreds of users having these issues.
- Updating to a newer version of React Native is cumbersome. There is a utility called react-native-git-upgrade which often fails to reconcile changes in the ios-specific configuration files. Much of this is due to problems with XCode (not sure how anyone tolerates using that). Compared to simple makefiles XCode's system that react-native interacts with is horribly brittle.
- Important libraries are not embraced by Facebook. Things like camera support are not included in React Native's scope, so third party libraries exist, yet often lag because the developer can't make time to keep up with pull request. Facebook should hire the top 15% of community contributors to maintain those projects in-house. Right now probably 30-50% of community libraries are not compatible with the latest stable React-Native. Facebook should realize that library maintainers do not have enough time to properly maintain these libraries and should offer more support and guidance, not to help the maintainers as much as to help people trying to use open source libraries from the community.
- Some of the React Native code is pretty ugly. A few times I've had to debug issues and some of it looks like it was written very rapidly and could use a refactor for clarity and ease of debugging. Not the core algorithms stuff, just the bundle management stuff.
But in spite of all this I'd still use React Native on a new project. Most apps that aren't strongly architecture-driven could be written in a day or two. It's pretty amazing.
There is a dependency tree here around whether you currently (or plan to in the future) have any patents. If you don't and you never do, then how can Facebook infringe it in a way whereby you'd want to sue?
And then there is the cost of suing. We seem to be reckoning it would cost around $1m to start a serious action against FB, so what does the cost of replacing React look like in that sort of scale? We've costed that, in broad strokes.
So on paper, it all looks like we're fine, right?
But...
But...
Here's where they take pause:
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 [...]
Subsidiaries? We don't have any of those."Corporate affiliates"? What does that mean? Oh, it's anybody who owns at least one share in us, or we own one share in them.
Wait. What? We have business angels, founders, multiple VC firms and other investors. Do any of them have patents that Facebook might infringe on? What about future investors or people who we might want to be acquired by? Could we have an acquisition blocked because the potential buyer has a war chest of patents they value?
And "agent" means external law firms too, right? So if any of the companies we use for advice on an on-going basis get involved in any patent action, what does that mean for us?
Suddenly it becomes this huge sprawling mess. Risk aversion is important when you're dealing with a company that is already carrying a 9-figure valuation.
We're trying to find a way around it. As an engineer I brought it up with Legal because I want clarity for colleagues and myself: we want a green flag.
Unfortunately, in doing that, we may have brought enough scrutiny to it that they are going to tell us to stop using it.
If/when that happens we'll talk about it and share that information.
In the meantime, we continue to use it, but we're doing so with caution, and we accept there may be a re-tooling cost.
The Facebook iOS app is slow, bloated and occasionally glitchy. A company like Facebook seriously doesn’t have the resources to make Android or iOS native applications? Because React isn’t “native.”
It's certainly possible to use any native API you like when using React Native. You can easily write a modules to bridge to native APIs, but you need to be comfortable to drop into native code when required and do that work for both android and iOS. If you don't feel able to do that, you'll be limited to the libraries that others have already written. It's not hard to do though.
It's easy enough to add a native module to address specific hardware -- so easy in fact that you can usually find one already done (ARKit for example: https://www.npmjs.com/package/react-native-arkit). As with all 3rd party library use you have to do your due diligence of course.
The more of these you use, the less 'cross-platform' your code becomes. If there's enough similarity in hardware between platforms, you might write (or find) a react-native library offering a javascript/RN API that addresses native apis under the hood. This is done with animation, for example.
> A company like Facebook seriously doesn’t have the resources to make Android or iOS native applications?
I'm can't imaging they don't have the resources, and know nothing about FB or its motives. But if I was managing a large cross-platform app, I'd definitely want the largest number of developers I possibly could have communicating via a commonly understood codebase, rather than via meetings and specs.
Was curious about counter arguments and came upon this : https://medium.com/@reicheltp/dev-diary-4-why-i-left-xamarin...
A little old but I think I prefer RN's disadvantages over Xamarin's
Making so many errors in a sentence about basic language features, when a big chunk of OP's article is argumenting that React Native is bad because JavaScript is bad... Maybe it would be less bad if OP actually learned the language?
Makes me picture some language where you write "1 = 2" and from then on in your code all 1's are 2's.
I definitely endorse freedom of speech and thought, but unless one is a vetted expert in the matter, one should avoid making these blog posts. I'm not the best chef in the world and I do things a certain way, but I do not go around the world telling people that they should do it my way.
And the conclusions seem to favor Phonegap, really? Xamarin might not be that bad but doing really nice UI on both platforms require two separate projects (or modules at least).
My bets are still on Javascript :)
If you insist, you can use Xamarin Forms and have an equally terrible UI on both platform as RN.
As much as these features might "bloat" the language, they provide some much needed and much desired elegance.
I have a need for an app that is mostly word-processing oriented in nature with some interactive graphing and drawing, some displaying, creating and drawing on top of PDFs too. I'm looking for easiest path to create something crossplatform AND performant (and possibly easy on the battery).
> both a desktop (Linux/MacOS/Windows) and mobile (tablet and phone, android and IOS) application from same codebase... word-processing oriented in nature with some interactive graphing and drawing, some displaying, creating and drawing on top of PDFs
... definitely doesn't fit that description. At that point, your choices are JS with RN, React and Electron or C++. For custom graphics rendering and editing, JS would be a very odd choice.
There are some desktop bindings available, but they're relatively experimental:
https://github.com/ptmt/react-native-macos
https://github.com/Microsoft/react-native-windows
https://github.com/jamrizzi/react-gtk (no code yet, just intent to develop)
I also thew the logic/state/HTTPclient part of the app behind a crappy Electron "desktop" UI the other day for giggles. Wasn't hard, took about half a day. No design or releasable GUI in that amount of time, but you can click buttons and fill in values and stuff happens, using the same code as all those other platforms do (or will, in some cases—it's ongoing). So you can't share the GUI, but you can share pretty much everything else.
> (and possibly easy on the battery).
React Native's not too bad, compared to other cross-platform whatevers that have come before it. Electron kind of almost flirts with being easy on the battery at its very best, but hell, no-one else seems to care about that so why should you?
> creating and drawing on top of PDFs too
Oh god. Have fun with Android and PDF. Yeesh.
[EDIT] I should add that you can always add native code to React Native projects for parts that need it. Not sure about Electron, but... maybe?
The author mentions Flow as a typing solution to solve some of the problems with Javascript development, but didn't like it because you can still write code that crashes if you ignore the warnings. They also complained about the lack of immutability, and mentioned Immutable.js, but weren't happy with that. They went on to say that most of these problems they mentioned are already solved with libraries, but ... libraries are bad? I didn't really pay attention to the huge Javascript rant in the middle, but I've heard it all before, and I totally disagree. I've started to realize that I prefer ES7 Javascript with Flow or Typescript, jest, babel, webpack, etc. I think I actually enjoy writing it more than Ruby or Swift.
I really like react-native-web [1]. I've used it to build an app that runs on all mobile devices (iOS, Android, Windows Phone), as well as on the web. There's a lot of quirks and workarounds, but it was actually a lot easier that I expected. Even if you just use plain react on the web, it's easy to write re-usable components and code.
They also mentioned hot reloading. If I wrote an article titled "Why I'm a React Native developer", the content would just be the words "Hot reloading." I spent a year developing a native iOS app with Swift, and I never want to go back to waiting for my code to compile.
class ViewController: UIViewController {
let indicatorView = ConnectivityIndicatorView()
override func viewDidLoad() {
super.viewDidLoad()
indicatorView.frame = CGRect(origin: CGPoint.zero, size: CGSize(width: 20, height: 20))
view.addSubview(indicatorView)
}
}
class ConnectivityIndicatorView: UIView {
var isConnected: Bool = false {
didSet {
render()
}
}
override func didMoveToSuperview() {
super.didMoveToSuperview()
isConnected = arc4random()%10 > 4
}
func render() {
backgroundColor = isConnected ? .green : .red
}
} const Root = ()=> <ConnectivityIndicatorView/>
class ConnectivityIndicatorView extends Component {
state = { isConnected: false }
componentDidMount() {
const isConnected = Math.random() > 0.5
this.setState({ isConnected })
}
render() {
const backgroundColor = this.state.isConnected ? 'green' : 'red'
return <View style={{backgroundColor, width: 20, height: 20}}/>
}
}
And here's how I would actually write it in my own app: const Root = ()=> <ConnectivityIndicatorView isConnected={Math.random() > 0.5}/>
const ConnectivityIndicatorView = ({isConnected})=> {
const backgroundColor = isConnected ? 'green' : 'red'
return <View style={{backgroundColor, width: 20, height: 20}}/>
}Do engineers actually depend on the compiler to save their ass and don't bother looking up in the documentation or reading the source code to see what a function returns !? No I don't think so. There's a saying that every bug that ever existed in a static typed language actually did pass the type checks. If the compiler finds a bug it's rather luck that the two parameters passed in the wrong order was not both of the same type, and not because of better language design. If you don't know what a function returns, you can say "bad documentation", or "bad code", but don't blame it on the language.
I know the == operator drives people crazy sometimes, and you are told to use === but if you actually understands what == does it's a convenience that null==undefined so you don't have to type if(foo == null || foo == undefined). You could argue that having two (or with false it's three) types of "nothing" is confusing, but for me they mean different things. undefined means it has not been defined, null means it explicitly "nothing" and false means it's "not true". And for convenience you can write if(foo) to check for them all.
For example, say that you want to implement login/register on top of an existing Swift codebase. This is possible, right?
(May not have understood OP correctly.)
https://facebook.github.io/react-native/docs/integration-wit...
I love to have a react-native-like for just the UI and do my code on swift/F# for the rest.
If you mean adding native modules into an essentially RN app, that's practically very simple (https://facebook.github.io/react-native/docs/native-modules-...) but still requires some conceptual care (like any API design).
But I aggree with all the problems of javascript, they were my excuses to not learn javascript, and here I am, writting RN apps. Things happens in RN world man, you gotta move to the winning side and leave your pride. Get over it.
It's a shame that no one takes something like the old Android codebase and makes it for web in the canvas. Is that even possible?