Get Started


This page serves as a guide for quickly getting up and running with Xen.

  1. Installing Xen
  2. Hello World
  3. Variables
  4. Functions
  5. Loops
  6. Conditionals
  7. Modules / Namespaces

1. Installing Xen

Head over to the downloads page and download the appropriate distribution for your system. If your platform doesn't have any precompiled binaries, you'll need to build Xen from source.

Once you have Xen installed, make sure you add it's bin directory to your PATH environment variable.

Building from source

In order to build Xen from source, you'll need to make sure your system meets the following requirements:

Once you've verified your system requirements, download the source code and extract the tarball. Then navigate into the project root and run the following command:

$ make debug # or release

For Windows compilation:

$ make windows-debug # or windows-release

Clean build artifacts:

$ make clean

2. Hello World

Hello World in Xen is extremely simple. Create a new text file with the extension .xen and add the following line to it:

include io;
io.println("Hello World");

You can then run this program by running the following command:

$ xen hello-world.xen

3. Variables

Variables in Xen are defined with the var keyword. Variable names can contain letters, numbers and the underscore (_) and can have a maximum length of 64 characters. They cannot begin with a number. Any valid Xen object can be assigned to a variable, including functions.

var x         = 10;       # valid
var _         = "hello";  # valid
var my_var_80 = 0.1;      # valid
var 5_times   = null;     # invalid

4. Functions

Functions in Xen are defined with the fn keyword. Function names follow all the same rules as variable names.

fn inv_mod(a, b) {
    return -a % -b;
}