r/FlutterDev • • Jan 09 '22

Discussion Can Flutter/Dart replace JavaScript and React? If no, then Why

[removed] — view removed post

43 Upvotes

58 comments sorted by

View all comments

44

u/gaspard-m Jan 09 '22 edited Jan 09 '22

Flutter is still not that mature when it comes to the web. So I do not think that it would be able to replace React in the near future. Furthermore, JavaScript still has the advantage of running natively in a browser while Dart needs « compilation » to JavaScript…

But what is sure is that Flutter is becoming better and better each day that passes and I don’t think the same can be said about React… And if fuschia continues growing, Flutter will start to be way bigger than React. But not replacing it since React also comes with it shares of advantages. Like written in JavaScript which is a very popular language as opposed to dart.

I love Flutter and I am not that experienced with React so my opinion is clearly not impartial ! :)

4

u/Only-Split82 Jan 09 '22

As nobody is using React.createElement but JSX, React is not running natively as well ( the real "native" React interface is too uncomfortable to use it in real apps ). So this is not an advantage over Flutter.

I think the biggest disadvantage of Flutter for Web is that the app runs in canvas instead of using html elements ( please correct me if it is also possible to use html elements in Flutter ). So if it comes to SEO and Browser optimizations it will be worse than the other frameworks. Another disadvantage is debugging as it is imo much more difficult in Flutter Web than in React for example. Maybe it is just that i am used to a certain debugging style that i cant apply to the new technology.

For hybrid mobile apps i think Flutter is much better than the other players. And you can be very productive with it. Super nice technology for this niche.

1

u/ImpossibleReality903 Jan 09 '22

As nobody is using React.createElement but JSX, React is not running natively as well

What does this mean?

That if I used `React.createElement("Text"` ... or whatever, the views/etc wouldn't be in the JS thread but native? But with JSX it has to be "parsed" then sent to native?

1

u/[deleted] Jan 09 '22

JSX is compiled, so the argument that Dart doesn't work because it's compiled is the same as JSX, no one uses React without some form of compiler anyway.

0

u/miyoyo Jan 10 '22

That's kind of disingenuous, React's JSX is not going to majorly affect the final code, its effectively just converted to create Elements, whereas Dart brings entirely new semantics, different runtime type checks, and more, that's like saying an airplane and a shopping cart are the same because they both have wheels.

1

u/[deleted] Jan 10 '22 edited Jan 10 '22

That is not a great straw man argument. It misses the entire point that it's not comparing whether or not a base compiler is needed. It is fact that JSX does, regardless of how much it actually does. No one cares about the additional checks that dart2js will add when compiling dart, as it in no way changes the actual functionality of javascript as a language, so there is no point in comparing how much each actually changes, except for the difference in it needing to exist at all, or not.

To prove the point further, people don't even just use a jsx "compiler", they use babel, with like 50 plugins installed, that does hundreds of polyfills, manipulations, checks, and TypeScript or whatever else you want to support.

-3

u/miyoyo Jan 10 '22

The amplitude of change, and the resulting performance hits, are definitely things to consider, "compiled" JS is pretty much still the same, and acts similar to the original source, whereas Dart compiled to JS effectively runs into a VM written in JS, you can't just pretend that these are equivalent.

3

u/[deleted] Jan 10 '22

Except if you had done just a little research into what you’re saying instead of pulling stuff out your arse, you’d know that there isn’t really a Dart VM in browsers, nor does Dart itself run directly in a browser. Dart code gets compiled into optimized JavaScript, which in turn means that you’re still running JavaScript.