Note: This article was written several years ago. It describes an installation process that may not work on your system today. If you run into trouble, please follow Google's instructions instead:
Get your daily vitamins with d8
It can be difficult to sort out the various options mentioned in the documentation. I have successfully installed and executed d8 on Ubuntu versions 12.04 and 14.04 by running the following sequence of commands in a terminal.
$ sudo apt-get install git git-svn subversion
$ mkdir ~/js
$ cd ~/js
$ git clone git://github.com/v8/v8.git v8
$ cd v8
$ make dependencies
$ make native console=readline
$ sudo ln -s ~/js/v8/out/native/d8 /usr/bin
$ source ~/.bashrc
What does it all mean?
Let's go through it step by step.
First, we have to install software that will download V8 packages from the appropriate repositories. The sudo command will probably prompt you for your password.
sudo apt-get install git git-svn subversion
Now let's make a directory called js in the home directory. We'll install V8 inside this directory.
Go to the directory where we're going to install V8.
Use git to download the latest stable V8 release into a new directory called v8.
git clone git://github.com/v8/v8.git v8
Go to the directory containing the V8 source code.
Invoke a script that sets up the compilation environment.
Compile the various components of V8, including the d8 shell. The compilation process takes a long time. You can speed it up with parallel processing: add the option -j2 if you have a dual-core CPU, -j4 if you have a quad-core CPU, and so on.
make native console=readline
The compilation process is done. The d8 shell is ready to execute, and its absolute path name is ~/js/v8/out/native/d8. To avoid typing the whole path each time we want to run d8, let's add a symbolic link in the /usr/bin directory.
sudo ln -s ~/js/v8/out/native/d8 /usr/bin
If you're running the Bash shell, use the following line to refresh your configuration file so that you can immediately access d8 from anywhere. (If this doesn't work, open a new terminal window and you should now be able to use d8.)
Things that may not be obvious
What if you want to execute a longer program? Suppose the file a.js contains your program and you want to feed it the contents of in.0 as input. Execute the following.
d8 a.js < in.0
The following useful commands are built into d8.
effect: read a line from stdin
example: var line = readline();
effect: write the arguments to stdout, followed by a newline
example: print(1, "two", 3);
effect: read a text file into a string
example: var data = read('in.0');
A final command that may come in handy is quit(), which leaves the d8 environment. Alternatively, you can get out of the interactive loop by entering an EOF character with Ctrl-D.