Albite

Hello, world

Here is a complete Albite program:

fn main() -> String {
    "hello world"
}

Save it as hello.tg. Every executable needs a main; its return value is what the program produces.

Note there is no return and no semicolon on that line. A function body is an expression, and its last expression is the result — a rule that holds everywhere in the language, not just in main.

Check it

albite check hello.tg
✓ hello.tg: 1 definition(s), all OK

check type-checks and stops. It generates no code and needs no LLVM, which makes it the fastest way to ask whether something is well-typed — the command you will run most.

Run it

albite run hello.tg
"hello world"

run evaluates the program with the built-in interpreter. Also no LLVM.

The quotes are worth a word. run prints the value your program evaluated to, rendered the way a String value is written — so you see "hello world", not hello world. That is a small but real difference from the compiled binary below, which prints the string itself.

Compile it

albite compile hello.tg -o hello
./hello
hello world

compile lowers your program through LLVM to a native executable. This is the one command that needs LLVM 18 installed.

Which command when

CommandWhat it doesNeeds LLVM
albite checkType-checks only; no output artefactNo
albite runEvaluates via the interpreter, prints the valueNo
albite compileProduces a native binaryYes

Reach for check while writing, run to see a result quickly, and compile when you want an artefact.

A caveat worth knowing early. The interpreter and the compiled binary should agree, and for almost everything they do. There are currently two known shapes where they do not — early return in statement position, and same-named definitions imported from sibling modules. In both, the compiled result is the correct one. See Current limitations.

Returning something other than a string

main can return any type with a printable representation:

fn main() -> Nat {
    20 + 20 + 2
}
albite run arithmetic.tg
42

Next: a short tour of enough of the language to read real Albite code.