Why does flutter use dart?

Viewed 6082

I understand that there could be many reasons but when the developer community has already adopted ES6 and is working hard to make it better then why dart and not JS?

Is there anything special which makes dart such a good fit for Flutter?

3 Answers

I did a little research after being asked the question by a couple of colleagues and thought it would help by summarising what I have read and thought about (it's a very important question for my colleagues)

Language requirements for Flutter

  • AOT and JIT compilation for fast reload and fast released code
  • A good garbage collector to clean up after creating and destroying many objects
  • Single threaded to avoid locks and therefore jank
  • An arm compiler to avoid having another engine running the code on the device (aka React Native)

Dart meets all these requirements. JS (I think) meets all the above pretty closely too, apart from the AOT and JIT compiler part.

Why didn't Flutter choose JS and build a JIT and AOT compiler? (initially they did choose JS but they switched) I could guess at the following...

  • Dart was built with to-binary compilation in mind from the beginning
  • Dart already had a to-binary JIT compiler, it added the AOT compiler later
  • Dart is more structured and simpler (it is type safe and has no eval)
  • JS could implement new language features that might jeopardise flutter dev
  • Dart can be optimized for Flutter without needing to worry about other uses of JS
  • Historically long wait times for new JS functionality (last 3 years has been better)
  • The Dart and Flutter teams can work together closely

Saying all of that I can imagine that a JS solution could happen but it might be costly and a more complicated solution. Dart is pretty good and Dart2 has really improved things with inherent type safety.

Dart has a declarative and programmable layout that is easy to read and visualize. Hence, Flutter doesn't require a separate declarative layout language like XML. It is easy for Flutter to provide advanced tooling since all the layout in one language and in a central place

Related