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 — the same version --native needs to compile your programs. Install it 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 via rustc and run it (without Rust on PATH, loft says so and interprets) |
--native-release | Same as --native with full optimisations (slower to compile, fastest to run) |
--native-emit [out.rs] | Write the generated Rust source to a file without compiling it |
Running your program as a native binary
loft myprogram.loft already compiles through rustc when it can find it, and interprets when it cannot — you do not have to choose, and the answer is the same either way. Compiling takes a few seconds the first time and then runs compute-heavy code many times faster than interpreting (Performance measures native against hand-written Rust). Ask for one on purpose when you want to:
loft --native myprogram.loft
To see the generated Rust code without running it:
loft --native-emit myprogram.rs myprogram.loft
cat myprogram.rs
Native runs need rustc on your PATH — the same Rust you built loft with. Without it, --native says so and interprets instead. A downloaded release carries no native runtime, so it always interprets.
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.