Dart
At a party the other night, John Maloney was asking me whether I’d tried Dart. I had spent a bit of time with it back in May, but I realized that I hadn’t posted anything about it here. I figured that I’d better change that, so I went back and blew the dust off one of the programs I’d built then. I had to make a few changes because some libraries had been renamed, but they’d also made a number of improvements.
Here’s a copy of our old friend Planets and Ships. As in the original Processing version, you click to add ships which will fly around the planets. Let’s see how well this works for those of you who aren’t using Chrome.
You can also use the ‘c’, ‘s’, and space keys to create trails behind the ships and reset things.
There are four source files:
As you can see from looking at them, Dart is basically a cleaned up version of JavaScript. They seem to have done a pretty good job of giving you easy access to all of the things you really want from JavaScript while hiding some of its more annoying and confusing quirks. The best part of it is that it comes with a nice, easy to install development environment. This includes a good debugger, doc publishing tool, unittest framework, and some good examples. The environment looks something like this:
When you hit run, it pops up a copy of Chrome which connects to a local server it starts for you. The edit/debug cycle is nice and fast. I haven’t played with the Pub packaging tools yet because I’ve just been making little toy apps.
If you run into problems getting it to run in your browser, please drop me a line. Dart provides hooks for running in browsers other than Chrome, but I’m not sure that I’ve got them all set up correctly in this example.
So it appears that this is working fine in Chrome & Safari, but not in IE. I’ve only done a bit of digging, but the problem appears to be where dart.js installs the listener on DOMContentLoaded. I don’t think that IE wants you to call window.addEventListener when you’re inside an iframe. I guess I’ll have to figure out a different way to embed into blogger’s page.