More and more often, I would get emails about why people think Google choose Dart for Flutter. It seems, most of those articles written by people who just joined the Flutter crowd and did not follow Dart’s evolution from the very beginning. So, as a person who followed it from pretty much day one, I decided to write a few lines about why, do I think, Google preferred to use Dart to any other alternatives.
1. Dart was designed for the UI development and that is why it was chosen for Flutter.
- All those features like “new” operator removal or conditions in arrays, were added after Flutter was introduced. Those were added to address pure readability of the Flutter widgets code. Let’s be honest, XML and derivatives like HTML or JSX are the only “languages” which was designed for the UI.
WRONG: In a very first place, Dart did not have AOT and it was added specifically for the Flutter and NOT because the AOT is faster. In fact for quite some time AOT compiled Dart code was quite a bit slower than its JIT version. The reason why is because Google already had highly optimized VM for browsers. Reasons, why Google choose Dart and added AOT are:
- AOT compiled applications much faster to launch (To launch! Not to run!) because the compiled code can be executed right away without the need to compile and optimize it.
3. AOT is faster than JIT.
WRONG: AOT compiled code does not assume superior execution performance. Superior launch speed? Yes — you do not have to compile it first. Less memory needed? Likely, Yes — you do not have to keep VM in memory. But not execution speed. In fact, JIT, theoretically, can be even faster, because compilation would happen on the target hardware and VM can make some optimizations specifically for the environment where the user is launching it.
For example, both Java and C# code will perform better than AOT-compiled Dart code most of the time.
4. Google should’ve to use Kotlin, Go, or any other language for the Flutter.
When Google started to work on Flutter, there was no real alternative to it at that time. Kotlin was not a thing yet. Java and other platforms will not be able to provide a “Hot reloading” feature. But more importantly, Google does not own those languages, thus, would not be able to evolve any of those the way they want. So, there is no point comparing Dart with any other language in the context of Flutter. You are not complaining to Apple that they use Swift but not Java. They just build tools that make the most sense for their platforms.
There are other reasons why would Google decided to use Dart. For example, Google invested quite a bit of resources building Dart and tooling for it. According to them, even before Flutter, Dart was in the top five languages list used at Google which already could be a justifiable reason, but those I listed, I think are the most important from the technology perspective.
It would be so great to get the feedback from original Flutter creator, because those one above are just my speculations and I will be happy to confirm ore dispel them.
As always, great thanks for reading!!!