Embedding Javascript

22 Dec 2008

Recently, for personal and professional projects I've been working with Javascript implementations for embedding. It's quite interesting that there three separate teams working on an open source implementation of the same language with the same goal of great performance. I can't think of another language that has this much focus.

Here's my take on the state of the world 22-Dec-2008. Comments welcome.


  • SpiderMonkey is Mozilla's C implementation.
  • In development for over 10 years
  • API is large, and fine grained, but a bit klunky in some spots to deal with legacy issues
  • API is in C, with some C++ helpers
  • Lots of options for error, memory and runtime control
  • Lots of documentation on Mozilla's site, and via searches
  • Version 1.7 source code is in CVS and has a wacky install procedure
  • Version 1.8 source is in Mercurial and uses standard autotools
  • Has the most Javascript language features and extensions (as you would expect by the creators of Javascript)

Version 1.8 isn't out yet but should be soon. It's a bit tricky to get a snapshot, but I've documented and posted a tarball in my other article.


  • JavaScriptCore is the implementation in Safari.
  • API is in "minimal C++" (nothing too scary)
  • API looks nice, maybe the best of the bunch but..
  • ZERO web documentation
  • Frequently zero code comments in headers... and when they do exist... no line break. So you have a 600 character single line comment. Lovely. What editor are they using!
  • Code in SVN
  • Code configured via SCONS, which seems to work once you know where to look
  • No formal releases I can see (didn't investigate tags)
  • Didn't see anything on controlling execution (e.g. while (1) { }
  • Main wiki wildly out of date

The API is really nice looking, but hampered due to lack of any documentation. There are some samples in a test directory -- that's about it. Apple (or whoever controls it) needs to put in nice release engineering to show the world their handy work.

Chrome V8

  • V8 is the implementation in Google's Chrome browser.
  • API is "maximal C++" -- templates, automatic casting, macros, multiple namespaces, the works
  • Code is in SVN
  • Code configured via SCONS
  • Semi-formal releases via tags
  • Some documentation on web for major concepts, less so on getting things done.
  • I found it hard to know or even find where things were defined, or what some defined things in the API even were
  • Didn't see anything on controlling execution (e.g. while (1) { }}
  • Very active development (it's the newest engine)

V8 is has a very "clever" api that uses all sorts of C++ tricks to simplify coding. Good luck if you need a C api. I think the API is a good start and has a lot of promise, but right now it's a little too confusing for my tastes. A good scrub of the main API files will help a lot.