Live data from Hacker News

Flutter 2

developers.googleblog.com

741–750 of 780 posts

Re: Flutter 2

#741
post #639

Earlier quoted context omitted.

People build less unions because these languages fail them. Just add sum types or something similar, it's a disgrace to not have them in 2021. Static typing goes wonderfully well with them, allowing for exhaustiveness checks and all that. The "people use fewer unions in Java" argument is like saying people used fewer lambdas in Java 1.6. Build it, and they will use it.

> Just add sum types or something similar I think you're confusing union types and sum types, which are very distinct features. SML, Haskell, and Rust don't have union types. OOP languages can model sum types already. It's mostly a question of how much the surface syntax encourages that style.

I'm not confusing them :-)

I think _closed_ union types (the syntax `a | b | c`) are almost as good as sum types, since they bring exhaustiveness checking to the mix. They also act as documentation. Crystal is a good example of a language leveraging this feature.

The OO model of just subclassing a common class is quite poor by itself. Scala and Kotlin have a 'sealed' modifier to at least recover the exhaustiveness check. Both also have ways of safely doing the case switch on the object's class and simultaneously downcasting (Java too with its recent `match` construct, afaik). Does Dart have anything like that?

Re: Flutter 2

#742
post #644

I think Dart's new way of declaring variables as null safe by default is very interesting. If you want a variable to be able to hold a null, you have to explicitly say so. It seems a less heavy-handed version of how Golang handles nil, and much better than the standard way of declaring variables in most any other language. Maybe this is some common language thing I haven't seen before, but it seems an "obvious in ret…

It's already in at least kotlin and typescript, not to mention the languages that simply don't have null.

Interesting. Typescript seems to need a --strictNullChecks flag, but yeah Kotlin does have this already. (Sadly, Kotlin is filled with so many bad ideas, it's hard to notice a good one.)

Re: Flutter 2

#743

Earlier quoted context omitted.

I realise it works, I just don’t think it’s really useful for what was asked for, a way to write common cross-platform business logic for a platform-specific UI. Unless there are some great new tools I’m not aware of, C on WebAssembly seems about the same as C on Android. You can compile stuff just fine, and run it, but actually connecting it up to any substantial UI written in JS/Java is going to be incredibly tedio…

The interaction between C and Javascript offered by Emscripten is a lot better than JNI on Android. I wish the Android NDK would steal a few ideas from Emscripten, but all the Android teams at Google don't seem to be able to look outside the nice comfy bubble they've created for themselves. With Emscripten, you can embed Javascript source code directly into the C code and then call the embedded JS function from the C…

Not bad! Sounds like the tooling has improved since I last looked.

How about debugging? Is it possible to step through a mix of C and JS stack frames?

Re: Flutter 2

#744
post #324

Earlier quoted context omitted.

Because Google is focused on language and tooling development, but forgot to create a killer app example with publicly available source code. Show us a minor Google property re-done in Flutter with code examples and people would flock to it. But. They. Won't.

> forgot to create a killer app example with publicly available source code. Show us a minor Google property re-done in Flutter with code examples and people would flock to it. Can you think of a "minor Google property" that is open source?

Its a hard resource-intensive problem to dogfood your own OSS at a company as large and diverse as Google. But hard problems haven't stopped Google in the past.

What you're trying to create is the same spark in your users as PHP and React did to the web. The "oh wow I could do...." that while technically possible before the product existed, is completely re-framed by relatively minor improvements to the DX. You want to inspire an entire generation that may have passed on mobile and cross platform app development due to the verbosity and pitfalls of the iOS and Android ecosystems.

I think a killer app example is the ticket to do this. It may not be the only way, you could blow a huge marketing budget, you could convince another large tech company to do it, but doing it yourself is probably the quickest (or only way) to get it done.

Re: Flutter 2

#745

I created apps in cordova, react native and now flutter and I have to say flutter beats both by a lot. It's just been such a nice experience. I'm absolutely in love. My most successful app in flutter is https://stockevents.app if you want to try.

[Googler who works with the Flutter team]

I'm a big fan of your app! It has become the main way I consume and watch stock data.

There are some minor issues however. The "Watchlist" header has an issue where it renders under the back button both on Android and iOS. Also the Watchlist view can have some jank while scrolling unlike other sections of the app. Finally it'd be great if the app responded to the system level dark mode setting instead of having it's own toggle.

Overall though, great stuff so keep up the good work :D

Re: Flutter 2

#746
post #685

I'm currently 5 months into developing a mobile app for a startup with flutter and my experience so far is very underwhelming. Flutter as a framework is not the worst but far from best, it's very OO while trying to use reacts vdom model which just wants to be functional. The biggest limitation of the platform is Dart - it's a horrible language that should have died once TS and ES6 became mature enough. And I've used…

Sorry but you don't know what you are talking about, try to use Dart as Dart, not as what you think Dart is... You have a mind block.

As what exactly ? Look at libraries like built_value and built_collection. That level of boilerplate and code generation is only seen in Java land, even there there's better stuff because the metaprogramming is better with stronger reflection capabilities.

Dart is a worst of all worlds - languagee designed by VM engineers in a Java shop

Re: Flutter 2

#747
post #741

Earlier quoted context omitted.

> Just add sum types or something similar I think you're confusing union types and sum types, which are very distinct features. SML, Haskell, and Rust don't have union types. OOP languages can model sum types already. It's mostly a question of how much the surface syntax encourages that style.

I'm not confusing them :-) I think _closed_ union types (the syntax `a | b | c`) are almost as good as sum types, since they bring exhaustiveness checking to the mix. They also act as documentation. Crystal is a good example of a language leveraging this feature. The OO model of just subclassing a common class is quite poor by itself. Scala and Kotlin have a 'sealed' modifier to at least recover the exhaustiveness ch…

> The OO model of just subclassing a common class is quite poor by itself. Scala and Kotlin have a 'sealed' modifier to at least recover the exhaustiveness check.

The natural OOP way to model an operation that must exhaustively be supported by a set of types is by making it an abstract method on a shared superclass. For problems where it's natural to keep the operations textually near each type, that works great.

Otherwise, yes, you'd ideally have some notion of a sealed family of types so that you can do case analysis with exhaustiveness checking. That lets you ensure all operations are covered when you program either in OOP or FP style.

Something I find odd is that FP folks often criticize OOP languages for not supporting exhaustiveness checking, but I rarely hear them admit that most FP languages don't have support for the other style that OOP does well, which is abstract methods.

Re: Flutter 2

#748
post #689

Earlier quoted context omitted.

Here are some benchmarks: https://benchmarksgame-team.pages.debian.net/benchmarksgame/... The Dart implementation seems much slower than the NodeJs implementation and it doesn’t bring anything new to the table? It added null safety today. Anyone that knows if it has any feature beyond for example what Ocaml has?

To give context, the implementations for the same problem are completely different, e.g. javascript versions uses worker thrreads on 4 cores for most of the examples. To compare actual performance first similar approaches should be used.

Similar like 5.37 seconds and 5.53 seconds ?

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

:and:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re: Flutter 2

#749
post #741

Earlier quoted context omitted.

I'm not confusing them :-) I think _closed_ union types (the syntax `a | b | c`) are almost as good as sum types, since they bring exhaustiveness checking to the mix. They also act as documentation. Crystal is a good example of a language leveraging this feature. The OO model of just subclassing a common class is quite poor by itself. Scala and Kotlin have a 'sealed' modifier to at least recover the exhaustiveness ch…

> The OO model of just subclassing a common class is quite poor by itself. Scala and Kotlin have a 'sealed' modifier to at least recover the exhaustiveness check. The natural OOP way to model an operation that must exhaustively be supported by a set of types is by making it an abstract method on a shared superclass. For problems where it's natural to keep the operations textually near each type, that works great. Oth…

As far as typed FP languages go:

- Scala has the whole OOP stuff - F# as well - SML: you probably need to do it by hand, with a record of closures, or something like that. It's ugly but it works. - OCaml has objects (it's in the name), first-class modules, or records-of-functions; all of which can replace abstract methods successfully. - Haskell can rely on typeclasses to do the virtual dispatch, I think. Not an expert on that.

So I'd say it might not be as ergonomic, but the capability is still 100% there.

Re: Flutter 2

#750

Earlier quoted context omitted.

It's not just about building special experiences. I want to be able to browse normal websites in VR -- VR and uncommon user agents introduce a new set of user inputs that Flutter will need to handle if it doesn't want its websites to just break if someone loads them up in a headset. Currently as a web dev, if I want my website to be usable by a voice assistant, I don't have to do anything. If I want my website to be…

It's true of course that as a cross-platform toolkit independently built on top of another platform, Flutter will have to consider new controls, gestures, and changes in many platforms. You could say the exact same things comparing Android/iOS/Windows to the cross-platform web: it's very hard to do and there are plenty of compromises, but it's still very valuable. There's been far more handwringing over the web's def…

> You could say the exact same things comparing Android/iOS/Windows to the cross-platform web: it's very hard to do and there are plenty of compromises, but it's still very valuable.

The difference is that the web efforts aren't being headed by one team in one company, they're a giant effort with a huge amount of funding, shared resources, and attention from multiple companies and communities.

Flutter doesn't have that benefit. It's not that nobody could build a cross-platform replacement for the web, it's that the web was hard to build, and it's very unlikely the Flutter devs are going to be able to repeat that effort on their own.

> Yet Electron and web apps continue to dominate

Largely because Electron piggybacks on existing work by embedding the entire Chromium engine, they're not building an entirely new render engine from scratch. And Electron still struggles trying to keep pace with native systems, even though it's largely just hooking into them instead of rewriting them.

> Accessibility features like voice assistant support don't necessarily come free either. Rich web applications usually don't produce simple/accessible DOM structures even if you're developing with web-native tooling.

The web gives you a lot for free though. It's sort of like comparing OpenGL and Qt. Sure, both require me to be thoughtful as a developer, but one requires me to be a lot more thoughtful.

----

The bigger problem here isn't whether application devs need to think about accessibility, it's for the Flutter dev team. It's that the web doesn't expose the kind of accessibility APIs that a pure Canvas UI needs to recreate all of the accessibility and screenreader support that's built into browsers. Qt on the web has run into the same problem. What you end up doing (because it's the only interface you have to work with) is either trying to on-the-fly maintain part of the DOM and working really hard to figure out which parts need to be maintained, or just flat-out adding a second, hidden DOM tree that screenreaders can interact with. The only way that Flutter can tell a screenreader that a piece of text exists is by making a node and putting it into the DOM.

This is, from what I can see, what Flutter does in its forms. It has a DOM representation of all of the input elements (but interestingly enough not the links or other text, so they're not screenreader accessible at all), and then completely separately, it re-implements the entire browser rendering stack. And the performance is... well, you can see the performance.

Flutter's strategy for handling events to those elements appears to be (for lack of a better term) inverted. It's "Render first, worry about the DOM second", which is not the way that I would try to build something like this. I don't want to read too much into it, maybe I'm misunderstanding their architecture, but the tab errors that people are seeing look to me like they exist because Flutter is trying to poorly reimplement how browsers tab, rather than using an underlying DOM model that could for free signal to them what the currently selected element is. Similarly a lot of the input selection and mouse lag is because it looks like they're doing collision detection in WASM and performing a DOM mutation every time they need to change the mouse cursor into a different shape. Which, yeah, of course that's not performant.

Ideally, a framework like this would target the DOM directly in the first place and use that to drive input, accessibility, and styling wherever possible, adding canvases back in only when necessary to override specific parts of rendering. That's the path that frameworks like Blazer and OpenSilver are trying to go down, which is just a lot more realistic of a goal for an individual team to accomplish.

I'm trying to thread a fine line here, because I haven't read Flutter's source code, so I don't know for certain how they're doing everything or why. I don't want to confidently say they're doing something wrong if I don't have the full picture. But I can see the outcome, which is currently pretty bad, and I can see little bits and pieces of the architecture they're using to get that outcome, which all seem very counterintuitive, overly-complicated, and buggy. I'm happy to be proven wrong in the future, but in the present there's a nearly half-second delay to change my mouse cursor when I hover over an input and none of the links in-app are screenreader accessible, so that's not exactly inspiring optimism. Sure, Flutter could theoretically overcome everything and keep pace with the web, but is that what's currently happening? They're announcing v2 and the web version is basically unusable.

Post reply on HN