Luau ported from C++ to pure Rust (passes all tests)
luaur is a pure-Rust port of Luau (Roblox's typed Lua) - lexer, parser, bytecode compiler, register VM, type checker, and the CLIs. It builds for wasm32-unknown-unknown with no C toolchain, so you can run and type-check Luau right in the browser: https://pjankiewicz.github.io/luaur/
About 2 weeks ago on a whim I decided to do this. Why? I wanted to use Luau but in a way that's first-class in the Rust ecosystem and targets wasm32-unknown-unknown. Lua is a great embeddable language and it serves me well as a scripting language for AI agents - and being able to type-check a script before I execute it is another reason it's a good fit.
That's the why. Here comes how.
Since the LLM boom started I fantasised about porting large projects to Rust with a systematic approach. The cleanest one is graph-based: build a graph of the source project, sort it topologically to fix the translation order, and keep expanding the context with the items you've already translated. Then you can translate the whole thing in one clean sequence. That's a well-known "skeleton" strategy - that was assumption one.
Assumption two: do the porting with small, cheap models guided by the graph harness. With the right context I believed even small models produce passable output - we've leaned so hard into multi-turn frontier agents that it's easy to forget how much a small model can do when the context is right.
With both assumptions in place, building the tool and filling the skeleton took about 2 weeks of not-very-intense work - mostly monitoring and nudging Claude and Codex (I used them interchangeably) to stay on target. Sometimes the agents forgot they were supposed to do batch parallel translation with the cheap models. Claude or Codex would say "the cheap models are clearly too weak, let me translate this myself." My nudge was always the same: use the translation tool, fix the systematic context errors. In 9 out of 10 cases the problem was the context - the hallucinations and bugs were missing-context errors, not model quality.
After a few days a stable loop emerged:
- pick a module
- translate it in a batch
- fix it in a batch (rotate the models)
- let the agent fix the rest until the project is green
- repeat
The last stretch was purely agentic: setting up the crates, fixing tests, getting it working across platforms.
Now - does auto-translated code actually work? That's the part I cared about proving, so the oracle is Luau's own tests, not mine:
- 5,347 of Luau's own unit tests, ported to Rust, pass.
- 293/293 upstream conformance scripts run byte-identically on the Rust VM.
- a byte-exact bytecode differential: bytecode compiled by C++ Luau runs on the Rust VM with identical results.
- the safe API layer (luaur-rt, mlua-style) passes 225/235 of mlua's own test suite byte-for-byte; the other 10 are documented Lua-vs-Luau differences.