r/programming • • May 07 '19

Flutter for Web (technical preview)

https://flutter.dev/web
24 Upvotes

42 comments sorted by

View all comments

19

u/dwighthouse May 08 '19

We’ve come full circle, I see.

5

u/kuzux May 08 '19

Twice.

3

u/MachoAlpha May 08 '19

How many of these "native" frameworks do we have already? I was never interest in web development but lately I've tried to learn something new and chose the web (the biggest platform ever). Seriously how come we are still using JavaScript ? And why are we compiling everything to JavaScript ? And why web assembly still needs JavaScript ?

These UI toolkits, frameworks (angular react Vue ... And whatever) will always output 1MB of JavaScript for a simple hello world.

13

u/Dave3of5 May 08 '19

Seriously how come we are still using JavaScript

Because that's the only language that browsers actually support at the moment and it's unlikely to change in the near future.

And why are we compiling everything to JavaScript

You don't need to compile anything and in fact you are transpiling from language X to JavaScript. The main reason is that a lot of developers now have to write code for the browser and they don't like the design decisions made in the JS language and so want to write in a language more like [insert their favourite language here] because it's "better" than JavaScript.

And why web assembly still needs JavaScript ?

Pardon ? Web Assembly doesn't need JavaScript for more details see here.

These UI toolkits, frameworks (angular react Vue ... And whatever) will always output 1MB of JavaScript for a simple hello world.

That's false.

For example the Vue.js hello World clocks in at 88KB unzipped, zipped up the total JS is 32.2KB. In terms of what you are looking at it's probably the Dev build which is large because it allows you to properly debug your application when you are developing. This is the same in non-web based environments like C / C++ in terms of an optimised build vs a non optimised build. If you don't believe me have a look here that's the total vue.js lib that you can include on your page without an "compiling".

6

u/i9srpeg May 08 '19

Pardon ? Web Assembly doesn't need JavaScript

You still need it to:

  • Bootstrap the webassembly code.

  • Interact with the DOM and any other web API.

Those can all be abstracted away, but you still need some JS code even with webassembly.

4

u/AngularBeginner May 08 '19

Seriously how come we are still using JavaScript ? And why are we compiling everything to JavaScript ?

Because we don't have any choice. Web Assembly has come a long way, but it's not ready for production use.

2

u/myringotomy May 08 '19

Good news. Flutter doesn't use JavaScript.

2

u/Darkglow666 May 08 '19

To be fair, even with Flutter, the Dart code transpiles to JS for the web. But it is great that you don't have to write the JS yourself.

0

u/Hell4Ge May 08 '19

The same way we put bigger images on web - our network connection speed evolves every 3-5 years.

The same applies for our hardware, and honestly who the hell cares that React / Vue or other framework takes 1MB just like that when the whole page can take 2MB.

Resources are cheap today, the way you write software (thus time) is more important than your RAM and for example you can take a jQuery library - if you skip it, then you will probably produce a bug in one browser (let's say Internet Explorer because we all hate it). What will you tell to your customer? That this bug occured because you wanted to save a 500KB of bandwidth that would be cached in browser memory anyway? Because a 25ms of page loading time was a thing for you? Nah, it's not what customer really cares about.

And if you want just to switch from JS then it's too late because its the same deal that walks around mismatch between 1000 and 1024, some decisions taken in past comes with consequences and will not change. Period.

-1

u/Darkglow666 May 08 '19

Even if web frameworks really did produce 1MB of code for "Hello, World" (they don't), it would still be short-sighted to complain about it. The framework code only has to be included once, no matter how big your app gets. So you may end up with a big toy app, but with a real app, that framework code saves you from writing all kinds of code, so as the app grows, things even right out.

Furthermore, Dart has a fantastic compiler that does aggressive tree-shaking, making sure only code that gets used is included in a build.

1

u/virtualistic May 08 '19

(disclaimer: I work on Flutter for web)

I'm not sure what your application's size constraints are, but FWIW, Flutter for web "hello world" app start with ~150KB gzipped when compiled in release mode. We haven't done any code size optimizations yet (focused on rendering correctness, feature completeness, and performance). We get this size purely from dart2js's dead code elimination capabilities. Obviously, the more widgets you use, and the more application logic you write, the bigger the JS bundle (for example, the Gallery sample app, which uses nearly every widget in Flutter's toolkit, is ~500KB).