Loft

Build small games and interactive things — share a link, anyone plays.

A statically-typed scripting language inspired by Rust.

v0.8.3

Brick Buster — a complete loft game
Built with loft

Brick Buster

A complete arcade game — hand-designed levels, cel-shaded sprites, heart lives, round ball with a velocity-directional squash, rising balloon bombs, fireball after-images, chiptune music. Written in loft, runs in your browser.

No install

Live playground

Type a few lines of loft code. Press run. See output. That is the whole tutorial.

24 demos

Graphics gallery

From a hello-triangle to physically-based rendering with shadows — all running live in WebGL.

Welcome to Loft! Loft is a concise, statically-typed language designed to be safe and easy to embed in larger Rust projects. It is great for scripting game logic, configuration, data transformations, and anywhere you want a friendly language backed by a fast Rust runtime.

These documentation pages are your guided tour — each page is also a live test, so every example you see has already been verified to work exactly as shown. The best way to get started is to read the pages in order. This first page introduces the handful of ideas that shape every other part of the language.

Getting Started

Install

Get loft running and write your first Loft program in minutes.

Roadmap

Planned features for version 1.0 and beyond, with syntax previews.

Language

vs Rust

Key differences for developers coming from Rust.

vs Python

Key differences for developers coming from Python.

Performance

Benchmark results across interpreter, native, wasm, and Rust.

Keywords

Keywords and control flow

Texts

Text handling and functions

Integers

Whole numbers and arithmetic

Boolean

True, false, and null

Float

Floating point operations and math functions

Functions

User defined functions

Vector

Vector creation and use

Structs

Grouping related data with structs

Enums

Named choices with optional data

Sorted

Keeping records in sorted order automatically

Index

Fast lookup and range queries over records

Hash

Instant key lookup with a hash table

File

File system — text, binary, and directory access.

Lexer

Lexer library.

Parser

Parsing Loft source code programmatically

Libraries

Library system — importing and using external loft modules.

Store Locks

Immutability with const and runtime store locks

Parallel execution

Parallel processing with the par(...) for-loop clause

Logging

Recording events with the logging system

Time

Wall-clock time and elapsed time

Safety

Language traps and how to avoid them

JSON

JSON parsing and generation

Generics

Generic functions

Closures

Capturing variables from the surrounding scope

Coroutines

Lazy sequences with generators and yield

Tuples

Grouping values without defining a struct

Match

Pattern matching with match expressions

Formatting

Format strings — interpolation, alignment, and number bases

Standard Library

Types

Primitive type conversions and null checks

Interfaces

Math

Arithmetic, rounding, and trigonometry

exp / ln / log2 / log10

min / max / clamp

Text

String manipulation and formatting

Collections

Vector, sorted, index, and hash operations

Output and Diagnostics

Print, assert, and diagnostic functions

Vector aggregates

Field iteration support types

File System

File, directory, and path operations

Environment

Command-line arguments and program state

Time