Coding With SpiderMonkey

The Idea

Many years ago I had an idea. That idea was to integrate PHP and Javascript by building an extension for PHP based on Mozilla's SpiderMonkey Javascript engine. My main motivation behind this idea was that I wanted to be able to re-write my IRC bot Wiser and have it use javascript for plugins and commands.

Before I could get to that dream though I knew I needed to first learn how to code for SpiderMonkey in general so a separate sub-project was born that I called WiserJS. This project was intended to be a generic javascript host program that one could write extensions for in order to provide new functionality. Essentially what I was attempting to build was Node.JS but using SpiderMonkey.

I decided that while I tackled this learning excercise I would document what I learned in the form of tutorials and post them on my website. I figured other people my be trying to do things with SpiderMonkey and they may benefit from whatever experiences I can pass on. The tutorials did get some traffic from google and I did get a few comments regarding them so I suppose at least a few people did find them useful.

These days the tutorials are most likely out-dated and irrelevant but I leave them up for nostalgia because I can. Maybe someone in the future will enjoy them, and it reminds me of one of my more ambitious personal projects.

The code

I did eventually end up creating a simple host program that could do some basic file and socket operations. This was as far as I was able to get however before various life events required attention and I abandoned the project. By the time I thought about doing anything else with it, Node.JS was already well on it's way to becoming the standard JS platform and had amassed a large community.

If anyone is interested in the code, I do still keep a copy of it around on my Subversion server. To check out a copy of the code you'll need to have Subversion installed. Once installed simply issue the following command in your terminal.

svn co https://svn.aoeex.com/wiserjs/trunk/

The code was originally written using Microsoft Visual Studio. The necessary project files are included in the repository so if you have a copy of Visual Studio it should be easy to get it up and running.

The Tutorials

  1. Getting Started
  2. Executing Scripts
  3. Console Object
  4. Files and Exceptions
  5. File and Directory Management
  6. Sockets
  7. Calling Functions From C