logoalt Hacker News

amazingamazingtoday at 2:35 AM3 repliesview on HN

I always find it strange that flutter isn’t built with golang or typescript. Why use a new language? When flutter came out both languages existed so curious about that.

The main reason i can think of is generics not existing initially


Replies

billynomatestoday at 8:19 AM

Dart shipped in 2011, four years before Flutter started.

On the technical side, Flutter needed AOT compilation to native ARM for release builds and a JIT for development (that's what makes stateful hot reload possible). Dart does both from one codebase. TypeScript means shipping a JS VM, which is precisely the overhead Flutter was designed to avoid. (In contrast to RN). Dart's other big win is GC tuned for allocating and throwing away tons of short-lived objects which is what happens when you hot reload over and over.

Go has no JIT, so no hot reload, and no generics until 2022, Flutter has a big widget library so that would not have been possible.

And of course the Dart team was inside Google, and had just lost its original mission when Chrome declined to ship the Dart VM, and was willing to change the language to suit Flutter.

esprehntoday at 12:16 PM

There were a lot of factors that led to the dart decision. It's also important to note that Flutter is very old, we were designing it in 2014.

- we wanted hot reload

- it was supposed to feel familiar to web developers and reasonable to native developers

- iOS needed AOT compilation for speed since we couldn't use a JIT

- TypeScript had literally just reached 1.0

- Swift looked promising, but the Oracle lawsuit made the idea of using it tenuous

- Kotlin was not even 1.0 yet, that wouldn't happen for 2 more years

- Go made huge binaries. The language was also lacking features like generics and Go was unwilling to add them (remember this is 2014).

- v8 was not interested in AOT, but Dart was willing to dramatically invest in flutter

There were probably other reasons too I'm forgetting.

Dart was a really pragmatic choice to ship quickly at that time. I have mixed feels about how the decision has aged over time, and wish we had things like Hermes and WASM back then, and a willingness to build a TypeScript compiler like other native frameworks (ex. Valdi)... But for the time I think the choice was reasonable.

bbkanetoday at 3:22 AM

I'm not sure why you're being downvoted, it's a super reasonable question.

Iirc the reason is that the Dart team was willing to heavily modify the language and runtime to accommodate the needs of Flutter and the V8 team wasn't.

I think this is the video that talks about this: https://m.youtube.com/watch?v=xqGAC5QCYuQ