Infrequently Noted

Alex Russell on browsers, standards, and the process of progress.

Bits and Peices

As things ramp up for the Comet Developer Day and the Dojo Developer Day(s), there's been a ton of activity in Dojo-land. Here's a selected sample:

Adventures In Comet and Multipart Mime

The Dojo Bayeux client implements a bunch of different "transports" and tries to pick the right one based on what the browser can support, the cross-domain requirements, and so forth. When we started down this path, most of the reason for doing this was to implement both the forever-frame and long-polling styles of Comet as well as providing a platform to experiment with alternate transport types (e.g., Flash sockets). One of the most promising of these experiments took advantage of the multipart mime support that's been tucked away in the Mozilla codebase for quite a while. What follows is one of those stories that makes people assume that I'm crazy to do what I do for a living. They might be right.

Multipart is attractive because it provides a way of avoiding TCP set-up and tear-down for each and every event across the channel. While it's not significant overhead (comparatively), being able to also reduce the number of HTTP header blocks sent can also help out when it comes to wringing latency out of the system. The code indicates that multipart is supported on Safari and Mozilla, but while events are indeed delivered at the right times on Safari, you can't get at the payload until the connection closes completely. Not useful.

Things were looking better on Firefox and it was the preferred transport type in the Dojo client, but I think that's going to have to change. Sadly, it seems we can't actually tell when a multipart connection has failed. In "normal" XHR requests, the 200 HTTP status code plus a "finished" readystate indicates that the contents of the request can be read and control handed back. In the multipart case, each successful block fires of a load handler and resets the readystate. That means that the combination of readystate and and status can't be used to differentiate between block success and connection success. Making matters worse, server-side connection failure doesn't fire any kind of readystatechange handler, and even if it did, it doesn't appear to be possible to determine if the connection is closed from any of the public properties on the object.

So, OK, what about falling back to a timer that restarts the connection every N seconds for good measure? This might work in cases like failover where a lag of 10 to 30 seconds might be acceptable but not for normal operation. Should events be flow regularly, it might never be necessary to hit this "backstop". Not great, but I gave it a try, only to discover that Firefox won't give you responseText of an XHR request if the connection is marked as multipart but the response isn't a 200 and wrapped in a multipart block. Since we're trying to use HTTP status codes correctly and keep the server internals from needing to fork significantly for each pluggable transport, it's something of a step backward to need this kind of hand-holding.

I'd still like to support the multipart transport type, but until at least one of the implementations becomes rational for use from the XHR object, I think I'm going to just be commenting this transport out in cometd.js. Like XHR itself, it's one to mark down for resurrection a year or two from now. At least we still have good enough options in the mean time.

Belated JavaPolis Roundup

This past week I had the good luck to be invited to speak at JavaPolis and while there, even for only 2 days of the weeklong event, amazing stuff seemed to be dropping out of the sky like rain.

My talk was in the first slot of the first day of training (before the official conference start), but despite the hour and the day, folks still came to hear about Dojo. Following me were Jonas Jacobi and John Fallows' talk on JSF+Dojo, but little did I know (until a half hour before they gave the talk) that they'd written a new Comet server from scratch for the talk, and it implements Bayeux! Their demo hooked a Dojo table and chart widget up to a set of Bayeux channels for updating stock prices. It's always fun to see everything on the screen update in unison.

The next day, some of the folks working on Phobos cornered me to show some of the server-side Dojo integration they've been working on. It's amazing to see JavaScript finally "getting there" on the server side, and I'm glad we can be a part of it.

Lastly, there was some spirited debate in the never-ending static vs. dynamic languages debate over dinner. Not sure I swayed anyone at the table, but there was a pretty strong dynamic languages contingent at the conference in general, which I wasn't expecting.

I was happy to hear that the Swing team at Sun is starting to really get that startup time and complexity really are significant limiting factors. To that end I started to throw together a very small dojo.widget.SwingWidget namespace and I was surprised at how simple it was to get things dynamically updating compared to earlier experiments with SWT. Desktop access and portable desktop UIs have always been the one place where dynamic languages fall down, so perhaps we really can make a difference with JavaScript + Dojo + Java in liberating desktop programmers. Swing programmers who are interested in seeing how deep this particular rabbit hole goes should get in contact with me...might make for some sexy demos of Java 6 if we can show that there's no external dependency chain and it's faster to develop in than Java.

The Extra Click Syndrome

I just fired up Firefox to do a bit of writing over in the project wiki, and as sometimes happens, I was presented with an extension update notification screen. The UI is mostly a farce of user control in that there's not nearly enough information to judge whether or not going to the next version of Me.dium is a good idea or not. I blithely click "OK" to let it do it's installation dance in the hopes that it'll get out of the way. I've got stuff to do. It dutifully proceeds.

A couple of seconds later, it's done, and instead of getting an unobtrusive notification of success while the browser starts to load whatever it is that I actually care about, the update window simply shows a nearly identical UI, but the button that had previously allowed me to proceed with the upgrade now reads "Continue". Do I have a choice at this point? What would closing the browser at this point ever buy me over hitting "Continue"?

Given the massive number of Firefox users and their use of extensions, it boggles the mind to think how much time is wasted by this one button alone. Unless there is an affordance for recoverability (roll back the upgrade) or discoverability (what just happened?), this button needs to die.

Including Dojo, The Really Easy Way

AOL has been generously hosting builds of the toolkit in their CDN for some time, but using these builds has always seemed scary. Configuring local and remote copies of the same thing hardly seems like fun. Also, lots of people ask us for a way to "just include one file to get Dojo". It's an obvious thing to do, and it turns out the cross-domain infrastructure that AOL donated is the perfect solution to both problems!

In response to Amit Green's excellent suggestion, I've constructed a couple of very small "wrapper" files that will let you include the "Ajax" build of Dojo from various versions through the cross-domain loader. Including the latest stable Dojo couldn't be simpler:

<script src=""></script>

It's also trivial to test out the latest 0.4.1 Release Candidate:

<script src=""></script>

That's all there is to it!

From here on in, your pages can use the dojo.require() system to pull in anything that's part of the "stock" distribution, and by following James' detailed documentation and test page, you can also load your own custom packages while still loading the main system from a separate domain.

Older Posts

Newer Posts