Hello World From V8
Heard of V8 but haven’t got a clue how to run it? Here’s a quick guide to get you started. This guide is intended for Mac OS, but there are detailed Windows instructions.
V8 is actually a C++ JavaScript engine, designed to be embedded in another program. Fortunately Google provide a sample shell that can be built with the bundled build chain.
Step 1: Get Scons
Assuming you’ve already got Xcode installed, get Scons. V8 uses this as its build tool. It’s easy to install from source, but you could also use MacPorts. MacPorts will fetch a whole bunch of dependencies — if you’re on Leopard or Snow Leopard you should be OK to just build it yourself.
I installed it like this:
sudo python setup.py install
Step 2: Build V8
Fetch V8 from the Google Code subversion repository:
svn checkout http://v8.googlecode.com/svn/trunk/ v8
Then build V8 and the sample shell:
scons
# Wait for a bit...
scons sample=shell
You will be able to run the interpreter with ./shell.
Step 3: A Less Painful Interpreter
To get command history and more, install rlwrap. I actually did install this from ports.
Then run: rlwrap ./shell.
Step 4: Hello World
V8 version 1.3.18.6
> print("hello world");
hello world
>
I also tried a library I wrote, with insanely fast results:




