What's awesome about Dart?
The thing that I liked most about Dart is that I took me very little time to pick up. It is in many aspects so similar to Java that I had very few surprises so far.
This is another advantage of Dart over TypeScript, there is some Web UI building stuff included, and also some very important things are built-in. For example there is really no need for jQuery, Dart already has some
query function that you can use.
As a fan of Eclipse, I am very happy to see that a lot of work is put into creating an IDE that is enjoyable to use. For TypeScript an Eclipse plugin has been released just recently, but I bet the quality of the Dart IDE, which is an Eclipse RCP, is higher.
Some of the language constructs are pretty nice. I especially like the
.. notation for initializing objects. It allows you to chain methods calls as if they were returning the
this object. Example:
TestResult.addTest(new Test("Adding positive numbers", 10)..progress=5..status=Test.CANCELED);
is equivalent to:
Test t=new Test("Adding positive numbers", 10); t.progress=5; t.status=Test.CANCELED; TestResult.addTest(t);
I like this so much that I actually which this would be in Java. Btw. my AST Model is designed in such a way that you can do this, but each method call is returning a new immutable object.
Like most modern languages and Java 8 it also has functions as first class objects and closures, which makes filtering tasks very smooth. There are a few other little things that I like, for example get/set declarations.
What sucks about Dart?
Creating a language is hard, especially the validation part. So it is not very surprising that I encountered and reported a few bugs here and there, but one of it is so severe that it makes me question whether google is serious about Dart or not.
var x = 123; print(x is! double);
int billion = 1000000000; int quintillion = billion * billion; int quintillionOne = quintillion + 1; print(quintillion == quintillionOne);
A purely cosmetical issue is the fact that dart2js takes 3.5s for a very simple dart file and produces an obscene amount of code around, which is caused by the fact that each dart2js invocation kind of becomes its own complete application with all APIs included and everything, but I will come to that later again.
At least one bug that took me one day to find was caused by the lack of enums. But there is light on the horizon, someone is working on it and it will be available post 1.0 probably.
Another bug that I produced was caused by the fact that this code does not even generate a warning:
When you call doStuff, it simply returns null... This is not what I expected, but oh well, some people like it that way..
Another thing that I can get my head around is the package and library system. I somehow manage to import my stuff and am able to use it, but I still don't understand what I do when I place a
at the top of the file. Sometimes you need it because if you include two files that don't have it, Dart gets confused somehow. But its not like you need that anywhere... Maybe I am really just missing something here that is totally useful, but for now I just accept it and put something random at the first line so that the compiler is happy. I am also not the biggest fan of the URI based imports.
Dynamic loaded code
When I started to implement the dart code generation for simulation, I was wondering how I could actually load some code at run-time. The solution to that are called isolates. In principle a nice multi-threading concept. You create a separate process for the loaded code and communicate via message passing. So far so good. But this also implies a heavy performance overhead, because all your data is serialized and deserialized for every Message that you send. No shared memory, nothing. This makes it also quite cumbersome to send some data. My first idea was to have a simple recipient on the generated code side that receives values to set, make a run and return ports that changed. The performance of that was awful! The reason is quite simple: For the message passing Maps are used and copied in between processes. I then used another method where the input for the generated code is generated within the simulation process. The UI just sends some configuration data to the simulation process, which then runs until something changes. Then it reports those changes back. How that looks like can be seen here.
Another thing that I learned, when working with isolates debugging becomes really hard. You can't set break points in the isolate and it sometimes crashes without propagating the exception properly.
I really enjoy programming in Dart. While the frequent updates to the Dart SDK cause some slight shivering when I see that yet another update is ready, the overall stability is good. You can't blame the Dart team for breaking API changes that cause some trouble in this early stage of Dart development.
But whether I recommend someone to use Dart depends on the dart2js bug. If you know that you will not be affected, I can recommend it. But it also shows that the designers of dart dreamed up some concept that they can't deliver right now. I really hope that this is fixed soon and if they deliver a 1.0 with this bug still open, I will call them morons and slam my door really loud, but very certainly I will not recommend Dart to anyone then.