Skip to content
Wantzel
Start

Getting started

From download to a running program in a few minutes.

Wantzel is one file. Download it, write a small program, build it, and run it.

1. Get the compiler

The compiler is a single executable for Linux x86-64 with the whole standard library inside. Nothing else needs installing. Wantzel Studio carries it as well.

curl -O https://wantzel.com/download/wantzel-linux-x86_64
chmod +x wantzel-linux-x86_64
sudo mv wantzel-linux-x86_64 /usr/local/bin/wantzel
wantzel --version

The checksum is on the download page. wantzel --lib lists the modules that are built in, and wantzel --lib money prints the source of one.

2. A first program

An invoice line: the net amount, the VAT, the total. Amounts are whole cents in an int, never a real, so the result is exact. Save this as factuur.wz.

import io;
import money;

var
  line: array[0..63] of char;
  n, net, vat: int;

begin
  net := 125000;                       // EUR 1.250,00, always whole cents
  vat := money.percent(net, 21);

  n := io.push(line, 0, "net   ");
  n := money.put(line, n, net, ',');
  io.out(STDOUT, addr(line), n);
  io.puts(STDOUT, "\n");

  n := io.push(line, 0, "vat   ");
  n := money.put(line, n, vat, ',');
  io.out(STDOUT, addr(line), n);
  io.puts(STDOUT, "\n");

  n := io.push(line, 0, "total ");
  n := money.put(line, n, net + vat, ',');
  io.out(STDOUT, addr(line), n);
  io.puts(STDOUT, "\n");
end.

3. Build and run

The compiler takes a source file and the name of the executable to write.

wantzel factuur.wz factuur
./factuur
net   1.250,00
vat   262,50
total 1.512,50

4. What you saw

  • import money; brings in a library module (which pulls in io). Every module is inside the compiler.
  • money.percent(net, 21) takes a share of an amount in cents and rounds half away from zero.
  • io.push and money.put write text into a buffer you own; io.out writes the buffer to standard output. Nothing allocates behind your back.
  • Declarations come first, begin opens the main program and end. closes it.

5. When the compiler says no

The compiler is strict, and its messages name the file, the line and the fact. Change net := 125000; to net := "1250"; and build again:

wantzel: factuur.wz:9: type error in assignment: expected int, found str

There are no implicit conversions and no undefined initial values, so a program that builds does what it says. A runtime error, such as an index outside an array, stops the program and names the file and line too.

6. Where next

  • The language opens with a tour and then specifies every construct.
  • Writing Wantzel lists the pitfalls and takes you from an error message to its cause.
  • How-to has recipes: an HTTPS server, background work, resolving names.
  • Prefer an editor? Wantzel Studio writes, builds, runs and debugs the same programs.