Your first program

Write a file, run it, then poke around in the REPL.

Hello, world

Create a file hello.xs:

hello.xs

Run it:

xs hello.xs

No main required for scripts. Define one anyway and it gets called automatically:

hello.xs

The REPL

Run xs with no arguments to start the interactive Read-Eval-Print Loop:

xs

Type XS expressions and see results immediately. Multi-line input works: lines ending with {, (, [, or \ continue on the next line automatically. Useful REPL commands:

:t 42           -- show inferred type of an expression
:env            -- list all bindings in the current session
:clear          -- clear the current session state
:quit           -- exit (:q also works)

A small program

Variables, an if expression, a loop:

greet.xs

if is an expression and returns the value of the taken branch. String interpolation uses {name} inside the string. Comments start with --.