Install

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 (Rust 1.82 or later). 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

The quickest way to get the loft binary on your PATH:

cargo install --git https://github.com/jjstwerff/loft --bin loft

This compiles loft in release mode and places the binary in ~/.cargo/bin/, which is already on your PATH if you used rustup.

Build locally

Clone the repository and build with Cargo:

git clone https://github.com/jjstwerff/loft
cd loft
cargo build --release

The binary is at target/release/loft. Copy it anywhere on your PATH, for example:

cp target/release/loft ~/.local/bin/

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("");
}

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 syntax highlighting extensions are planned. In the meantime:

Next steps