The Second Coming of Dart


The Birth of Dart

The Dart language was designed and conceived by Lars Bak and Kaspar Lund at which time  both were at Google. Dart was announced to the world in this October 2011 blog post.

Quoted from the blog :

“Dart code can be executed in two different ways: either on a native virtual machine or on top of a JavaScript engine by using a compiler that translates Dart code to JavaScript. This means you can write a web application in Dart and have it compiled and run on any modern browser. The Dart VM is not currently integrated in Chrome but we plan to explore this option”.

From this introduction way back when, we all understood Dart’s main purpose was to bring higher performance and Javascript-like ease of use to web application development. So we can conclude Dart was developed primarily as an alternative to or replacement for Javascript in the browser.

The Journey of Dart Life

Dart’s nearly ten year journey to relevance has been a long time in the making so I’ll  try to document that journey and key events starting from the birth of the language in 2011, through the introduction of the Flutter framework, and most recently, the release of Dart 2.0. 

Competing Goals

In a 2018 Hacker News discussion, one of contributors to Dart core (munificent aka Bob Nystrom2) provided a historical perspective on Dart’s two initial goals:

1. Get a native Dart VM into Chrome and eventually other browsers

2. Get a significant number of client-side web developers that were using JavaScript to move to Dart

Pushing on both goals at the same time would have been extremely challenging but there was also a classic chicken-and-egg situation in prioritizing one over the other.

Focusing first on convincing the developer community to adopt Dart over JS would have been a tough sell without a real native Dart VM. In a world with only JavaScript VMs, precompiling Dart to JavaScript just wasn’t compelling enough, especially in a world with TypeScript emerging as an alternative.

Realizing this, the Dart team prioritized the first goal of getting the VM integrated into Chrome. For better or worse, it never came to fruition. Aside from a non-production “Dartium” build of Chromium, the Dart VM never made it to Chrome.

In fact, fast-forwarding to the present, Typescript was the real winner in terms of Javascript alternatives. It has quite successfully popularized one of Dart’s primary language goals: type safety.

In another decision, if Google focuses on achieving the first goal,indeed it will be much more difficult because it is unlikely other browsers want to support Dart VM.

And if the first goal is achieved, Google doesn’t need to struggle to achieve the second goal anymore because Dart VM already provides a new “engine” for browser based apps and developers don’t need to use Javascript or worry about it anymore. But unfortunately, the majority of developers have fear of Google dominance and control if they depend on Dart VM and this is another hindrance to Dart VM success.

History tells us that Google went to prioritize the first goal and failed to achieve it, because no other browsers wanted to support Dart VM so the first goal failed spectacularly. 

Competitive Advantages

Google saw the weakness of Javascript and disadvantages of it, which I believe is one of the strong reasons why they developed Dart. But because of Javascript’s pervasiveness and broad support in all browsers, many developers feel there is no strong reason to adopt Dart because in terms of language it is really different to Javascript and developers tend to stick with language they already know.

If Google could bring Dart VM support to all browsers, Dart may have stronger competitiveness because the Dart plus Dart VM can offer many advantages compare to JS engine but otherwise we still don’t know whether it will succeed in case all browsers willing to add Dart VM support because it is still not easy job to influence developers to replace all existing Javascript code that runs well already in production and to convince them to not worry of Google dominance. 

Javascript Compilation

In the beginning. Dart compilation to Javascript was really bad, see this quote “Nine lines of Dart code is successfully compiled to … 17,259 lines of JavaScript”. (1)

This inefficient compilation result added another reason for developers to reject Dart, although there were improvements on the next versions, but this early version already put a bad impression and triggered big NO from early adopters. And if the latest Dart transpilation to Javascript has good performance, what prevents developers from writing code in Javascript directly or choosing Typescript over Dart ?

Web UI Component

https://pub.dev/packages/web_ui

Google had developed a Web UI component based on Dart but failed to bring a lot of adopters and its status now is deprecated. Now Google recommended Polymer.dart as a replacement.

Angular Dart

Other than the Web UI component, Google also created Angular Dart that until now still doesn’t have too many adopters out there. Majority of front-end developers will choose Angular with Typescript over Angular Dart. Latest AngularDart supports Angular version 5.3.1 (it is in progress of migrating to 7.0.0) that is far behind the latest Angular version that already reached version 14.1.3, at the time of writing. This is a strong sign that this framework is not well maintained anymore.

First Dart Death 

Like the success formula of all businesses, Dart failed because it didn’t offer strong competitive advantage and obvious differentiation to others. 

Dart failed to attract many believers and couldn’t convert many of other existing language and platform followers to come to Dart “religion”.

Although in reality Dart was not going anywhere and there were still ongoing improvements along the time since the birth and the first coming until now, the majority of developers felt that Dart already departed into another realm and some thought Dart died already before the second coming of it, starting with release of Dart 2.0.

The Second Coming of Dart

When Google prepared the second coming Dart in their lab, they put a lot of interesting materials and happiness promises to developers in it and they didn’t forget to provide new heavens for Dart believers. 

Dart brings a new mission to become “multi-platform client-side language. In particular, application language of Flutter, a cross-platform mobile framework(2)

Dart 2.0

Dart 2.0 that was released in August 2018 with sound type system (3) is the first reality of The Second Coming of Dart. This version bring new characteristic on Dart language to become more “C# with less boilerplate” and not “JS with more types” anymore. 

A sound type system has several benefits:

  • Revealing type-related bugs at compile time.
  • More readable code.
  • More maintainable code.
  • Better ahead of time (AOT) compilation.

Flutter 

Flutter is the first promise as the “happiness place/heaven” for the second coming of Dart believers that finally can attract many developers to adopt Dart because Flutter is becoming a de facto multi platform UI framework. For now Flutter is still in progress to support desktop applications. (https://github.com/flutter/flutter/wiki/Desktop-shells)

Dart2Native

Since version Dart 2.6 at the end of 2019, with the release of dart2native, Dart enables the creation of command-line programs on Linux, Windows, and MacOS.

With dart2native, a lot of developers who learned and know Dart well (mainly because of Flutter), can expand their Dart skill usage to develop other types of applications, like command line programs, serverless functions and microservices.

Serverless & Microservices

The rise of serverless and microservices that support Dart applications. Although the emphasis of Dart is on the client side, it is very possible to use Dart for building Microservices because it can be deployed easily as native linux application using Docker in K8 and AWS Lambda already supports Dart runtime (4). These new trends open the opportunity for a lot of Flutter developers to use their Dart skill to develop serverless functions and microservices. The experiment I found on the blogosphere mentioned that we can build a Dart docker image with 20 mb size (5)  which is not bad.

Fuchsia

Another incoming operating system from Google called Fuchsia states that Dart and Flutter is the recommended language and framework to build UI for Fuchsia. This may bring Dart to a lot of believer masses in future because I believe a lot of developers will think Fuchsia has a big probability as the next successful operating system and promising as new heaven for them, learning on Android adoption which is a very big success. 

Dart is an approved language for Fuchsia, and it is a really different situation for Golang (Go), which is not approved by Google (although it is still supported). This fact is stated in the Fuchsia Programming Language Policy (6) document. This is a very interesting fact and quite weird because we know Go is developed by Google and it is a very popular programming language and widely used for many Google cloud services.  

Conclusion

With the new exciting promises and heavens, the second coming of Dart already attracts many believers, followers also evangelists and surely with some fanaticals believers included. 

The existence of Fuchsia as a new future heaven, which is still built in progress, the ongoing Google process to bring a lot of new believers is still happening, that involves a lot of Googlers. They have a good Flutter Youtube channel with a lot of new videos added frequently that successfully attract a lot of subscribers (415K at the time of writing) already.

From what we see on Flutter showcase here https://flutter.dev/showcase, we can see a big number and growing list of well known and big companies around the world already adopting Flutter, that of course includes Dart.

Outside the big and well known companies in Flutter showcase page, we also can find a lot of mobile and web applications that are built using Flutter + Dart at https://itsallwidgets.com/

New Dart will not disappoint the believers because it comes with great programming language features and comes with exciting and attractive promises of developer heavens like Flutter, Microservices and Fuchsia.

For now we already become Dart believers and we admit that we are involved in some kind of Dart evangelism by writing this article.

We can say that the New Second Coming of Dart gave birth to the new successful “Dart 2 religion” that converted many developers to become believers, but most pragmatic developers don’t want to become fanatical believers because they still strongly believe in the “use right tool for the job” verse.

References:

  1. Why Google Dart Will Miss Its Target

https://www.sitepoint.com/google-dart-fail/

  1. Can anyone explain why he called Dart a complete failure?

https://news.ycombinator.com/item?id=17248636

  1. Dart 2.0 Sound Type System

https://dart.dev/guides/language/sound-dart

  1. Introducing a Dart runtime for AWS Lambda

https://aws.amazon.com/blogs/opensource/introducing-a-dart-runtime-for-aws-lambda/

  1. Experiments with Dart Microservices

https://itnext.io/experiments-with-dart-microservices-fa117aa408c7

  1. Fuchsia Programming Language Policy

https://fuchsia.googlesource.com/fuchsia/+/refs/heads/master/docs/project/policy/programming_languages.md#Go.