Google offers the web a new language called Dart – but why?

Google has announced an early preview of Dart, a new language for web applications. The news is not a surprise, especially if you have been keeping track of the developer conference GOTO Aarhus, whose organisers had pre-announced that Google would be announcing its new language there, as indeed it did.

image

Dart is a curly-brace language like JavaScript, Java, C, C++ and C#. In Dart, as in C# and Java, a class can implement multiple interfaces, but only inherit from a single class. Dart supports both static and dynamic typing. Google says it can be executed by a Dart VM, or converted to JavaScript:

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.

Google also says that you will be able to “execute Dart code directly in a VM on the server side”, so you can infer that Google has Dart in mind as an alternative PHP as well as to JavaScript. The company is using the phrase “structured web programming” to describe Dart, and this phrase appears in the announcement and as the subtitle on the Dart site. The implication is that JavaScript code tends to be poorly structured and that Dart will promote more maintainable code.

In the preview Dart only runs in Chrome, Safari 5 and Firefox 4+ – spot the missing browser vendors.

At first glance, Dart looks like a promising language, though I find myself asking what it is really for, when it bears a strong family resemblance to existing languages, and bearing in mind that the Google Web Toolkit, which compiles Java to JavaScript, already enables structured programming for web applications. The list of problems which Dart solves in the technical overview is not all that compelling.

Google states that:

Developers have not been able to create homogeneous systems that encompass both client and server, except for a few cases such as Node.js and Google Web Toolkit (GWT).

This is or was one of the attractions of Microsoft Silverlight, presuming you use C# on both server and client, but Silverlight is a plug-in that was never going to run on an iPad and from which Microsoft itself is now retreating; though it is worth noting that Dart is not unlike C#, especially the latest version of C# with dynamic features.

I guess that Dart is a consequence of the failure of ECMAScript 4.0, which was a cooperative effort to create a more modern and advanced JavaScript. Google is now going it alone; the key question is whether it can win support from others such as Apple and Microsoft, or whether this will be a Google language for Google on the server and Chrome on the client, or an interesting experiment that never really catches on.

Do we need Dart? I would value hearing from others what you think of Google’s proposal.

4 thoughts on “Google offers the web a new language called Dart – but why?”

  1. Dart is Google’s effort to advance the state of Web app development beyond what can be achieved through backwards compatible JavaScript evolution. Organic, incremental evolution can only take you so far. You’re still hobbled by the requirement to support the old patterns and syntax, which may be incongruous or incompatible with a fresh approach.

    I’m not familiar with what’s been going on in Ecmascript 4.0, but from what I’ve heard the committee got into an evolution versus revolution stalemate. Google’s Dart is the product of the revolution mindset.

    Google hopes Dart will do for Google what C# did for Microsoft: provide a clean-break restart point, taking the good bits and shedding the bad, creating a new baseline at or above the “high water mark” of JavaScript and other languages it replaces.

    I like what I see in the Dart language features overview. Executing Dart in a VM is fine, but compiling Dart down to JavaScript will be the key to Dart’s adoption as a web app dev tool. That eliminates the deployment problem completely, making Dart a candidate for developing web apps to run on any JavaScript capable device.

    I won’t consider Dart for any real development until I see a Dart tool chain – in particular, a debugger. I’ve done large scale JavaScript web app development with the JavaScript tool chains available at that time, and it was extremely painful and time consuming compared to fully realized tool chains such as C#. Debugging tools will probably be the tipping point for me.

  2. At first glance Dart may seem to be re-inventing the wheel but I find a couple of the distinctions between Dart and JavaScript interesting:

    Multiple Dart scripts embedded in an HTML document do not occupy a common namespace, as they do in JavaScript, so code in one script cannot automatically access that in another. This means Dart should prevent conflict between like-named global variables and functions.

    As Dart scripts are invoked when the DOMContentLoaded event fires, unlike JavaScript, they do not run until the DOM is fully loaded. All objects are therefore guaranteed to be accessible when the Dart script executes so it can assuredly add event-listeners. This means Dart can safely disallow inline event-listeners in the HTML code.

    But will Dart catch on? Your guess is as good as mine…

  3. Have you tried to maintain a non-trivial application that has tons of JavaScript? If you’re asking the question “do we really need Dart?” I suspect the answer to my first question is, “no”. Dart appears to have facilities to let people create reusable code, not re-packaged ala current JavaScript libraries. Plus there is static typing so there should be some tools that allow for real refactoring support instead of “search and destroy” techniques one must currently utilize with JavaScript. Those two are enough in and of themselves!

  4. Simply put Dart is Google’s SilverLight. They don’t even need to do anything fancy. Just copy half of what C#/SilverLight provides then they’d have one heck of product. Imagine if GoogleDoc or ChromeOS were written in a toolset as good as C#/SilverLight. MSFT dominance in Office and Windows would be seriously challenged. Right now Google has the ambition to steal market share away from Office and Windows but get their hands tied by the pathetic Javascript. Should Dart become a SilverLight counter-part (and it looks like it has every chance to become one) watch out. Microsoft can kill SilverLight for the sake of Windows but they cannot do anything about Dart from an outsider company, and Google can give Dart a free reign here.

Comments are closed.