Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

rut

rut is a small, statically typed, embeddable scripting language with Rust-flavored syntax, implemented in Rust. It is designed to be the scripting layer of host applications — typically UI apps — replacing JavaScript engines with a language whose type system is not erased: types exist at runtime, drive bytecode specialization, and make the host boundary fully checked.

Syntax feels like TypeScript (simple enum, the class shape, anonymous functions), with Go-flavored structural interfaces (interface + satisfaction by having the members) and Kotlin-style structured concurrency (async/await over poll-based futures). The runtime is a bytecode VM with no JIT — deterministic, fuel-metered, and small enough to embed everywhere a wasm binary fits.

use ink::{ Logger };
use pouch::{ Vec };

fn sieve(limit: i32) -> Vec<i32> {
    let mut marks = Vec<u8>::filled(0, limit + 1);
    let primes: Vec<i32> = Vec::new();
    for (let mut i = 2; i <= limit; i += 1) {
        if (marks[i] == 0) {
            primes.push(i);
            let mut m = i * i;
            while (m <= limit) {
                marks[m] = 1;
                m += i;
            }
        }
    }
    return primes;
}

entry fn main() {
    let log = Logger("sieve");
    let primes = sieve(100);
    log.info(f"{primes.len()} primes up to 100, last={primes[primes.len() - 1]}");
}

Where to go next

If you want to…Read
Use rut in your Rust project (and the temporary-run CLI)Quick Start
Learn the language hands-onthe Tutorial
Understand why the language is shaped this wayCore Concepts
Study complete programsExamples
Look up exact rulesthe Reference

The book is also served live at https://rut.hpp2334.com, and the wasm playground — where every snippet on this site runs in the browser — lives at https://playground.rut.hpp2334.com.

The repo

crates/     the implementation: lexer, parser, compiler, VM, std, CLI, wasm
rut/        the in-tree rut packages (core, pouch, ink, json, http, …)
examples/   seven runnable end-to-end projects
demo/       the wasm playground
docs/       this book (built with mdbook)

Build the CLI binary from a checkout:

cargo build --release -p rut-cli   # the `rut` binary: run / fmt / pack / dump

No checkout? cargo +nightly-2026-07-15 install --git https://github.com/hpp2334/rut.git --locked rut-cli puts the same binary on your PATH (Quick Start).

That binary is the temporary-run lane — running module directories and bundles, fmt, dump, pack. To use rut in your own project, depend on the engine crates as a git dependency — the crates are not on crates.io (Quick Start).

License

MIT OR Apache-2.0.