r/FlutterDev • u/Logical_Clothes_1089 • Jan 09 '22
Discussion Can Flutter/Dart replace JavaScript and React? If no, then Why
[removed] — view removed post
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.
2
u/qualverse Jan 09 '22
Flutter web uses (by default) a hybrid of canvas and HTML elements to render, although you can also use canvaskit which renders using only canvas. The biggest issue with it though, imo, is the lack of native scrolling.
3
u/Charly_ZA Jan 10 '22
The default auto mode uses the HTML renderer on mobile and the CanvasKit renderer on desktop.
Edit link: https://docs.flutter.dev/development/tools/web-renderers#command-line-options
3
u/gaspard-m Jan 09 '22
That’s quite true! But I would like to point out that for web app such as Google Analytics, Uber, … and many others you don’t really need seo.
The usual approach being to have a static website written in another language for seo purposes that gives access to the web app.
1
u/Snirdude Jan 09 '22
please correct me if it is also possible to use html elements in Flutter
I know seo_renderer is trying to fix that. It's under development and I haven't tried it myself but you're welcome to try.
1
u/bc_odds Jan 09 '22
please correct me if it is also possible to use html elements in Flutter
I just remembered the Flutter youtube channel doing a short on package:html. I'm really curious what it renders to on web. Something to try out tonight!
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/Only-Split82 Jan 10 '22
I just mean that JSX is not part of vanilla Javascript. So either you use createElement syntax or you need a compilation step to compile JSX to vanilla JS.
1
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
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
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.
1
u/cesarfrick Jan 10 '22
Well, React does run natively on the web. JSX is just sugar syntax, and it's transpiled to plain Javascript in the building process, so I wouldn't say that's a disadvantage of React. The transpiled code won't include any JSX on it
1
u/Only-Split82 Jan 10 '22
I never said that! I just said that "Flutter needs to be compiled" is not a disadvantage when comparing it to React as it needs to be compiled ( or rather transpiled ) as well.
0
Jan 10 '22
[deleted]
0
Jan 10 '22
[deleted]
0
Jan 10 '22
[deleted]
2
u/Only-Split82 Jan 10 '22
Imo JSX is one main feature of React. Without it, it wouldnt be as popular as it is. Just don't use React without JSX!!!
1
u/Slonik923 Jan 09 '22
More and more developers uses Typescript, which also needs transpilation to Javascript. Moreover transpiled code can be and usually is faster than Javascript code written by a developer. Unless developer spend a lot of time optimizing the code.
2
u/gaspard-m Jan 09 '22
And does react typescript allow for easy debug? Because that’s one of the drawback with Flutter web… It does not have a good stack trace when the issue is a bit complex… Of course you usually dev using android emulator or other but when some issue are only web related it becomes quite hard..
2
2
u/Slonik923 Jan 10 '22
In TS you can tell compiler to declare TS to JS maps, which are then used for debugging. Now you now on which line the error occured. Not sure if you can do this in Dart, but Dart have pretty cool tooling on mobile, so I wouldn't be worried about that.
Flutter Web is using canvas, which could be reason why stack traces are that complex. Flutter Web is still in beta, so maybe this will be improved.
On the other hand you still can use AngularDart, which is not as cool as Flutter, but does the job. And maybe we get Flutter Web with html elements support.
20
u/venir_dev Jan 09 '22
No.
The irony is that Dart was born (under the name "Dash") to replace JavaScript and to be interpreted directly by browsers. Google and half the internet had enough of JS but the reality is that it can't be replaced at the moment (nor 10 years ago).
If that trial didn't fail, we wouldn't have the Dart we know today and consequently Flutter.
[Opinion ahead] Flutter/Dart is a cross platform dev tool. Even tho it targets the web, at the moment I don't feel like it can be competitive against a JS framework.
Flutter will dominate the native market, that's for sure. It's very powerful there. On the web? Nahhhh
3
u/eibaan Jan 10 '22
Well, the Sky project (which later become Flutter) started independently from Dart and in an alternative reality without Dart they would have picked a different language. In our reality they looked at multiple languages and picked Dart because of its VM with hot code replacement (the AOT requirement was added much later AFAIK because of you cannot use JIT compiled languages on iOS and they didn't want to use a plain interpreter. In an alternative reality, another language would have the same hot code replacement feature because that's something inherited back from L Peter Deutsch's Smalltalk VM back in 1984, again AFAIK.
Perhaps, in that reality, they would have picked Bob Nystrom's Wren language which he created in 2014 which is early enough. Perhaps they would have looked at how the Apple Newton used a Pascal-Syntax-modified version of Self called NewtonScript and created a C-Syntax modified version of Self. Or looked at Apple's Dylan project which started as an elegant object oriented Scheme and became a Pascal-Syntax-modified abomination that provided a few ideas to Rust and Julia. Or they would have chosen Io which is a simplified Self with a metacircular syntax that is impossible to optimize. And I think, Lars Bak already moved on at the time, Sky started, and began to create a new language which is now called Toit – again a C-style variant of a simple Smalltalk-like OOP language sprinkled with a pinch of Python. There are a lot of possibilities for a Flutter framework based on a different yet similar language.
10
u/cesarfrick Jan 09 '22
I don't know about replacing Javascript, since WASM (once fully matured) may change the way people write web applications, but will not replace React in any form.
The main issue is that Flutter uses canvas for the web, and that presents a lot of issues regarding accessibility, which is what HTML provides.
I do think both can live together and Flutter is a nice alternative to React Native, but I don't see a scenario where one replaces the other in the near future
5
u/aryehof Jan 09 '22
No. Because Flutter on the web just doesn't work well for common scenarios, and that is unlikely to improve significantly.
2
u/skilriki Jan 09 '22
Web based flutter apps have only been possible within the last year.
It's very likely to improve greatly as they are just getting started.
2
u/LessBoysenberry7633 Jan 09 '22
I just see dart flutter as a better solution overall for native apps, but react is more friendly to web devs coming from html.
2
Jan 09 '22
No. Reason: SEO. Maybe in 5 years Google solve this issue
3
u/redHero0010 Jan 10 '22
No need to use flutter of web. The only scenario I can think of is when you have a mobile app like Uber, Zomato and you want your users to be able to use your app from a browser via laptops soo a "webapp" or some thing like Rive 2d animation software but general stuff like blog, e commerce flutter is not good.
2
u/taufeeq-mowzer Jan 09 '22
Flutter web is a major issue...and web is javascript's bread and butter...The only way flutter would be as good as js in the browser is if browsers natively supported it..you could also argue that for what flutter can already do with ease, is it even necessary for it to be perfect on web.
Its great as a landing page for a mobile app/dedicated web app to download off a static website/internal web app/poc. But not suitable as a general website as yet, its just not as snappy in the browser as on mobile. And unfortunately, the choppy scrolling and letter resizing on web screams unprofessionalism
-The file size is too big compared to js, hence lower income areas suffer and loss of visitors due to poor load times -SEO is still in the works -No access to browser api's (would be a huge game changer) -No SSR
Also, many people don't realise that flutter web is its own thing, you don't need to use the exact mobile version for web. You could water down the web version a bit for size....add snap scrolling instead of regular scrolling to web if possible, makes a big difference. Same with desktop imo, you should change a few things to compliment the platform and screen size etc.
Futter is great for creating beautiful user interfaces with ease on mobile and nearly there for desktop.
2
u/poq106 Jan 10 '22
No because React and Flutter are two completely separate tools that achieve different results. Flutter Web would need to be completely rebuilt in order to achieve the same results as React. From my POV it’s a very common misconception that Flutter can compete with classic JS frameworks. Flutter is for web apps, while React is for websites.
2
u/eibaan Jan 10 '22
The assumption that there can be only exactly one solution to every problem is wrong and shows IMHO a certain inexperience. Still, such discussions just for the sake of it are fun.
The answer to the original question is probable "no" and that's okay. Instead of having just one hammer for every nail, just learn how to use a saw, or a chisel or whatever tool fits best.
3
u/akshat_tamrakar Jan 09 '22
Why is it so hard to grasp the fact that 2 technologies doing same thing can coexist ?
Both are great, doing more or less the same thing and both improving.
2
u/AwGe3zeRick Jan 10 '22
And with supersets of JS like Svelte and frameworks like SvelteKit + TS really make things easy does web and even desktop dev, hell, even mobile. But I still love flutter. That doesn’t mean I’m gonna use it when a simple JS app is all I need. Nor would I necessarily choose SK over Rails for a backend API.
Learn lots of languages and techs. Know what they’re good at. Pick the right one for the job. Don’t learn one and shoehorn it into everything.
2
u/akshat_tamrakar Jan 10 '22
Exactly I 💯 agree with you...
I love flutter but if we are talking about web swelte is in my opinion best technology out there.
1
u/AwGe3zeRick Jan 10 '22
Honestly, if I had to go back to contract work (trying to start my own thing right now in hardware) I'd 100%. look for remote Svelte jobs. I spent almost a decade doing Rails work it's just not the same as it was 10 years ago. Or maybe it is too similar to how it was 10 years ago and that's the problem.
I'm sure in 10 years Svelte/SvelteKit won't be the best either (or maybe they will, idk). But right now, I'm loving it lol. It's a lot of fun to write in.
1
1
u/bsutto Jan 10 '22
Not quite on point but if your are building a web app (not brochureware) then you should be using java/vaadin.
I've used a lot of web app frameworks and nothing comes close in terms of productivity.
And I'm saying that as someone that loves dart and use flutter for mobile dev.
1
u/slavap_ Jan 10 '22
In some scenarios - yes, it could be an alternative to React. E.g. you need a mobile app AND web app. Just using Flutter only for web development is not so good idea. And by the way, let's say you have web app implemented with React - what options do you have to make it mobile app? Migrating to React Native? But React and React Native are quite different frameworks.
1
u/ZeRo2160 Jan 12 '22
You could build your App in React Native and utilize https://github.com/necolas/react-native-web or https://github.com/vincentriemer/react-native-dom
So your app renders in the browser and as mobile app.
But its in roughly the same beta stage as flutter web thought. Had some tests but nothing serious for now. But utilizes the dom fully for seo and such.
1
u/slavap_ Jan 13 '22
SEO is not that important for web apps, and is actually possible with Flutter (with some painful restrictions of course). Developing with Flutter is IMO easier than React Native.
1
u/redHero0010 Jan 10 '22
If flutter provides a way to diliver static websites. Then I think it will be the goto choice for many. Specially web developers who wanna explore mobile.
1
u/kbruen Jan 09 '22
Since Flutter for the web doesn't use the DOM, but the canvas, it will never be one of the top web frameworks.
-1
1
u/vonKlinkenhofen Jan 09 '22
Yes. At some point Google will come with a compiled runtime for in the browser. Somewhat like the good old jar file. The Chromium will be ported to use it natively, other Browsers will follow.
SEO will also become possible, look at the SEO package on pub.dev to see the first attempts.
1
u/gluecat Jan 10 '22
Why should it? Typescript + React is great... if anything I would rather use Kotlin over Dart
0
u/Samurai___ Jan 10 '22
No. JavaScript is way ahead and evolving faster than Flutter. It won't catch up.
6
u/Impressive-Resist645 Jan 09 '22
Mangos.ai - Mobile app and Website, built on Flutter :). Never going back.