Coding again at last! In Dart. Herewith are my initial experiences with Dart.



The reason I am using Dart is to run in the browser, which is the best platform for modern UI work. Being able to run on every device in the galaxy is a secondary benefit. What Dart offers over JavaScript is a serious language and a professional development environment. Everything I need is there, albeit still immature.

I spent an hour or two reading the “Up and Running” guide and was able to start coding immediately. The major differences in Dart from vanilla OO ala Java are optional typing and constructors. Much has already been written about the optional typing but so far I haven’t found it to be a big deal compared to simple “var” type inference. It lets you get away with things like heterogeneous arguments and duck typing but so far I haven’t needed those features. Dart’s new approach to constructors aren’t discussed as much but are a big win for me.

Dart makes object construction atomic and deterministic. Some common initialization idioms are outlawed – for example initializers can’t reference ‘this’. But it is so great not to have to deal with revealing partially constructed instances or non-deterministic class initialization order. A related feature is compile-time constant object instances with interning. There is also nice support for factory constructors. Dart’s creators are VM experts, and I think it shows in the way they have rationalized the insanity of laissez-faire construction.

The Dart Editor is a slimmed-down Eclipse with all the essentials: type-driven completion, autofix suggestions, type and doc lookup, usage-definition traversal, and refactoring. Some of it is rudimentary, but I find there is enough to get real work done without cursing. I am a little worried that analysis time is already perceivable with less than a thousand lines of code. Update: there do seem to be scaling problems in the static analyzer, but I am told they are being actively worked on. I am hoping they can fix it before I write too much code, or else IntelliJ gets their plugin working.

The libraries are the most immature, and feel a bit like an afterthought. There are excellent highly evolved class libraries to copy from, but it feels like they started from scratch. Or started from JavaScript, which is about the same thing. For example they just added Object.hashCode, and there still isn’t a Collection.equals method. But compared to JavaScript, the Dart libraries are already a giant win. I suppose they are prioritizing breadth over depth, which makes sense. So far no show-stoppers, but there is still an alarming amount of churn in the APIs.

The one feature I wish Dart had was case classes as in Scala. These give you immutable value objects without the boilerplate hashcode and equals, and give you type-driven switch statements.

Anybody else have experiences with Dart to share?