ulua is a pure-Rust implementation of the Luau language (Roblox's typed Lua derivative), covering the lexer, parser, bytecode compiler, register VM, garbage collector, bidirectional type inferencer, and A64/X64 native JIT code generation.
Current focus: We are actively refactoring transliteration artifacts from earlier C++ ports, eliminating raw pointers, removing warning suppressions, and shrinking unsafe boundaries. Systematic microarchitectural tuning will follow once idiomatic Rust patterns are stabilized.
In-Memory Benchmark Comparison: Tested 16 compute-heavy benchmarks in a single process on Apple Silicon (M2 Max, arm64), taking median runtimes in milliseconds (ms):
Benchmark (ms) ulua Luau C++ ulua JIT Luau JIT LuaJIT Lua5.4
-----------------------------------------------------------------
binarytrees 105.0 135.7 70.4 89.9 49.6 116.9
coroutines 83.1 108.2 82.8 130.8 26.1 145.3
fannkuch 33.1 28.8 7.9 7.8 3.6 22.6
fib 83.7 92.6 35.2 34.8 8.4 74.9
mandel 93.2 93.5 25.4 23.3 11.0 56.2
matmul 51.8 45.8 12.2 12.5 4.3 38.3
nbody 93.4 95.7 92.5 92.7 4.8 72.1
spectralnorm 79.9 74.6 20.7 19.9 2.2 90.9
tablesort 64.5 66.9 63.8 67.4 115.2 241.1
-----------------------------------------------------------------
GeoMean ratio 1.00 1.02 0.52 0.57 0.16 1.17
- Interpreter: ulua tracks upstream C++ Luau throughput (1.0 vs 1.02 GeoMean) and is ~17% faster than Lua 5.4.
- JIT: native compilation cuts runtime by ~48% (0.52 GeoMean), matching C++ Luau JIT (0.57).WebAssembly Playground: Without C/C++ build dependencies, ulua compiles directly to wasm32. A live browser playground is running client-side at https://webc-site.github.io/ulua
Quick example:
use ulua::prelude::*;
fn main() -> Result<()> {
let lua = Lua::new();
lua.load("print('Hello from ulua')").exec()?;
#[cfg(feature = "jit")]
{
lua.enable_jit(true)?;
let res: i64 = lua.load("local s = 0; for i = 1, 1000 do s += i end; return s").eval()?;
assert_eq!(res, 500500);
}
Ok(())
}