Tutorial 1 of 4

Your first script

You'll write a tiny script, run it, then grow it with a variable, a function, and a loop. Every snippet below has been run against the real interpreter.

Needs Python 3.11+ and a clone of the repository - see Installation if you haven't set that up yet.

Step 1: Hello, Falx

Create a file called hello.flx anywhere you like:

output("Hello, Falx!");

Run it from inside your clone of the repository:

$ python -m src.Main run hello.flx
Hello, Falx!

Step 2: A variable

Add a let and build a string with +:

output("Hello, Falx!");

let name = "Ada";
output("Nice to meet you, " + name + ".");
$ python -m src.Main run hello.flx
Hello, Falx!
Nice to meet you, Ada.

See Variables & types for the full rules on let/const.

Step 3: A function

Declare a function with func and define together:

func square = define(n) {
    return n * n;
}

Full write-up: Functions & closures.

Step 4: A loop

Put it all together with a while loop and the postfix ++ operator:

output("Hello, Falx!");

let name = "Ada";
output("Nice to meet you, " + name + ".");

func square = define(n) {
    return n * n;
}

let i = 1;
while (i <= 5) {
    output(i + " squared is " + square(i));
    i++;
}
$ python -m src.Main run hello.flx
Hello, Falx!
Nice to meet you, Ada.
1 squared is 1
2 squared is 4
3 squared is 9
4 squared is 16
5 squared is 25

That's the whole shape of a Falx program: a flat list of statements, executed top to bottom, with functions as ordinary values. See Control flow for foreach and if/elseif/else too.