Wax

Interpreted, Embeddable, Sandboxed.

Implemented in Rust.

  • A scripting language for games and apps, sealed off from the program that runs it
  • Has good performance for its class
  • Embed it from Rust or C, with scripts compiled ahead of time if you like
  • Open source, under Apache 2.0 with the LLVM exception

A script

The top level runs once, when the script is loaded. After that the host calls the script's procedures, here on_hit, whenever its own events happen.

show_msg is a door: it exists only because the host opened it. A script can't reach anything else.

Read the standard →
mut hp = 30
show_msg("loaded")

proc on_hit[amount: Whole]
    hp = max(_ - amount, 0)
    show_msg("hit for {amount}, {hp} left")
end

What Wax is for

Sealed by design

A Wax script can reach nothing outside itself except the doors its host opens: no files, no network, no clock, unless the program embedding it says so. Steps and memory are capped per call.

  • doors
  • step limits
  • memory caps
Learn more →

Has good performance for its class.

Ngin1, the first official interpreter, has good performance for its class. It has no garbage collector, so it has no pauses either.

  • register VM
  • no GC
  • value semantics
Learn more →

Embeddable

Load a script, give it doors, call its procedures when your game's events happen. From Rust, or from C and anything that speaks it.

  • Rust API
  • C API
  • wax.h
Learn more →

Ahead of time

Compile scripts once with wax build into .waxc files, verified every time they load and optionally signed, so a game ships only what you built.

  • .waxc
  • ML-DSA signing
  • load cache
Learn more →
use wax::{Doors, Limits, Script};

// The doors this script may use: here, only one
let mut doors = Doors::new();
doors.add("show_msg", |text: String| println!("{text}"))?;

// How many steps one call may take, and how much memory
let limits = Limits { steps: 1_000_000, memory: 1 << 20 };

// Loading checks the whole script, then runs its top level
let mut goblin = Script::load("goblin.wax", &source, &doors, limits)?;
goblin.call::<()>("on_hit", (10,))?;

Embed it in a few lines

Your program decides which doors exist, how many steps a call may take, and how much memory a script may hold. Then it loads the script and calls it whenever it likes.

Getting started →

Ngin1's times

Normal benchmarks, written plainly · Apple M5, macOS 27.2.1 · release build · mean of 10 timed runs after warming up · every answer checked first · lower is faster

fib(32), recursive30.6 ms
n-body, 100,000 steps64.8 ms
spectral-norm, size 20017.9 ms
fannkuch-redux, 9103.0 ms
word count, 500,000 words26.4 ms
text building, 20,000 joins337 µs
binary-trees, depth 14100.4 ms