Dart vs Typescript vs Kotlin.js

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?

Dart is a programming language originally developed by Google. The language is designed by Lars Bak, who, before working for Google, worked on multiple Virtual Machines, such as the JVM, and a VM for Smalltalk. At Google, besides working on Dart, Lars also worked on the V8 Javascript engine.

Dart itself is an object-oriented programming language inspired by Java, Javascript, Smalltalk and Erlang. While it’s originally launched in 2011, the adoption of Dart hasn’t been great. Not many projects have been written in Dart, and only several books have been published in the last 5 years. Only since 2017, with the introduction of Flutter, does Google show again a bit of interest in the language.

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?

TypeScript is a language developed by Microsoft. It’s designed as a superset of Javascript (meaning all Javascript code is also valid TypeScript code), and, as the name implies, TypeScript adds types to Javascript. This makes TypeScript a better language to develop larger applications in, since it gives more compile time safety and prevents errors.

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.

TypeScript, like Dart, has been inspired by a lot of other mainstream programming languages such as Java, C# and Javascript, and the syntax of TypeScript has great similarities with those languages. TypeScript is widely used these days, and is the default language for Angular, Nest (a NodeJS framework), Grafana and many more. Frameworks like Vue.js and React have great support for it. Also, Microsoft’s own VS Code IDE is written in TypeScript.

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.

The Kotlin language and frameworks evolve at quite a steady pace. Experimental features are added in most releases of the language (enabled by setting a feature flag), and these features are then ported to the other platforms Kotlin runs on, if applicable. While the language itself is quite well evolved, the documentation is not. There is almost no documentation specifically for Kotlin.js. Although there is one example project at the time of this writing, there are virtually no books on Kotlin.js. So, while the Kotlin language (especially on the JVM) works well and is well documented, for the Javascript version of Kotlin there is a little less love at the moment.

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.

The bigger difference between Dart and TypeScript is the adoption. While Dart is only adopted by Flutter, TypeScript has a wider adoption. While both languages had their 1.0 release around 2013-2014, Microsoft has been much more successful in pushing TypeScript as a better JavaScript than Google has.

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

DartTypeScriptKotlin.js
Owned byGoogleMicrosoftJetBrains
Created byLars Bak and Kasper LundAnders HejlsbergAndrey Breslav
Original release dateNovember 2013October 1, 2012March 2017
Current version2.14
(8 September 2021)
4.4
(26 August 2021)
1.5.30
(24 Aug 2021)
Type safetyOptionalOptionalYes, with dynamic support.
Genericsyesyesyes
Reified genericsyesNo, whole type-system is erasedYes, through keyword
Visibility scopesPublic and PrivatePublic, private, protectedprivate, protected, internal and public
Non-null typesyes, since 2.12.0yesyes
FunctionsFirst class supportFirst class supportFirst class support
MixinsyesyesThrough Kotlin delegates
Data classesnoParameter propertiesyes
Extension functionsnoyesyes
If expressionsnonoyes
String interpolationyesyesyes
Operator overloadingyesnoyes
Supported platformsFlutter
Web
Server
Web
Server
Web
Server
InheritanceyesyesYes, but classes are final (non inheritable) by default
Sealed classesnonoyes
Javascript interopThrough JS interop packageNative, TypeScript Compiles to JavascriptTranspiles to ECMAScript 5.1
Online playgroundDartPadPlaygroundPlayground
Tooling supportTooling
VS Code
IntelliJ
Android Studio
Atom
Vim
Emacs
Tooling
VS Code
Webstorm
Netbeans
Atom
Sublime
Eclipse
Vim
Emacs
IntelliJ
VS Code
Build toolsOwn build toolAll major Javascript build tools
(Browserify, Gulp, Grunt, Webpack, etc)
Maven, Gradle, Command Line, IntelliJ
DocumentationDart documentation
(Articles, code labs, tutorials, website, books)
TypeScript documentationNone
Style guideDart Style GuideNo official guideKotlin Style Guide
BookNo recent booksTypeScript Deep Dive (Free)
Amazon books
None

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:

  1. Dart is a simple language. Yes, it’s missing features, but it’s very easy to get started with it.
  2. Much like Kotlin, it runs on the web, mobile devices, and through plugins, also on the desktop.
  3. 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!

Older Post
Newer Post

2 Replies

Leave a Reply

Your email address will not be published. Required fields are marked *