Tag Archives: Tom Austin

Zaphod: A Browser Language Lab for JS

When I started full-time at Mozilla this January, one of the first projects I dreamed of starting was an experimental version of JavaScript that would be easy to hack and experiment with. Ideally, it would be embeddable in Firefox so that we could really try it out in the wild. My hope was that this would be useful for experimenting with JS features and ECMAScript committee proposals, and for seeing how they interact on the web. But, the best laid plans of mice and men being what they are, I never seemed to find the time for the project.

Enter our summer intern Tom Austin! Tom spent the first part of his summer helping us revive the Narcissus project, which is a JavaScript interpreter written in JavaScript. Brendan Eich wrote Narcissus several years ago as an experiment, but at that point it required a special build of SpiderMonkey to enable some low-level hooks. This meant that you couldn’t use Narcissus without building it from scratch. Tom worked on replacing the dependency on these hooks with the new meta-programming API’s coming in Firefox 4 so that Narcissus can be used with the standard build of SpiderMonkey.

Once Narcissus started getting back into shape, Tom spent the rest of his summer building Zaphod, which is now available as an experimental Mozilla Labs addon for Firefox. Zaphod lets you choose Narcissus as the scripting engine for a <script> element by specifying the attribute type="application/narcissus". It also lets you switch the default engine from SpiderMonkey to Narcissus so that you can run existing web pages through Narcissus.

Zaphod promises to be a great tool for getting hands-on experience with experimental JS language features. Initially, it will useful to us internally for rapidly piloting language features in the browser. Down the road, it may also become a vehicle for giving the community early access to these ideas, so they can try them out and give us feedback. And of course, it’s all open source, so anyone who wants to join in on the effort is most welcome.