First look: Google Dart vs. JavaScript

Dart fixes a number of problems with Web programming, but introduces new problems of its own

Page 4 of 4

But I'm not as thrilled as some Dart developers are about the way the team cleaned up the event connection code. The old way of simply putting an extra attribute like onclick into the HTML tag is gone. Now you have to add event listeners to the DOM element in the Dart code. The Dart team argues that this is cleaner because you might want to have several functions receiving the events.

I shouldn't complain about too many possible paths -- as I do in other places of this review -- and then grouse when Google prunes some of the options. It's just that it was very handy to have the method call inside the HTML tag itself. When I poke around some Dart code and try to figure out where the clicks are going, I need to first find the name of the element and then search through the code for methods that are attaching themselves to that element. It's cleaner, but it makes debugging a two-step process.

Google Dart: Will it win?
Does Dart have the charm and charisma to attract enough programmers and grow into the dominant language on the Web? There are certainly plenty of new features, and the authors did a nice job of cleaning up some of the most annoying cruft that's getting in the way of progress in the HTML/JavaScript/CSS stack.

One roadblock facing Dart is the fact that JavaScript is surprisingly agile, and JavaScript programmers have become very adept at reforming it to be just what they want. You don't need to migrate to Dart to get the nice class structure Google added -- programmers are already experimenting with bolting one onto the JavaScript juggernaut. The jClassy project is just one example. Libraries like Dojo and YUI have nice, elaborate mechnisms for loading just the code that's necessary. And you don't need to wait for Dart to emulate jQuery; you're probably using jQuery already.

The immediate plan is for Dart code to be translated into JavaScript, and this mechanism should work well enough. The code crashed when I loaded it into IE 8, but it ran smoothly when I switched over to Chrome.

But there may be deeper practical issues. The very simple program that prints "Hello World" is converted into 231,503 lines of code, many of them fairly long. I pushed this code through the built-in optimizer, and the result was still 183K. This overhead, or the ensuing bandwidth bills, will give developers for any popular site a reason to pause.

That will change if and when Dart is built into the browser. That day will probably come relatively soon, thanks to the way that Google is open-sourcing the code for Dart. The rest will be up to Web programmers.

The good news is that if they choose to come, they'll find a comfortable, familar structure that's cleaner and a bit better lit than the current world of HTML, JavaScript, and CSS. The structure is pure, and maybe that will be enough to attract the hordes.

This article, "First look: Google Dart vs. JavaScript," was originally published at InfoWorld.com. Follow the latest news in software development, languages and standards, JavaScript, and HTML at InfoWorld.com. For the latest business technology news, follow InfoWorld.com on Twitter.

| 1 2 3 4 Page 4
From CIO: 8 Free Online Courses to Grow Your Tech Skills
View Comments
Join the discussion
Be the first to comment on this article. Our Commenting Policies