Luau
Fast embeddable scripting language based on Lua
Replaces —
Who it's for
Game studios embedding a scripting language for modding or gameplay logic get Luau's sandboxed execution, typed API contracts, and JIT-accelerated performance. Its adoption in Alan Wake 2, Warframe, and Second Life demonstrates fitness for commercial game titles.
The game engine already has a deep investment in a different scripting runtime (e.g. Wren, AngelScript, or Lua 5.4 with incompatible extensions).
Luau is the primary scripting language for Roblox and is the language Roblox Studio plugins are written in. Developers targeting the Roblox platform use Luau directly, with tooling like luau-lsp providing editor autocomplete backed by the type inference engine.
Applications needing a safe, user-facing scripting layer can embed Luau via its extended C API, use `luaL_sandbox` to isolate untrusted scripts, and expose typed host APIs to users who benefit from autocomplete without the host needing to trust user code.
The host application is already deeply coupled to a specific Lua 5.x version and cannot absorb the API caveats documented in the Luau migration notes.
The problem
Lua is widely used as an embeddable scripting language, but its lack of static typing, limited tooling, and aging runtime leave teams without editor-assisted error detection, autocomplete, or modern performance optimizations. Luau addresses this by layering a gradual type system and a rewritten high-performance runtime on top of the familiar Lua 5.1 syntax and C API, without requiring applications to abandon existing Lua bindings.
How it works
Luau's type system supports type refinements and type functions, and is powered by a type inference engine that aims to catch program errors and provide autocomplete with minimal manual annotations. Typing is opt-in, so existing untyped scripts continue to work.
The interpreter is completely rewritten from the Lua 5.1 original and paired with a fast bytecode compiler and an optimized, incremental garbage collector. An optional JIT compiler targets x64 and arm64 architectures and supports plugins that extend native code generation to embedder-defined types.
Luau limits the exposed API surface by default and provides `luaL_sandbox` and `luaL_sandboxthread` to isolate individual scripts' global tables, enabling embedders to safely run untrusted user code. The extended C API adds better coroutine and yielding support and more performant tagged userdata.
`luau-analyze` inspects source files and reports type errors and lint warnings based on file-level `--!` comment flags or `.luaurc` configuration files. A community-maintained language server (`luau-lsp`) builds on it for use with text editors.
Luau preserves the Lua 5.1 runtime API so existing C bindings remain largely compatible. It also selectively incorporates features from later Lua revisions; all post-5.1 features and their support status are documented on the Luau website.
Alongside the runtime and analyzer, the project is building out package management, linting, code transformation, documentation generation, and language server and debugger support, targeting a self-contained development environment.
Features
- Gradual type system with type inference
- High-performance runtime
- Safe sandboxed embedding
- Command-line type checker and linter
- Lua 5.1 backwards compatibility
- Full developer toolchain
How to install
# macOS brew install luau # Arch Linux pacman -Syu luau # Alpine Linux apk add luau # Build from source (CMake) mkdir cmake && cd cmake cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build . --target Luau.Repl.CLI --config RelWithDebInfo
Recommended for this setup
Strengths
- Battle-tested at Roblox scale: Luau powers game logic written by Roblox's large developer community and is used inside Roblox Studio itself. This production history at significant scale validates the runtime's stability and performance claims beyond typical research languages.
- Minimal annotation overhead: The type inference engine is designed to derive types automatically, so developers can get autocomplete and error detection without annotating every function signature. Gradual typing means teams can adopt safety incrementally.
- Drop-in replacement path for Lua 5.1 embedders: Because the C API is largely preserved from Lua 5.1, existing embedder bindings require few or no changes to run on Luau. Teams get JIT compilation, incremental GC, and type checking without a rewrite of their host application.
- Cross-platform JIT with embedder extensibility: The optional JIT targets x64 and arm64 and exposes a plugin interface so embedders can extend native code generation to their own userdata types, a capability not present in stock Lua.
Trade-offs
- Not a full superset of Lua 5.2+: Luau deliberately diverges from Lua design decisions made after 5.1. Teams migrating scripts written against Lua 5.2, 5.3, or 5.4 features will need to audit compatibility; the Luau website documents each post-5.1 feature and its support status.
- Ecosystem is smaller than stock Lua: LuaRocks and the broader Lua package ecosystem target standard Lua runtimes. Package management for Luau is still being built out, so teams relying on existing Lua libraries may encounter integration friction.
- JIT is optional and target-limited: The JIT compiler only runs on x64 and arm64. Deployments on other architectures, or embedders that do not opt in, fall back to the bytecode interpreter.
Tech stack
FAQ
Yes. Luau is designed to be backwards compatible with Lua 5.1 and preserves the Lua 5.1 C API so existing bindings remain largely compatible. It selectively incorporates features from later Lua versions but is not a full superset of Lua 5.2 or later.
You can download compiled `luau` and `luau-analyze` binaries from the GitHub releases page and add them to your PATH. Package manager options include `brew install luau` on macOS, `pacman -Syu luau` on Arch Linux, `apk add luau` on Alpine Linux, and `emerge dev-lang/luau` on Gentoo.
No. Luau uses a gradual type system, so typing is entirely optional. The type inference engine will derive types where it can, and untyped scripts continue to run without modification.
`luau` is the REPL and script runner. `luau-analyze` is a standalone type checker and linter that reports errors and warnings from source files without executing them. It reads configuration from `--!` comments or `.luaurc` files and is the backend for the community `luau-lsp` language server.
No. The optional JIT compiler currently targets x64 and arm64 architectures. Deployments on other platforms use the bytecode interpreter, which is itself a rewritten, high-performance implementation compared to the original Lua 5.1 interpreter.