Hacker News new | ask | show | jobs
by MrJohz 674 days ago
> I know Flutter/Dart doesn't get much love here on HN but in my opinion I think it's much easier to reason about than a system like React which I think is the wrong level of abstraction compared to Flutter's render the entire widget tree approach.

Could you expand on this a bit? My impression was that Flutter and React had relatively similar approaches to components, but I haven't had much experience with Flutter yet, so I'm interested to hear your experiences!

4 comments

I’m too lazy right now to get into all of the specifics but just wanted to drop a quick note to say that I’ve been doing web development since 1997 and the difference between React and Flutter is like day and night.

It’s genuinely hard for me to overstate the general quality of life improvements both from the developer experience and the overall quality of the apps I can produce in any given time frame.

A big part of the reason for that is Dart is itself hands down the nicest language I’ve ever worked with. The team behind it got real serious when it comes to tooling and language design and everytime I have to go back to TypeScript I feel like I’m trying to run with a 50kg backpack on.

At a basic level Flutter renders the entire widget tree and caches components that don't need to re-render rather than applying a diff of changes to the DOM.

But it's really the Flutter/Dart API and widgets that make it much easier to work with, if I need to load some data asynchronously I use a `FutureBuilder`, if I need a stream of events I can use `StreamBuilder` etc. Compared to Reacts state, hooks, memo, effects etc. you end up with code that is far easier to reason about what is rendering when and why.

Oh and the real killer feature is Flutters hot reload experience, it's easily the best DX I've seen for GUI work.

As another comment mentioned it really is like night and day. I recommend giving it a try.

I don't quite understand the point about rendering, unless you mean it in the Angular sense (i.e. on every state update, the whole app gets rendered, and elements are updated to the new state during that render).

But I can imagine that the API can be easier. I think React handles state fairly well, but as soon as that state needs to interact with things outside the React world (http requests, continuously updating data, etc) then the current abstractions don't quite feel right.

>i.e. on every state update, the whole app gets rendered

Yes, that's basically correct:

>Calling setState notifies the framework that the internal state of this object has changed in a way that might impact the user interface in this subtree, which causes the framework to schedule a build for this State object.[0]

The `build` method rebuilds the entire widget tree. So "the whole app" does not necessarily get re-rendered, only whatever is in the same widget as the changed state or below it, although potentially that can be the whole screen. Flutter also uses an algorithm to detect unchanged widgets and reuse them,[1] but conceptually the whole thing is re-rendered on state change.

[0] https://api.flutter.dev/flutter/widgets/State/setState.html

[1] https://docs.flutter.dev/resources/inside-flutter#linear-rec...

React doesn't work in the same way? I don't know much about it, but I assumed it does.
I'm not sure. Hopefully someone here can let us know. I didn't mean to imply that react doesn't work that way.
It does work that way. However, Flutter and now React (via their new compiler) are becoming smarter at rerendering, where they will only rerender what has truly changed, not just rerender the entire tree below the changed component.
react and flutter are pretty much the same thing, i do both for a living i am not sure what this person is going on about
React = one small piece of a very large required ecosystem (HTML + CSS + Javascript + NPM + React + Vite + ???)

Flutter = a UI framework for mobile/desktop/web (Flutter + Dart)

On top of the purpose built nature, nearly everything is a Widget, even layout/styling making it pretty easy to grok very quickly.

I personally prefer using many smaller components over using a large opinionated framework. But I'm not a big fan of React, so this could be better and worth a try.
It's less a "large opinionated framework" and more "fewer components overall. There is no HTML/CSS for example, it goes direct from Dart (equivalent to JS) to the Widget rendering system."

Dart has its own build tools and package system that work well. You can still pull in dart libraries as you need them. Dart is also a much better language than JS. I can't tell you how many days I've lost to react/JS build tooling issues. A single problem can easily eat an entire day. With flutter/dart I haven't had a single issue like that.

flutter does a so so job on desktop and it's web version is wasm based.

the job market for dart flutter is a drop while react is the lake.

react with electron, react native, react itself together are still the only ones production ready cross platform GUI with widest adoption

comments about job markets aside…

The first and the third paragraphs really haven’t been true for some time now.

Flutter is absolutely production ready as a cross platform GUI.

For ios and android maybe but I doubt for web. Also 12k+ open issues, team layoffs and all founders that left don't brink confidence to flutter. I think also roadmap and progress in last year doesn't look stellar.

On the other hand I think flutter lost a lot of benefits comparing to 5 years ago - now we have stable better swift and swiftui and better kotlin with jetpack compose - those support also apple watch, macos, tvos, visions os, Google wear, Google TV and with current jetbrains compose desktops like windows is already stable.

React native and web ecosystem also improved a lot in the last year.

I keep seeing this coming up and I have no idea where it’s coming from like it’s some self reinforcing feedback loop based on just utter bullshit.

If I am remembering correctly the headcount on the Futter team literally changed by a single person.

Here are some actual real life numbers you can use if you want to gauge the health of the two projects:

1. https://github.com/facebook/react-native/pulse

2. https://github.com/flutter/flutter/pulse

Specifically Flutter’s 108 merged pull requests to React Native’s 1 and Flutter’s 330 closed issues to React Native’s 18.

Also note that this doesn’t even include their rendering engine which had another 90+ closed pull requests https://github.com/flutter/engine/pulse

The truth of the matter is that Flutter is actually is far better shape both from a technical and open source perspective.

I did checked pulse for those on github on regular bases. Change to monthly and notice out of 450commits more than 170 commits are by flutter-engine-autoroll bot just auto updating some packages, then next second user did ~30commits, then you have few another flutter bots with some commits. Then go compare with react native.
They do have similar approaches, I'm not sure what the above commenter is saying as both work basically the same (with React class components at least). Flutter doesn't have hooks but they're addressing that via macros next year, and anyway today there are packages like flutter_hooks and ReArch that enable hook-like functionality in Flutter today.