Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 25, 2026·3 min de lecture

Luau — Fast Embeddable Scripting Language Based on Lua

Luau is a small, fast scripting language derived from Lua 5.1, extended with a gradual type system, type inference, and performance optimizations developed by Roblox.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Luau
Commande d'installation directe
npx -y tokrepo@latest install 533e17d4-8847-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Luau (pronounced "Lu-ow") started as an internal fork of Lua 5.1 at Roblox to support millions of developers building games on the platform. It adds a gradual type system, better performance, and modern language features while maintaining backward compatibility with standard Lua.

What Luau Does

  • Provides a Lua-compatible scripting language with gradual typing
  • Performs type inference to catch errors without requiring annotations
  • Compiles to a custom bytecode with a fast interpreter and JIT compiler
  • Embeds easily into C/C++ host applications via a simple API
  • Supports sandboxing for safe execution of untrusted scripts

Architecture Overview

Luau consists of a compiler that produces bytecode, a bytecode interpreter, and a native code generator for x64 and ARM64. The type checker runs as a separate analysis pass and supports both strict and nonstrict modes. The runtime is designed for low-latency environments, with incremental garbage collection tuned for interactive applications.

Self-Hosting & Configuration

  • Build from source using CMake on Linux, macOS, or Windows
  • Embed by linking the Luau library and initializing a Lua state
  • Use luau_compile() to compile source to bytecode ahead of time
  • Enable the type checker with --!strict or --!nonstrict directives
  • Configure sandboxing by restricting available standard library functions

Key Features

  • Gradual type system with inference eliminates common runtime errors
  • Native code generation (JIT) for x64 and ARM64 platforms
  • Backward compatible with Lua 5.1 syntax and semantics
  • Incremental garbage collector tuned for real-time applications
  • String interpolation, compound assignment, and other syntax improvements over Lua

Comparison with Similar Tools

  • Lua 5.4 — Standard Lua lacks a type system and JIT; Luau adds both while staying compatible
  • LuaJIT — Faster JIT for Lua 5.1 but no type system; Luau trades peak throughput for type safety
  • Teal — Typed Lua that transpiles to Lua; Luau is a native implementation with its own runtime
  • MoonScript — CoffeeScript-like syntax for Lua; Luau extends Lua syntax without changing its feel

FAQ

Q: Is Luau only for Roblox development? A: No. Luau is open source and can be embedded in any C/C++ application. It is used outside Roblox in game engines and other projects.

Q: Can I run existing Lua 5.1 scripts in Luau? A: Most Lua 5.1 code runs without changes. Some differences exist in string patterns and coroutine behavior.

Q: Does Luau support LuaRocks packages? A: Not directly. LuaRocks packages targeting the C Lua API need adaptation for the Luau API differences.

Q: How does the gradual type system work? A: Type annotations are optional. Luau infers types where possible and only reports errors where it can prove a type mismatch. Strict mode requires all types to be resolvable.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires