r/reactnative • u/[deleted] • Mar 21 '21
Flutter vs React Native: a principal engineer’s viewpoint (Part I)
I’m so fucking tired of this topic, of endless analysis paralysis and holywars people seem to be having, so here is my jerry can of fuel to the fire.
Disclaimer: I work as a principal engineer in a company that earns money from a mobile solution lineup. I have personally reviewed Flutter and React Native, and decided to go with the latter, but not because it is so wonderful.
Anyway.
Neither of frameworks is superior. In fact, both are garbage in one way or another. I mean, they are both brilliantly engineered, and their maintainers are really great specialists. They are garbage in the sense that neither will solve all your problems perfectly. In fact, every technology that exists out there is more or less unfit for the job you are struggling with. That’s what you get paid for: solving problems by using flawed tools to make imperfect solutions, that are simply better than no solutions at all.
Literally, stop hoping for The Perfect GUI Library, it will never exist. No kind grey bearded wizard will wave his wand and give you a magic tool that will allow you to make splendid apps in no time, and earn easy money by writing poetry in code. Anyone who tries to sell you this is preying on your naïveté. There will always be a catch.
Your job is not about that. Your job is not about making the Most Wonderful App Ever at all. Your users don’t really give a shit about what your app runs on, and even what performance you have managed to squeeze out of it. OCD clowns from Management can give you some hard time about it, but it’s likely because that particular manager has managed to disconnect themselves from the actual needs of the business and customers so much, that they have the time to holler about some minor bugs and performance hiccups you may have that are of no consequence to the users at all.
Your job as a person in Engineering is to help your business solve tasks it faces on the technological front, and to identify and take care of the most critical tasks first, and of other if you have some free time. You should worry about making things happen, not about finding the best application structure (I can’t call it “architecture”, sorry) or rewriting stuff from one framework to another.
If your business’s livelihood solely depends on your screen rendering 300 milliseconds faster, your business is up shits creek no matter what you do, because this is not a viable business scheme in the first place. If your business, on the contrary, is doing something impactful for the society, your app can be a webview running jQuery, and users will be happily using it daily.
Anyway. That was one long and boring intro. Sorry.
So, React Native and Flutter. A description is warranted of both, highlighting the most conceptually important things (and not marketing fluff that get repeated from one “highly reputable tech company’s 5-reasons-my-ass blog post” to another.
React Native: Escape Hatches and Capitalizing on prior art.
First there was React, a method of developing user interfaces that scaled amazingly well on the scale of Facebook and tons of other projects. It’s gravitas dragged in talent and created a huge and nice, if a little hectic, ecosystem around it. Lots of things sprang up from these approaches. For example, there is a wonderful library called Relay that is basically an advanced data layer that is already written for your app, provided you use GraphQL of course. React Native gets React updates almost for free. You get some of the smartest battle-tested GUI concepts like Suspense for free. You’ll soon get Concurrent Mode in all its glory. Building upon React was a design decision. It capitalized on prior art.
Naturally an idea to replace DOM entities with platform-native views came into people’s heads immediately, because native GUI frameworks are just as battle-tested as are browsers. Plus, all of the apps out there are native apps, and you can’t really adopt any technology that drags in a foreign non-native stack incrementally. Operating Native views was a design decision. It capitalized on prior art.
Leaving JS was a design decision too, because it allowed to run huge amounts of code that has already been written. Lots of libraries available in the JS ecosystem at that point were familiar with running in both browser and in the server environments. This was a design decision, that capitalized on… you get it.
React Native is all about capitalizing on prior art. It is also a very boring framework, you could literally write it yourself. When it is was unveiled, my colleague of that time, who wasn’t even a programmer, was in the process of finishing a prototyping tool with hot reloading that worked exactly like React Native would work. It is straightforward to understand, it has little magic in it, and as a senior engineer, I like it very much. I wrote patches (very rarely) for React Native because I understood how it worked.
React Native is actually full of escape hatches and customization points, sadly not all of them are documented though. It is very hackable, and projects like react-native-skia or react-native-v8 show that. Hermes shows that it can incorporate some of Flutter’s fortes like AOT compilation without breaking a sweat. JSI shows that you can call native APIs with the same performance as if you wrote it natively. And with all this you can still run Relay, soon in Concurrent Mode for Data Fetching, with Error Boundaries, Suspense and all other modern GUI engineering concepts.
That said, React Native is not an easy tool for beginners or people who seek to quickly switch from pure frontend (or pure native) development. It is utter garbage in terms of how it treats new developers. Its tooling has lots of moving parts and the official team seems not too interested in improving developer experience just one bit (it is mostly Callstack and Expo who push for that). It is not as thoroughly documented as it could be. It fails to formulate and describe its design decisions, even though they, IMO, are dirtily pragmatic and brilliant. It sometimes suffers from lack of curated libraries (again, no resources allocated on that, because an attempt was made and failed).
It should not position itself as a tool for novices, actually.
React Native is about transferring successful concepts between classic frontend engineering and native GUI engineering, not about hiding complexity. It is about scaling the concepts that your app is built upon, while aggressively incorporating and reusing everything that has been done before. It is a tool for the astute developer who questions what they are doing and why.
It is an immensely powerful idea of framework that is driven by concepts inspired by natural evolution driving forces, and while it may never become perfect, it will claw itself out of almost every problem there can be.
It can be staggeringly ugly, as some living and evolving organisms are, and it is absolutely imperfect, but it’s architecture (not to be confused with “application structure”) ultimately allows it to be improved one point at a time.
But this all are technical details. As I said in the intro, this is a ultimately only as important, as consequences for your business are. React Native will not allow you to make an app super quickly or super cheaply, but it can reduce your costs just enough to be useful, and, more importantly, it will allow you to incorporate prior art from both the JavaScript and Native ecosystems. Not only the actual code, but knowledge and concepts, which is arguably more important. You can teach JavaScript or TypeScript to any good native developer, who will bring their expertise to your team, and this knowledge will be relevant. You can bring JS frontend or full-stack people into the team by gradually introducing them into native shenanigans, and these people will bring their expertise and it will too be useful.
Ultimately, it helps immensely to have a team who can reason about the entire stack, because the worst thing you can have in a tech team in 2021 is partial blindness in some points of the tech stack and really narrow focus of some team members. It breaks team synergy, and it allows people to stop considering product in its entirety and lazily focus on their own small damp corner, all while slacking around and keeping people away from disturbing their comfort zone.
React Native is not perfect, but it enables some really powerful concepts in areas like competence management, which are beyond “writing code and making it run”.
Choosing React Native was a strategic decision for our team and we are still reaping the rewards. It was not all bright, and for some tasks we had, Flutter would have been way better. But I’ll first focus on positive sides of both and only then I’ll dive into the negative ones.
Part 2 will be about Flutter, their comparison with RN and numerous downsides of both, and Part 3 will be about my story with both and conclusions. All parts are (hopefully) coming soon…
7
u/Sethu_Senthil Mar 22 '21
React Natives code push is a real big one for me, depending on the project (hobbyist) I switch from flutter to RN based on that
2
Mar 22 '21
Yes, that’s a useful feature! Saved us a couple of times already, although we use a self-made solution to support more strict security requirements we have regarding JS-bundles.
2
u/VytautasDidysis Mar 22 '21
Agree. And it's often not mentioned in comparisons between RN and Flutter. Had to look into it specifically to find out
4
u/TECHNOFAB Mar 22 '21
Been working a bit with Flutter some time ago. The app wasn't great but I learned a lot about how flutter works and I think I could do it better now. I'm personally way more into Dart than anything JS related, TS is okay-ish (using it for Angular currently) but I like Dart more. Didn't do much with React/ReactNative tho until now. Is it worth looking into it? Especially compared to Angular and Flutter respectively?
1
3
u/FixingKitty Mar 22 '21
Native look and feel (especially on iOS) and Codepush makes Flutter a no go for us. We release stuff several times per week, but only goes through the app reviews when there’s a new major RN version. Saves so much time for a small startup!
1
Mar 22 '21
Interesting! By the way, can you elaborate, how much are native look and feel important for you? Do users comment on it? I’m asking because our apps are in platform-neutral branding, and I’d appreciate if you shared experience from the alternative standpoint.
3
u/FixingKitty Mar 22 '21
Yeah, this probably stems from both me and the other developer coming from 8+ years each as iOS-developers.
So it's not so much styling but the timing of animations, button states, drag-bounce feel etc.
Flutter is just not "there" yet, at least for us. Most users would probably not care or notice, but we do :-)2
Mar 22 '21
As an iOS developer with a similar experience span myself, I salute my comrades in arms! :-)
I agree that Flutter still has to reproduce the “snappiness” feeling inherent to iOS. (Especially with that shader issue, although I say it at risk of being beaten to death by Flutter people).
4
u/NickHack997 Mar 22 '21
Very well written and interesting point of view on the subject! Looking forward to parts 2 and 3, but is there a blog or other platform than Reddit I could read this on as well?
4
Mar 22 '21
Thank you! Unfortunately not yet, as I literally just wrote and published it on a whim (hence some really silly mistypings and weird phrases, sorry for them by the way).
I’ve long been considering setting up a personal blog, maybe I’ll refine the text and post it there too. I’ll DM you a link if I do so.
1
5
u/ArmaniMe Mar 22 '21
Great stuff, thought I might share my point of view with the community.
I've been developing React-Native app for a year now, full time. We have a 100% native design & behavior, it is our requirement.
Here are some of the issues we've encountered on React Native:
Working with keyboard is pain, no docs & behavior is different for Android & iOS basic stuff needs to be hacked.
React Native Navigation => Costing a lot of performance, it keeps your screens up & re-renders stuff in the background, watch out for that.
The whole Redux ecosystem => Do not use it for app state, use it wisely it will consume your memory really fast & keep your logic outside of selectors.
A lot of npm packages that are out of date or without docs or doesn't do what they are supposed to OR is poorly developed that it trigger re-renders on every screen.
There is no debugger & developer experience can sometimes be very frustrating.
Keep in mind that CSS from the Web is very different on Native.
When designing your components try to pass only primitive types
5
Mar 22 '21
Great points! Thank you for sharing. Mind if I comment on them a bit?
Keyboard avoidance is just terrible, agreed. To be fair, it is absolutely awful in vanilla native too. Someone should just dive into the topic and abstract it away cleanly, but no luck so far.
I have not tried React Native Navigation recently, but I’ve been put off by the API. You are at the mercy of a library, and any upcoming improvements in React Native’s tree management (view flattening et cetera) will not help you much. React Navigation seems to work much better. A great warning, thanks for that!
We have long dropped Redux, but we have GraphQL, so we use Relay on both web and mobile, and we manage local state through it.
We have now tend to use outdated libraries as a starting point for developing our own solutions. It is faster than trying to work with an old package.
What about Flipper? It is wonderful.
CSS is too complex anyway. Browsers go out of their way to implement it. It is best to build your design system and try to use high level UI components.
Speaks against MobX! Using plain data classes is actually a good solution for native too.
1
u/ArmaniMe Mar 22 '21
I love the 4. I wish there was more time for us as a developers to build things that we need.
Great points tho :)
2
u/Alkyen Mar 22 '21
Thanks for your well written comment. I started learning programming last summer and React Native was my first. Had some trouble with the learning curve first few months but I love it as it allows me to do the stuff I need to do.
Thanks again, I liked your post a lot, can't wait for the next 2 parts!
1
Mar 22 '21
Thank you for your feedback! I’m glad you liked it. I’ll make the second part as soon as I have the time.
1
u/iffyz0r Mar 22 '21
Great post. Interesting read. Looking forward to the next parts.
I haven’t looked that much into Flutter, but I’ve been told that Flutter doesn’t actually wrap the native components of the platform it’s running on – it just mimicks them. Is that correct?
3
Mar 22 '21
Thank you for your positive feedback!
Yes, that is what it does. It is a totally different idea, and it actually works pretty well on Android, because there is quite a bit of device vendors with bizarre Android forks where native GUI primitives work as if they were implemented by jumping on the keyboard with developers’ bare asses. In that case Flutter helps to achieve predictability unimaginable with RN or even Native Android development.
Unfortunately, this is precisely why Flutter is not so good on iOS at the moment, because Apple usually goes out of their way to implement performant UI primitives, and using them allows to achieve expected UI “snappiness” easier, than by using a Skia canvas like Flutter does. Tradeoffs again.
I’m gonna elaborate on that more when I’ll discuss Flutter in detail.
2
u/iffyz0r Mar 22 '21
You are most welcome.
I can see the allure of predictability on Android ...
Do you have any examples of the undocumented customizations and escape hatches you mentioned? Or any searchable terms for those you’ve found most useful?
1
Mar 22 '21
Well, you can start with react-native-v8 and react-native-skia – it’s ongoing work where entire parts of React Native (JS engine and Renderer respectively) were easily swapped out.
I’ll add more examples once I make this text into a post on my blog.
1
u/iffyz0r Mar 22 '21
Will check them out. Just about to switch to Hermes on both iOS and Android. Got a link to your blog?
2
3
u/hugthispanda Mar 22 '21
That’s what you get paid for: solving problems by using flawed tools to make imperfect solutions, that are simply better than no solutions at all.
The most accurate job description I've ever come across thus far.
1
u/Silencer306 Mar 22 '21
What are your thoughts on ionic?
2
Mar 22 '21
Unfortunately I’ve not considered Ionic, but I’ll be glad to revisit it.
Why I didn’t do it was the same reason I’ve decided not to go with Flutter – it is too magic. It synthesizes the entire super complex stack while not offering enough escape hatches.
1
u/Silencer306 Mar 22 '21
Hmm I haven’t used any of the three, but I’ve used react. I am trying to get into app development, and when I looked about react native, a lot of points mentioned that when you try to do really complex stuff, you have to get into the native programming for ios/android, and then your codebase doesn’t stay one.
Thats the reason I’m preferring Ionic rn, because it can be used with react. Again, I haven’t used any of them.
1
u/sp_jamesdaniel Mar 22 '21
According to me Flutter is a reliable business solution that prevents obstacles, brings advanced technology trend to keep your app future-proof, and makes the integration extremely smooth. Moreover, it minimizes the risk to any business by allowing it to quickly build a product prototype and launch it in the market with investors’ approval to test waters.
4
Mar 22 '21
The same can be said about React Native as well. This is more-or-less usual marketing positioning for this kind of software. But I do agree that Flutter is awesome!
0
u/ntvinh25 Mar 22 '21
In my view.
Flutter is better than React-Native.
But JavaScript is better than Dart.
(Union types, handle JSON,... on Dart are very bad.)
13
Mar 22 '21
Flutter is really good in terms of abstracting away native quirks. Can be a curse too.
Flutter is about building a whole new shiny world of effortless development where everything is coherent, while React Native is an evolutionary mess full of quirks.
Flutter is the Esperanto language while React Native is English.
But as we’ve been blessed with an experienced team, we prefer an evolutionary hackable mess to the newly-built self-contained world which can limit us in something complex like advanced text rendering or accessibility, and we have zero way to predict having issues in that area.
4
u/okienow Mar 22 '21
Flutter is the Esperanto language while React Native is English.
Beautifully put.
1
-36
u/almbfsek Mar 21 '21
I can't, in good conscience, recommend RN to anyone. Literally every single commit they push breaks backwards compatibility. An app you wrote this week won't compile next week. Zero exaggeration, 100% truth.
4
Mar 22 '21
It doesn’t update fast enough to wast that much time on it. Plus you might not need to update to any new version as it gets released.
Are you using nightly builds so that you notice every commit?
I find it useful to think about RN as an upstream core for your app, like Chromium is to many custom browsers. Trust me, I’ve had friends who worked on a chromium-based browser, Chromium updates are the worst.
BTW, I don’t know why you are getting downvoted. It’s a valid point.
2
u/almbfsek Mar 22 '21
BTW, I don’t know why you are getting downvoted. It’s a valid point.
I think it was the "Zero exaggeration, 100% truth." part which I accept was a little bit exaggerated :)
I have used RN from 0.59 to 0.62, If I'm not mistaken there has been tens of stable releases in between. almost every single one of them was a problem for me. Especially the ones about webview (which then later was exported to its own community repo)
However my rant is mostly about the principals. I'm coming from a background where keeping backwards compatibility is sacred and I feel like a lot of projects nowadays are completely uninformed about it. I find it to be a disservice to the users of the library.
40
u/autiii43 Mar 21 '21
I’ve been using react native for a prod app with 10k+ MAU and I find that as long as I spend ~5 hours every major version upgrade I have no issues, which is 20 hours a year.
100% worth not writing an app twice.
10
19
u/dejus Mar 22 '21
I’ve been producing RN apps since 2017, many of which are in production right now. I think you exaggerated more than a little.
5
u/LemonKing Mar 22 '21
I just had the easiest upgrade from 0.63 to 0.64. Upgrading Cordova was a literal nightmare for me.
8
Mar 22 '21
Sounds like you’ve had unfortunate experiences. I rarely have version upgrades break things. Literally last week I upgraded our project from 0.63 to 0.64 and didn’t have an issue at all.
-9
Mar 22 '21
[removed] — view removed comment
1
0
Mar 22 '21
[deleted]
-2
Mar 22 '21
[removed] — view removed comment
0
Mar 22 '21
[deleted]
1
Mar 22 '21
[removed] — view removed comment
0
Mar 22 '21
[deleted]
1
u/SeanNoxious Admin Mar 25 '21
/u/vzaffalon has been banned. There's no place to be hateful here. Heated discourse is fine as long as it remains civil.
/u/ianmv sorry he wasn't removed/banned earlier.
0
0
Mar 22 '21
[deleted]
8
Mar 22 '21
This is the mindset I actively tried to avoid while writing this series. Arbitrary “90% better” and “way ahead” is absolutely not how you argue for and against technology. Better at what? Way ahead in what? “Everything”?
You have also obviously not read that part of my post where I speak about concept and competency sharing that is enabled by RN. Ease of writing code is one part of engineering, but not the only one.
If you wanna hack something, going full native native, and have budget for two full-fledged native teams, you should do just that. As an iOS engineer since 2011, I fully approve of that! But it is a really slow process to implement interfaces in UIKit and with Android APIs, so this is not a tradeoff I’d be willing to make for hackability..
0
Mar 22 '21
[deleted]
6
Mar 22 '21 edited Mar 22 '21
Are you ordering me to do it? “Give concrete examples”? From an account created an hour ago? No, thanks. My arguments are laid out in the post. If you wanna make a counterpoint, the burden of finding counterarguments is on you. You are the one throwing arbitrary percentages around.
EDIT:
I’m not arguing that Flutter cannot do what React Native can. Flutter is just more of a blackbox from a native developer standpoint than RN is, because Flutter is built on top of Skia with custom rendering methods. My knowledge of the platform is not transferred when I use it.
You obviously love flutter, and that’s great! If you are not here to troll, wait for the second part where I describe its merits and why exactly we have chosen React Native (it is a non-trivial reason). Method channels, bridges, all this is irrelevant on the scale I’m trying to describe the process, hence the post’s title.
0
49
u/techfocususer Mar 22 '21
The best part about React Native is how easy it is to hire for. We have hired over 40 web and mobile engineers to work on our apps over the last few years. Good luck trying to hire for Dart (Flutter)