Web Workers

July 22, 2009

One of the hard restrictions that JavaScript GUIs like Caplin Trader run up against is the single threadedness of the browser’s JavaScript engine. Organising the asynchronous execution of code to service both user interface and network events in a responsive and timely manner from a Comet server is fiendishly difficult.

So I was heartened to read about Web Workers today. In future they would enable a GUI like Caplin Trader to handle network events on a background thread…

One Response to “Web Workers”

  1. It’s great to see these kind of features being added to HTML 5 and modern browsers.

    At Caplin we’re always looking for new and improved ways to make the browser a better and better application platform. There’s no doubt that in a modern browser you can build awesome applications and being able to background some JS processing is another good tool to have in the box.

    There’s 2 issues with leveraging this in Caplin Trader at the moment:

    The first is that most implementations (except FF3.5) only support passing string data between workers and the main application. The obvious optimisation you mention – parallelising the handling network events – is mainly string parsing of the wire protocols into JS Objects and if we can only get strings back the benefit is negated.

    The second is that in the browsers that currently support webworkers (FF3.5, Safari 4 and Chrome), Caplin Trader performs so well that they aren’t really needed currently. Or, to put it another way, the browsers that would most benefit the speedup (IE6 and IE7) don’t and won’t support them!

    This is where Google’s Gears provides some help – they have a similar concept, the workerpool: (http://code.google.com/apis/gears/api_workerpool.html) and the Gears plugin can be added to IE6 and IE7. The problem is that, as I discussed in my recent blog post (http://blog.caplin.com/2009/07/14/supporting-ie6-a-poison-chalice-or-the-holy-grail), most users on IE6 aren’t there through choice, and it’s probably equally difficult for them to install a plugin like Gears as it is to upgrade to a better browser.

    What we’re likely to do is start to take advantage of this and other HTML5 features where they’re present but fall-back gracefully where there not. We just need to be careful we don’t end up back in the dark days of the early 2000s where large chunks of website code was conditional on which browser you were using!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s