r/programming • • May 07 '19

Flutter for Web (technical preview)

https://flutter.dev/web
24 Upvotes

42 comments sorted by

19

u/dwighthouse May 08 '19

We’ve come full circle, I see.

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.

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.

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.

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).

5

u/kuzux May 08 '19

Twice.

11

u/tonefart May 08 '19

Why bother? You'll just be letting google take control of development standards for web (html5/javascript/css)

-7

u/MachoAlpha May 08 '19

It's better this way than the mess it is right now

6

u/tsjr May 08 '19

Yeah, that's the reason why Flash and Java are preferred on the web over the mess we have – things sure are great where you give one company a way to dominate and control the platform ;)

And on this topic in particular, I don't think it's even replacing the mess: it's just adding to it. If HTML, JS and CSS are still there then Flutter Web is just another layer of shit slapped on top of it, with the exact same inherent problems that Angular are others still have. If it at least replaced JS with Dart-compiled-to-WASM I'd see it as an improvement, but as of now it just seems like yet another translation layer with the exact same problems as all the other ones have.

2

u/virtualistic May 08 '19

(disclaimer: I work on Flutter for web)

Flutter Web is built on top of existing HTML/CSS/JavaScript standards. We do not require any proprietary browser features. We do stumble upon browser differences here and there, but that's because browsers do not implement the standards 100% identically, not intentionally. However, you could say that we use these standards in an unorthodox way. You wouldn't be entirely wrong. We actually tried a more typical approach in a prior prototype (details in my blog post), but we failed to express the kinds of UI and interactions that Flutter is used for, so we had to be creative. We actually use a small subset of HTML and CSS because the Flutter framework does a lot of heavy lifting for us (e.g. layout), so we avoid a lot of "the mess" :)

WASM, WebGL/WebGPU are still options for us (or the community) to explore in the future. For now, we are trying to see how far we can go with the HTML/CSS/JS stack. This stack is adding interesting new capabilities too. For example, we're exploring the upcoming CSS Paint API.

1

u/[deleted] May 09 '19

can we use it without dart?

7

u/colelawr May 08 '19

Wow! This is a huge step for Flutter. A lot of people are highly skeptical of Flutter, but I'm still hoping that it succeeds, since it has been one of the most enjoyable cross platform UI development experiences I've seen.

1

u/ClownReddit May 08 '19

With this I believe Flutter has (WIP) targets for mobile, native desktop and web, so basically every platform is covered. Pretty huge for the security of the toolkit.

2

u/smoxy May 08 '19

This is GWT all over again.

1

u/feverzsj May 08 '19 edited May 08 '19

why not qml, you can use js directly.

3

u/renatoathaydes May 08 '19

> you can use js directly.

That's the reason why ;)

1

u/virtualistic May 08 '19

QML is great! But we're implementing Flutter on the Web, so we use Dart. API compatibility with Flutter is an explicit design goal. Having said that, there's a number of exciting new features coming to the language that will make coding UI in Dart much more pleasant (check out Bob's post).

0

u/[deleted] May 08 '19

[deleted]

3

u/Darkglow666 May 08 '19

If the tech achieves popularity, it won't be dropped. Simple as that. So if you like it, use it and promote it. To innovate, you gotta try everything, and that's Google's strategy. Many, many of Google's technologies have achieved critical mass and are now part of our daily lives. Telling people to walk away from anything proposed by Google is a great way to make sure we never move forward at all.

1

u/kankyo May 08 '19

And then there are those that crushed the market and then got canceled.

2

u/Darkglow666 May 08 '19

What's an example of that?

5

u/kankyo May 08 '19

Google reader is the worst at least.

-1

u/Darkglow666 May 08 '19

This is an example of a crushed market?

3

u/[deleted] May 08 '19

[removed] — view removed comment

3

u/congalala May 08 '19

I don't think using the number of stars as a benchmark a good thing.

16

u/fuckin_ziggurats May 08 '19

Google in 3 years:

"What's Flutter? Infotrode is the future of the web."

0

u/th1kan May 08 '19

So. Much. This.

-6

u/myringotomy May 08 '19

Microsoft has shut down more stuff than Google.

19

u/fuckin_ziggurats May 08 '19

Microsoft and Google are incomparable in terms of maintenance and support length. There's a reason Microsoft tech is popular in the long-term enterprise domain and Google tech is popular in startups.

-7

u/myringotomy May 08 '19

Microsoft and Google are incomparable in terms of maintenance and support length

It's true. Microsoft has canned more technologies than google. Google is much better at this at this stuff because they open source everything they no longer want to maintain.

13

u/fuckin_ziggurats May 08 '19

You're off your rocker. Microsoft most of the time only cans technologies that have been passed by time and no longer used. Google literally has two joke websites (gcemetery.co, killedbygoogle.com) referring to their tendency of dropping services they heavily advertised less than 5 years prior.

1

u/myringotomy May 09 '19

You're off your rocker. Microsoft most of the time only cans technologies that have been passed by time and no longer used

Same with google, same with any company.

Google literally has two joke websites (gcemetery.co, killedbygoogle.com) referring to their tendency of dropping services they heavily advertised less than 5 years prior.

LOL. So we are to take this as some sort of evidence? Do you want me to hunt down all the anti microsoft sites out there?

1

u/kankyo May 08 '19

Microsoft is older.

-1

u/myringotomy May 09 '19

So?

0

u/kankyo May 09 '19

So it has had more time to kill products.

1

u/myringotomy May 09 '19

Even if you do average them out per year MS has killed more technologies, libraries, and products.

1

u/myringotomy May 09 '19

Even if you do average them out per year MS has killed more technologies, libraries, and products.