Dart: Structured Web Programming Language

 

The goal of Dart is ultimately to replace JavaScript as the lingua franca of web development on the open web platform.

The Silicon Valley Google Technology User Group's December 2011 meeting (stream) was focused on the new structured language, Dart. Google released Dart in a technology preview in October 2011 with the goal of moving web programming into the future ("removing 15 years of cruft").

The majority of the presentation was given by Steve Ladd, a Developer Advocate at Google. Steve has previously worked with Rails, HTML5 and Java and MVC frameworks (he authored "Expert Spring MVC").

Dart looks extremely familiar if you understand OO, particularly Java. Dart has a compiler that emits Javascript capable of running on any "modern" browser (defined as Chrome, Safari 5+, Firefox 4+ and IE9) or it can be run in a Dart VM. The Dart team is also advocating a new MIME type "application/dart" that will allow Dart to be run directly in browsers that support it.

Currently, Dart does not have support for Refection, so there isn't (yet) a jUnit type unit testing framework available. In a nod to building large scale apps, Steve Ladd made sure to walk through code samples that made use of mocks, emphasizing the value of interfaces.

Dart also has a number of things that are missing in Javascript:

Libraries

The core library contains support for Collections, Maps, Hashtables and more.

Classes - look quite a bit like their Java counterparts

class Rectangle {

final num height, width;
Rectangle(num this.height, num this.width);

}

Interfaces - very Java-like as well

interface Shape {

num perimeter();

}

class Rectangle implements Shape{

final num height, width;
Rectangle(num this.height, num this.width);
num.perimeter() => 2*height + 2*width;

}

Static Types

Well, kinda sorta. You can turn on enforcement during compilation if you want (throws an error). However, during run-time, the VM will determine the actual type and execute (even if I do something like take a Rectangle object and erroneously declare it as a String). This "feature" seems pretty dangerous to me.

Dart Editor

At the meeting, we got a preview of the Dart Editor, which runs inside Eclipse. It was an early version, but many Eclipse basics were working including auto-complete and the ability to drill into declarations. It looked almost ... Java-like.

Conclusion

Dart looks pretty interesting. Javascript is pretty messy, especially without jQuery. With a friendly open source license (BSD) and native support in Chrome, the language might have some legs.