* Documentation

Getting Started

Install Turf, set up TURF_HOME, and compile your first program.

Turf is a statically-typed, LLVM-backed programming language. Current version: v1.0.0.

Installation

There is no package-manager distribution yet. You have two options:

  1. Pre-built binary — grab an archive from the Releases page for your platform if one exists. CI currently builds for Linux (x86_64, Arch x86_64), macOS (Apple Silicon and Intel), and Windows (x86_64). Release archives bundle lib/ alongside the turf binary, so extracting one and running the binary from inside the extracted folder works with no further setup.
  2. Build from source — see Building from Source on the Tooling page.

Setting up TURF_HOME

Every import — Turf’s own standard library under lib/std/, and (once a package format exists) third-party packages under lib/usr/ — is resolved against the TURF_HOME environment variable, which should point at the folder that directly contains lib/.

You only need to set this if you move the turf binary somewhere else than where you built or extracted it — with TURF_HOME unset, the compiler falls back to looking for lib/ next to its own binary. Running straight from an extracted release archive or a freshly built source checkout needs no setup at all.

Linux / macOS (bash or zsh) — add this to ~/.bashrc, ~/.zshrc, or ~/.profile:

export TURF_HOME="/path/to/turf-installation"

Then open a new terminal, or source the file to pick it up immediately.

Windows — PowerShell, set once for your account (new window required):

setx TURF_HOME "C:\path\to\turf-installation"

Or for the current session only:

$env:TURF_HOME = "C:\path\to\turf-installation"

Windows — cmd.exe:

setx TURF_HOME "C:\path\to\turf-installation"
:: or, current session only:
set TURF_HOME=C:\path\to\turf-installation

Windows — GUI: Start Menu → search “Environment Variables” → Edit environment variables for your account → New… under “User variables” → Variable name TURF_HOME, Variable value the path to your Turf installation.

Verify it worked from a completely unrelated directory (e.g. your home directory) by compiling the hello.tr below — import io; should resolve regardless of where you run turf from.

Your first program

// hello.tr
import io;

fn main(): int {
    io::printline("Hello, Turf!");
    return 0;
}
turf hello.tr -o hello
./hello

A few things to notice immediately, since they trip up anyone coming from a C-like language:

From here, the Language Tour walks through the full surface of the language, and the Standard Library page covers every module io lives alongside.

Compiler introspection flags

Beyond ordinary compilation, turf exposes a set of flags for inspecting what the compiler itself is doing at each stage: --dump-ast, --dump-resolved, --dump-typechecked, --dump-modules, --emit-llvm. See Tooling for the full CLI reference.