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:
- 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.
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 is currently the holy-grail in front-end frameworks: Angular, React and Vue - to name the "big three" - all support TypeScript very well.
Communitywise TypeScript with 66.9k stars on Github is the clear winner.
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?
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.
Runtime performance of native code is unbeatable. Dart is the winner in this category.
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?
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.
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.
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.
The IDEs, scripts and utilities that help us in our daily development routine.
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".
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.
Comparable to the "Tooling"-category Frameworks are the Community-Driving force of programming languages.
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.
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.