The purpose of the Tutorial is to give an introduction on how to create programs using the JavaScript programming language by running them using Seed. Also included are sub-tutorials to some of the Gnome libraries that Seed uses.

The assumption is that whoever is using this tutorial has some basic knowledge of computer programming but does not necessary mean knowledge of JavaScript and/or the Gnome Libraries.


As much as possible, I am going to put example code in the context of a program so that it can be easily be copied and pasted into any editor and run. This is different from other tutorials I have encountered that place the program code at beginning and then add fragments of code later on. I find this fragmented approach confusing and for most folk they love to jump in, play about with the code and then come back to the tutorial when they need more information.


Please note that this is a work in progress and is no where near to completion. Parts of the tutorial are a wee bit rough round the edges due to being lifted from my blog. There are other parts that I have written from scratch and the priority is firstly to get something written down.

Once I finish the basics section, I will review and tidy it up.

Exploring Seed

There are two ways on how to run JavaScript code using Seed. One is to use the interactive console and the other is to interpret text files containing JavaScript code.

Using Seed Console

The first way of using the interactive console is to enter it by using the following command on the Linux console:


Once the interactive console is activated, you will be greeted with the following prompt:


You can enter any piece of JavaScript code into the console and the code will be run.

   1 print ("Hello World!");

Will output the following:

Hello World!

You can also enter multi-line pieces of code like for instance if statements. After the first line, the prompt will change to this:


An example of this is as follows:

   1 if (x==4)
   2 {
   3 print ("Inside if statement");
   4 print ("x ==4");
   5 };

In the console, it will look this this:

> if (x==4)
> {
..print ("Inside if statement");
..print ("x ==4");

Running .js files

The second way of interpreting files of JavaScript code is simply to use Seed following by the name of the file. An example is if you had a file containing JavaScript code called hello_world.js, you would run this on the Linux console:

seed hello_world.js

The program will run and will display any output in terminal if the program is set-up to do so.

Alternatively, if the JavaScript file has the correct file permissions and the correct environment header, it can be run with out using it as a command line argument of Seed. It would then simply be run as follows:


More on this later.

First Program

As with every tutorial, it has to start with the hello World program. Copy the following code into your favourite editor.

   1 #!/usr/bin/env seed
   3 print("Hello, world!");

Save the program as hello_world.js

As mentioned, JavaScript, or JS as I will now call them, files can be run with or without Seed. To run without Seed, enter the following command in the Linux Terminal

chmod +x hello_world.js 

The command chmod changes the permissions of the specified file. The mode +x sets the file to execute. This allows the files to be run without Seed which is done by entering the following command on the console:


Predictably, the output is as follows:

Hello, world! 

Going back to the program, a bit simple but here is an explanation of it:

 #!/usr/bin/env seed

This is referred to as a Shebang (#!) which tells the console to use the specified interpreter to compile the text file. This is done through the env program which uses the appropriate environment variable set by your distro to where Seed is installed.

More info on Shebangs are at the following wiki page:


This line is not a requirement in a JS file but obviously will not work if you intend to run it without Seed.

The next line prints the string "Hello, World" to the console:

print("Hello, world!");

Projects/Seed/Tutorial/Overview (last edited 2013-11-22 19:19:58 by WilliamJonMcCann)