Google Dart hits a bull's-eye for Web developers

Google's new client-side Web language melds the best of JavaScript with familiar structured programming techniques

1 2 Page 2
Page 2 of 2

How Dart improves on JavaScript
For example, JavaScript is a dynamic, weakly typed language that allows you to, for example, treat a numeric string as an integer and perform arithmetic on it. This makes it very easy to lose track of which variables should hold values of which types, leading to data corruption and hard-to-trace errors. You might assume that Google would address this issue by making Dart a strongly typed language, but it didn't. Instead, it added just enough type safety to make debugging easier without sacrificing JavaScript's flexibility.

In Dart, declaring data types remains completely optional. If you declare them, however, Dart generates compile-time warnings -- not errors -- alerting you of potential problems. You can also execute Dart code in a debug mode that generates errors and halts execution at runtime if type conflicts arise. The advantage of this method is that you can start out coding in fast-and-furious JavaScript style and add type declarations later, as your code base grows and matures.

Dart also differs from JavaScript in its object-oriented syntax. JavaScript is a prototype-based language, a programming style that may be unfamiliar to developers with experience in languages such as C++ and Java. Objects in Dart are defined using the more traditional classes, reducing the learning curve for programmers coming from other languages.

Other Dart differences are designed to help make client-side code easier to manage and maintain, particularly when dealing with large applications and development teams. For example, JavaScript code loaded by different <script> tags in the same HTML page all exists within a single namespace; objects and variables referenced by one script can be modified by any other. Dart doesn't allow this; each script has full control over its own state.

Also, while JavaScript tries to run whatever code it can, as soon as it can, Dart code is executed in true application style. Dart waits until the DOM is fully loaded to begin execution, and each application runs starting with an explicit main() function, as in C. These and similar features impose just enough order on programmers to help pull client-side development out of the Wild Wild West that is JavaScript.

Will you use Dart?
All in all, I'm impressed with what I've seen of Dart so far. I guess I shouldn't be surprised; in many ways, Dart is exactly what we should have expected from Google, the company that has poured more effort into JavaScript-based application programming than any other. The question is, will it gain any traction or will it remain mostly an experiment like Go?

The decision to have Dart code compile to JavaScript may be disappointing to some, but it was the right choice. Requiring a plug-in to run Dart applications in current browsers would have been a total nonstarter. No doubt Google will embed a native Dart VM into Chrome before too long, and because Dart is open source, other vendors will be able to do the same if the language has any legs.

I can't help but wonder, though, whether a new client-side Web programming language is really the answer. Google began the project out of frustration with the limitations of JavaScript. JavaScript has been around for 15 years now. Surely, after 15 years, Dart will seem similarly long in the tooth. I'd still like to see an effort to embed a more open, language-neutral VM into Web browsers that would allow client-side developers to code in the languages of their choice.

That might be wishful thinking. The more pragmatic approach is to develop tools that can improve on JavaScript today. With Dart, Google has done an admirable job of that. It's a tool worthy of any Web developer's attention, and I look forward to seeing where it goes next.

This article, "Google Dart hits a bull's-eye for Web developers," originally appeared at Read more of Neil McAllister's Fatal Exception blog and follow the latest news in programming at For the latest business technology news, follow on Twitter.

Copyright © 2011 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2
How to choose a low-code development platform