Loft is a lightweight scripting language with null safety, built-in parallel execution, and a fast interpreter called loft. This page shows how to install loft and write your first program.
Prerequisites
Building from source requires the Rust toolchain. loft is an edition-2024 crate, so that means Rust 1.96 or later. Running a built loft needs no Rust at all — --native compiles through your system's C compiler. Install Rust from rustup.rs if you do not already have it:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Install from source
Clone the repository and install it into ~/.local, with no root needed:
git clone https://github.com/loft-lang/loft
cd loft
make install-user
This puts the loft binary in ~/.local/bin/ and the standard library it loads at runtime in ~/.local/share/loft/, and tells you if ~/.local/bin is not on your PATH. make install installs system-wide under /usr/local instead.
Build locally
To run loft from the checkout without installing it:
cargo build --release
./target/release/loft --version
The binary at target/release/loft uses the standard library in the checkout's default/ directory, or share/loft/ beside an installed bin/. A copy with neither beside it still runs, on the standard library built into it. make install-user (or make install) is the way onto your PATH.
Verify the installation
loft --version
Hello, World
Create a file called hello.loft:
fn main() {
println("Hello, Loft!");
}
Run it:
loft hello.loft
Hello, Loft!
A slightly bigger program
Variables, loops, and string interpolation all work without any ceremony:
fn main() {
// Variables are mutable by default; types are inferred.
total = 0;
for n in 1..=10 {
total += n;
}
println("Sum 1..10 = {total}");
// Vectors use square-bracket literals.
words = ["loft", "is", "fast"];
for w in words {
print("{w} ");
}
println("");
}
Command-line flags
Run loft --help for the full list. The most commonly used flags are:
| Flag | What it does |
|---|---|
--help | Show all available options |
--version | Print the loft version |
--path <dir> | Look for the default/ standard library in dir instead of next to the binary |
--interpret | Interpret the program instead of compiling it — the other half of the choice loft makes for you |
--timeout N | Stop the program after N seconds; worth using the first time you run something |
--explain | Print the suggested fix under each diagnostic. It only shows the fix, so it is always safe to run |
--native | Compile to a native binary through C and your system's C compiler, and run it (without a C compiler on PATH, loft says so and interprets) |
--ship | Builds the program as you ship it: fully optimised, with its native libraries linked in (slower to compile, fastest to run). Add --native-wasm, --html or --native-android to ship that target |
--native-debug | Compile with debug information naming your .loft source lines; combine with --ship for optimised + debug info |
--native-emit [out.c] | Write the generated C source to a file without compiling it |
Running your program as a native binary
loft myprogram.loft already compiles through your system's C compiler when it can find one, and interprets when it cannot — you do not have to choose, and the answer is the same either way. Compiling needs no Rust toolchain at all: the C runtime is inside the loft binary. It takes under a second the first time, caches the binary, and runs compute-heavy code many times faster than interpreting (Performance measures native against hand-written Rust). Ask for it on purpose when you want to:
loft --native myprogram.loft
To see the generated C code without running it:
loft --native-emit myprogram.c myprogram.loft
cat myprogram.c
Target toolchains
What each compiled target needs on your machine:
| target | needs | Debian / Ubuntu | macOS | Windows |
|---|---|---|---|---|
--native | a C compiler (cc, or the one LOFT_CC or CC names) | apt install build-essential | xcode-select --install | MinGW-w64 gcc |
--native-wasm | clang, lld, the WASI libc and the wasm32 compiler-rt (or the clang LOFT_WASM_CC names) | apt install clang lld wasi-libc libclang-rt-dev-wasm32 | brew install llvm lld wasi-libc wasi-runtimes — found without settings; Apple's own clang has no wasm target | wasi-sdk (the x86_64-windows archive), with LOFT_WASM_CC=<wasi-sdk>/bin/clang.exe |
--html | the wasm toolchain above, and binaryen's wasm-opt for a page that draws frames | … and apt install binaryen | … and brew install binaryen | … and binaryen's bin on PATH |
When a tool is missing, loft says which and what to install on the machine it runs on.
Standard library
The standard library is a set of .loft files bundled alongside the loft binary. They are loaded automatically before your program runs — you do not need any import or use statement to call println, assert, or any other built-in function.
The full function reference is in the Standard Library section of these docs.
Using libraries
Place a library file (e.g. lib/myutil.loft) next to your program, then bring it into scope:
use myutil;
fn main() {
result = myutil::compute(42);
println("{result}");
}
See Libraries for the full search path and naming rules.
Editor setup
loft ships its own editor support, so you do not need to pretend .loft is Rust:
- VS Code — the extension in
editors/vscode/of the repository gives syntax highlighting, snippets, and Run buttons for the interpreted (F5) and native (Ctrl+F5) paths. Build and install it withcd editors/vscode && npm install && vsce package && code --install-extension loft-0.1.0.vsix. It is not on the marketplace yet. - Any LSP editor —
loft-lspis a language server built from this repository (cargo build --release --bin loft-lsp). It answers diagnostics, completion, go-to-definition, references, hover, document symbols, semantic tokens, inlay hints, rename and formatting over stdio.loft-dapis the matching debug adapter. - Vim / Neovim —
editors/nvim/adds filetype detection and syntax highlighting; point your LSP client at theloft-lspbinary for*.loftfiles. - In the browser — the playground runs loft with nothing installed.
Next steps
- Read the language overview starting with Keywords and control flow.
- See vs Rust if you are coming from Rust.
- Browse the Standard Library reference for built-in functions.
- Check the Roadmap for what comes next.