Skip to main content

Compare · Embedded languages

Stof vs Lua.

Lua is a scripting language for your own app, and sandboxing it is your job. Stof is a document that carries its data, logic, and state over the wire, sandboxed by default, the same in Rust, JavaScript, and Python.

Lua

A small, fast scripting language embedded in apps and games through its C API.

Stof

Just-in-time software: data and logic together, in one document that runs anywhere, sandboxed, in Rust, JavaScript, and Python.

What happens when…

When…LuaStof
A model writes the logicPossible, with care: you build the sandbox by loading the code with a restricted environment and leaving out unsafe libraries.Parse it as untrusted (nothing runs while it parses), seal it to what you list, and call it. Or describe the function as an intent, and a model writes it, checked by your examples.
The code loops foreverBy default, there is no limit to memory or computation. Limits come from a custom allocator and debug hooks you add.Every call has a time and a memory limit (2 minutes and 256 MB unless you change them), and a sealed part can have its own, like 50 ms.
The logic has to run somewhere elseSend the source, and the data separately. Precompiled chunks aren't portable across architectures, and their format can change between Lua versions.Send the doc as text or compact binary: its data, its functions, and its current state, in one payload. The other side gives the same answer, in Rust, JavaScript, or Python.
Where the data livesSomewhere else: Lua code works on tables your app passes in.With the logic, in the same document. Any JSON is already a Stof document.
Your app is TypeScript, Python, or RustThrough a binding for each host language, each with its own API.One runtime, with packages for Rust, JavaScript and TypeScript (WebAssembly), and Python. The same doc runs in each.
What you send to move the workSource is small too. Server B needs the same embedding (the libraries and functions your app gives the script), and the state goes separately.The text itself: fn hello() { pln('hello world'); } is 34 bytes. A doc brings its data and state the same way, and server B, with the Stof package, runs it the same as server A.
SpeedOne of the fastest interpreters around. For heavy number crunching, Lua is faster.Fast for decisions (rules, pricing, tools), not tight loops over millions of items. Hand those to your app as functions.

Checked December 3, 2026. Sources: Lua 5.4 manual · lua-users: sandboxes · lua-users: security · luac. Something out of date? Tell us.

What you'd still build.

On top of Lua
  • The sandbox: a safe environment, and no unsafe libraries
  • Memory and time limits
  • A way to ship the data with the logic
Already in Stof
  • A sandbox that is on by default, with seals for code from elsewhere
  • Time and memory limits on every call
  • Data, logic, and state in one document you can send anywhere

Choose Lua for scripting your own app or game, where speed matters most and the scripts are yours.

Stof vs Lua, answered.

Isn't Lua already safe to embed?

It's easy to embed, and you can sandbox it, but that's work you do: Lua's own community notes that a restricted environment alone doesn't limit memory or computation. Stof starts with no access and with limits on every call.

Is Stof faster than Lua?

No. Lua is one of the fastest interpreters there is. Stof is fast enough for the logic it's for (decisions that return), and it brings the sandbox, types, units, and portability with it.

Also compared.

Every comparison →

Try it in a minute.

npm i @formata/stof
pip install stof
cargo add stof