Thursday, February 23, 2012

A Quick Play With Dart

I've been vaguely aware of Google's new answer to Javascript, Dart, for awhile now but I have never really taken the time to look at it. However, recently I stumbled across some Dart related videos on YouTube and decided to finally try it out.


What's Dart for?
Billed as "Structured Web Programming", it's a new language for client side web programming in place of using Javascript (and just like Javascript has moved to the server side with Node.js, one day we should be able to use something like a "Node.dart" for the server side). Because no web browser has built in support for it (except for certain special builds of Chromium, called Dartium), you need to run your Dart source through a compiler. There are two to choose from, one written in Java and other self hosted in Dart.

What's It Like?
Dart claims to be "familiar yet new".  Java and C#/Vala people should feel right at home. I think the same can be said for Actionscript fans (I'm not 100% sure as I've only ever looked at Actionscript and have never written anything in it - but from what I've seen of Actionscript it looks at least vaguely similar).

What's Interesting About It? 
Optional Typing leaps out first in my mind. You don't need to specify a type for a variable, so "var x = new Something(); x.doSomething();" works just a well "Something x = new Something(); x.doSomething();", however it's not like Scala where the compiler works out what the variable's type is. Instead the Dart compiler flat out doesn't care about the type. You could just as well write "Anotherthing x = new Something(); x.doSomething();" and all you will get is a warning in the IDE.  You can view type information in Dart more as a sort of annotation instead of a core part of the language.

Where To Start?
dartlang.org is Dart's home. If you want to watch some videos first the check out YouTube. Scalawags will probably want to watch Gilad Bracha's "A Walk on the Dart Side", while everyone else should probably head over to Seth Ladd and Steve Messick's GTUG talk "Dart: A Language for Structured Web Programming". I've got a small playlist of those and other Dart related videos here.

What's Next?
I'm going to carry on playing with it as it does seem interesting, while keeping in mind that it's still a Technical Preview and subject to change at relatively short notice.