shake, with fries

by Zach Carter

Posts tagged xpcshell

Oct07

Another Way to Run Narwhal

javascript narwhal mozilla xulrunner xpcshell commonjs | comments

What's Narwhal? Ahem:

Narwhal is a cross-platform, multi-interpreter, general purpose JavaScript platform. It aims to provide a solid foundation for building JavaScript applications, primarily outside the web browser. Narwhal includes a package manager, module system, and standard library for multiple JavaScript interpreters. - narwhaljs.org

It basically enables you to do things in JavaScript you might do in other scripting languages, like Python or Ruby. It's one implementation of the CommonJS specification. If you're in to JavaScript, you should get acquainted with it.

The default engine uses Rhino, but there's also a XULRunner engine, allowing you to use Narwhal from within Firefox extensions and other XUL applications. Really exciting stuff!

I wanted a quick way test Narwhal/XPCOM modules, so I made an engine using xpcshell to do just that. It shares most of its libs with the xulrunner engine.

To set it up:

git clone git://github.com/tlrobinson/narwhal.git narwhal
cd narwhal/engines
git clone git://github.com/Gozala/narwhal-xulrunner.git xulrunner
git clone git://github.com/zaach/narwhal-xpcshell.git xpcshell
cd xpcshell
bin/install
cd ../..
NARWHAL_PLATFORM=xpcshell bin/narwhal
js> 

It should work on Linux and OS X. Windows support is certainly possible. I'll have a hack at it one day.

You can learn more about what can be done with Narwhal on their site.