They didn't use JavaScript / TypeScript because of AOT requirements on iOS (Flutter actually was originally prototyped with JS as the language). Dart was mostly chosen for its runtime, which allows both Hot reload at dev time, as well as full AOT compilation to get native speed on iOS. React Native runs a JS interpreter to get around this on iOS and as a result is an order of magnitude+ slower
The speed is fixable. Performant AOT is very possible with Typescript. But if Facebook is not doing it, then the performance is good enough for them. Plus one can always code the problematic part in the native language.
Because TypeScript's type system is (by design and for good reason) unsound, an AOT compiler can't rely on static types to generate smaller more efficient code. It's always very hard to compile a dynamically typed language to fast code than it is a statically typed language.
Dart (as of 2.0) has a sound static type system. It's just an easier language compile well.
Even before that, Dart was easier to compile efficiently than JavaScript because classes are purely declarative and all objects have a fixed field layout.
Huh, which AOT compilers for JavaScript exist which achieve high performance? I thought JS as a language 100% depended on the runtime information available to a JIT for decent performance?
fpoling is referring to a _theoretical_ TypeScript compiler that doesn't actually exist in real life but could be written, that the Flutter team would apparently summon from the aether whole-cloth then proceed to maintain feature-for-feature parity with the official TypeScript compiler
Well, you wouldn't have to maintain feature parity with Microsoft's TS compiler. If you had some magical ES5 AOT compiler, you could just compile your TS to ES5 using the official TS compiler and then AOT-compile your ES5. No evolving spec to keep up with (at least as long as the upstream TS compiler maintains ES5 support). I'm really just curious about how one would AOT-compile a language as dynamic as JavaScript (be it TypeScript, ES3, ES5, or anything else) and achieve JIT-like performance.