Flutter 1.0 released
With the recent release of Flutter 1.0, Google released another platform to develop mobile apps. The focus of Flutter is to develop cross-platform applications. This allows developers to develop their application only once and publish it on multiple platforms, such as iOS, Android, Web, and even native desktop applications.
The Flutter platform is powered by Google’s own programming language, Dart. Google, not a stranger to creating their own languages (Go is another example), choose not to use a more widely used language out there, such as TypeScript, but instead use their own language.
What is Dart?
While the development team behind Flutter and Dart claim the Adsense interface has been written in Dart, which should indicate a sense of maturity, it’s helpful to note that this also the only (medium-sized, 160K Lines) project written in Dart by Google, and that the earlier version of Adsense has been written in GWT, which has since died a silent death.
What’s the popularity of Dart?
According to the Tiobe Index of January 2019, Dart ranks higher than Kotlin and TypeScript. The Stackoverflow Survey of 2018, Github’s State of the Octoverse (2018) and also my own experiences show very different results. As a result, I don’t have great confidence in Tiobe in this case.
Another resource, CodeMentor, ranks Dart as the Worst Programming Language to Learn in 2018 in terms of, well, all criteria really. So, we’re off to a not so great start. So, why would one even consider learning Dart? Good question!
However, since there are a few languages existing like Dart, one cannot help but ask if running Flutter on Dart was the best thing to do, in terms of features, as well as developer experience.
In this post, we’re going to have a look at some competing languages, their maturity and capabilities. We’ll see how to they compare to Dart, so as to understand better why the need for a new programming language was deemed necessary by Google, instead of leveraging the capabilities of existing languages such as TypeScript or Kotlin.js.
I’ve chosen the comparison between Dart, TypeScript and Kotlin.js since all of these languages are Object Oriented, Class based and Garbage collected languages, with similar syntaxes.
What is TypeScript?
The development of TypeScript has received involvement from Anders Hejlsberg, who is the lead architect for C# and creator of Delphi and Turbo Pascal, and it’s currently maintained by the team at Microsoft, who launch a new feature release approximately every 2 months.
All in all, TypeScript is a quite popular language with functional aspects, (non-nullable) types, and has an active community.
What is Kotlin.js?
Kotlin is a statically typed programming language designed by Jetbrains, the company behind the well known IntelliJ IDE (and variations thereof). Kotlin runs on the JVM, it compiles to native code (Kotlin Native), and runs in the browser (Kotlin.js) as well.
The Lead Language Designer of Kotlin is Andrey Breslav, who joined JetBrains in 2010 to develop the Kotlin programming language.
Dart vs TypeScript?
Dart and TypeScript are, in principle, languages which look quite similar. When proficient with either Dart or TypeScript, the other language should be quite readable and not hold many surprises.
See the below table for a much more detailed comparison between Dart vs TypeScript.
Dart vs Kotlin.js?
As mentioned before, the syntax of all the languages mentioned here are quite similar, and as such, there is not a huge difference between Dart vs Kotlin in terms of readability.
There are however a few big differences between Dart and Kotlin.js. For one, the documentation of Dart is, despite a lack of books, surpassing the available documentation on Kotlin.js. There are Codelabs, tutorials and articles available, while the results for Kotlin.js are, well, disappointing. It’s almost impossible to find any resources on Kotlin.js, and the lack of documentation is a serious impediment for greater adoption.
On the language front, Kotlin has most of Dart’s features, with a more modern type system. Non-nullable types are great to work with, variable assignment is immutable by default, and so is the collection system. Besides that, Kotlin has extension functions, if/switch expressions, data classes, and much more, giving Kotlin a much more mature and modern feel than Dart.
Dart vs TypeScript vs Kotlin.js overview
|Created by||Lars Bak and Kasper Lund||Anders Hejlsberg||Andrey Breslav|
|Original release date||November 2013||October 1, 2012||March 2017|
(8 September 2021)
(26 August 2021)
(24 Aug 2021)
|Type safety||Optional||Optional||Yes, with dynamic support.|
|Reified generics||yes||No, whole type-system is erased||Yes, through keyword|
|Visibility scopes||Public and Private||Public, private, protected||private, protected, internal and public|
|Non-null types||yes, since 2.12.0||yes||yes|
|Functions||First class support||First class support||First class support|
|Mixins||yes||yes||Through Kotlin delegates|
|Data classes||no||Parameter properties||yes|
|Inheritance||yes||yes||Yes, but classes are final (non inheritable) by default|
(Browserify, Gulp, Grunt, Webpack, etc)
|Maven, Gradle, Command Line, IntelliJ|
(Articles, code labs, tutorials, website, books)
|Style guide||Dart Style Guide||No official guide||Kotlin Style Guide|
|Book||No recent books||TypeScript Deep Dive (Free)|
Why did Google choose Dart for Flutter?
One of the most important reasons to choose Dart was not because it’s a superior language to either TypeScript or Kotlin. Dart is currently lacking features which make it a great language, and the adoption of Dart will most likely much depend on the adoption of Flutter. Flutter 1.0 has been released in December 2018, so it’s far too early to say anything about the adoption of Flutter and what effect it will have on the popularity of Dart as a language. Most likely it’s depending on the effort Google is willing to put in to promote the language, if Project Fuchsia will be launched in 2019.
So, while the current popularity is not a great reason for Google to choose Dart, there are a few other reasons:
- Dart is a simple language. Yes, it’s missing features, but it’s very easy to get started with it.
- Much like Kotlin, it runs on the web, mobile devices, and through plugins, also on the desktop.
- But most importantly; it’s owned by Google, so Google is in full control over the VM, the language features, and less likely to be sued by Oracle, Microsoft, or any other corporation.
This blog has been peer reviewed by my colleagues which I’d like to thank them for, especially for the numerous contributions by Winston! Much appreciated!