Dart vs. TypeScript

Dart vs. TypeScript

I am coming from a front-end background (mostly Angular, a couple of projects in React) and programmed for almost 4 years in TypeScript - basically when Google released Angular as a successor of AngularJS.

Oh, and btw.: Did someone tell Google that Angular was a pretty bad naming decision as successor of AngularJS in terms of google search performance?

But Dart caught my attention as the Flutter framework looks quite promising in terms of performance and what I call "feature speed".

Why do you compare Dart and TypeScript?

Great question! And there are already great answers:

- Why does TypeScript have to be the answer to anything?

- TypeScript or Dart? And more important: React or Flutter? (Part 2 out of 7)

A bigger picture of this article is to wrap our heads around one framework, tool or language to rule them all - speaking of one programming language and/or toolkit to program and then build native apps for Android, iOS, mac OS, Linux and Windows out of it. But this is out of scope of this article. Let's start simple and compare TypeScript and Dart for the first step ;)

So, let's take a deeper look at both programming languages.

Community background

Dart

Dart appeared 9 years ago on October 11th, 2011 and is actively developed by Google. It's influenced by Java (some call it "Java lite" - quote from Eric Windmill) and currently has 6.2k stars on Github.

Dart is not very well adopted outside of the Google universe. With Flutter as the - currently - main project it has some backing, but there are candidates that do way better...

TypeScript

TypeScript appeared 8 years ago on October 1st, 2012 (October seems a good release month for programming languages) and is actively developed by Microsoft. It's strongly influenced by JavaScript (and Java and C#) and currently has 66.9k stars on Github.

TypeScript is currently the holy-grail in front-end frameworks: Angular, React and Vue - to name the "big three" - all support TypeScript very well.

Result

Communitywise TypeScript with 66.9k stars on Github is the clear winner.

Dart: 0
TypeScript: 1

Performance

That's a tough category. Let's break this down into some sub-categories:

Performance - Runtime

When you wrote your programs and execute them: How fast are they performing?

Dart

Dart can compile to either native code (on mobile platforms) or JavaScript. No doubt native code is the performance king. JavaScript in the browser is - in recent browsers - quite fast as well.

With Dart 2.6 (current stable version of Dart is 2.10.4) the dart2native compiler was introduced to enable dart programs to be compiled to self-contained, native executable code.

And even further:
"Dart is one of very few languages [...] that is well suited to being compiled both AOT and JIT." - citation from a great post "Why flutter uses dart" from @wmleler

TypeScript

TypeScript is compiled - or more precisely: transpiled - to JavaScript. JavaScript has some decent performance in the browser. But compared to native code it is doing "good".

Result

Runtime performance of native code is unbeatable. Dart is the winner in this category.

Dart: 1
TypeScript: 1

Performance - Compilation

When you develop your code and want to see results - how long does it take to do the "hot reload" proclaimed by so many platforms?

Dart

That is the category Dart - or more precisely: Flutter - is made for: it's unbelievable fast. When you run Flutter and change your code it's compiled in a matter of milliseconds and synced to your Debug device. Great development experience.

TypeScript

The "hot reload" functionality of TypeScript (and the most front-end frameworks) are super handy for your daily development experience. But it might get time-consuming when your web-app grows and becomes bigger. There are tools and frameworks that provide help (Webpack and tree-shaking to the rescue!) but it's still a pain in big projects.

Result

Dart's (and Flutter - see next category) "hot reload" compilation is very fast. Again: If you are interested in this topic I highly recommend the great article "Why flutter uses dart" by @wmleler on this topic.

Dart: 2
TypeScript: 1

Tooling

The IDEs, scripts and utilities that help us in our daily development routine.

Dart

Dart is covered in all major IDEs: Visual Studio Code, IntelliJ - there is even DartPad: https://dartpad.dev to try-out some Dart code in the browser.

When it comes to libraries, you experience the "small community" effect: There is a handy package manager (pub) and the package repository is "good".

TypeScript

The best proof to have great tooling support is to write a very popular IDE in the programming language itself: Visual Studio Code is written in TypeScript. IDE-support for TypeScript is excellent: Visual Studio Code, IntelliJ, multiple browser IDEs (https://jsbin.com, https://jsfiddle.net, etc.) and many more.

Result

TypeScript is based on JavaScript which has npm - the biggest package repository in the world. Unbeatable.

Dart: 2
TypeScript: 2

Frameworks

Comparable to the "Tooling"-category Frameworks are the Community-Driving force of programming languages.

Dart

Flutter is by far the most popular framework written in dart - there are others as well, but again: mostly in the Google universe. Flutter itself is undoubtedly a great framework - but this is out of scope of this article. For more info about Flutter check our Flutter by example.

TypeScript

TypeScript "extends JavaScript by adding types". And with this TypeScript supports the biggest repository of libraries there is - with one downside: Not all of them are typed. But this can be handled fairly easily.

Result

TypeScript is based on JavaScript which has npm - the biggest package repository in the world. Unbeatable.

Dart: 2
TypeScript: 3

Summary

There is a clear winner by the points: TypeScript. BUT: It all depends on what you are planning to do:

Developing a Web app? TypeScript is your language.

Developing a mobile app? Take Dart (and Flutter) for a spin - it's great!

Developing a desktop app? Take Dart (and Flutter) for a spin - it's gaining momentum.

With Google's plan to position Flutter as a framework to serve different native apps from one codebase Dart is becoming more interesting.

Currently TypeScript is the clear winner - but Dart is becoming more important with the increasing popularity of Flutter. Let's see how Flutter aims on the web - the competition is extremely tough.

Reach out to us! We are hiring!

expressFlow is now Lean-Forge