Lua
termKept in this browser · My desk
The embeddable scripting language designed in 1993 at Tecgraf, the Pontifical Catholic University of Rio de Janeiro (PUC-Rio), by Roberto Ierusalimschy, Luiz Henrique de Figueiredo and Waldemar Celes; its name is the Portuguese word for the Moon.
Its creators tie it to the Brazilian market reserve (1977 to 1992), under which Tecgraf's client Petrobras could not easily buy software abroad; Lua grew from two little languages, DEL and SOL, and its first implementation was finished by July 1993.
What it is. Lua is a small scripting language made to be embedded: a library written in ANSI C (the American National Standards Institute dialect) that a host program links in and calls, plus a stand-alone interpreter. Lua.org calls it powerful, efficient, lightweight and embeddable, distributes it as free software under the MIT licence, and notes that the name is neither an acronym nor an abbreviation but the Portuguese word for the Moon.
How it works. Lua has eight basic types: nil, boolean, number, string, table, function, userdata and thread. Tables are its only data-structuring mechanism, and the language has no separate array type; since Lua 5.0 each table keeps a hash part and an array part, and the implementation detects tables used as arrays and stores their integer-indexed values in the array part automatically. Lua compiles to bytecode for a virtual machine (VM), stack-based at first and register-based since Lua 5.0, which its authors call the first register-based VM in wide use; the 2005 paper on Lua 5.0 counts 35 instructions, each 32 bits long. Functions are first-class values with lexical scoping, implemented with upvalues, and Lua 5.0 added asymmetric coroutines; incremental garbage collection came with Lua 5.1.
Origin. Lua was born in 1993 at Tecgraf, the computer graphics technology group of the Pontifical Catholic University of Rio de Janeiro (PUC-Rio), from two little languages written for Petrobras, DEL for data entry and SOL for a configurable report generator of lithology profiles. Its creators, Roberto Ierusalimschy, Luiz Henrique de Figueiredo and Waldemar Celes, tie it to the Brazilian market reserve, under which Petrobras could not easily buy customized software abroad. By July 1993 Waldemar had finished the first implementation as a course project supervised by Roberto. Lua 2.1 was released as unrestricted free software; Lua 3.0 (1997) unified Lua and C functions into one type; booleans and threads arrived with Lua 5.0 in 2003. The language's history was presented in 2007 at the third History of Programming Languages conference (HOPL III) of the Association for Computing Machinery (ACM), and it won the Front Line Award 2011 from Game Developers Magazine.
Versions and size. Lua.org dates Lua 5.0 to 11 April 2003, Lua 5.4 to 29 June 2020 and Lua 5.5 to 22 December 2025, whose main new features are declarations for global variables, named vararg tables, more compact arrays and major garbage collections done incrementally; the current release on 23 November 2026 was Lua 5.5.1 of 3 August 2026. Its whole source is about 32,000 lines of C, and on 64-bit Linux the interpreter with all standard libraries takes 293K and the library 484K; in 2007 the authors counted around 17,000 lines.
In practice. Lua.org lists uses from Adobe Lightroom, of which the HOPL paper says over 40 per cent, around 100,000 lines, was written in Lua, and games such as World of Warcraft and Angry Birds, to Ginga, the middleware of Brazilian digital television; it calls Lua the leading scripting language in games, and a 2003 poll on gamedev.net already ranked it first there. Roblox's Luau is a derived language, backwards compatible with Lua 5.1, with a gradual type system, an optional just-in-time (JIT) compiler and a deliberately reduced, sandboxed interface. Redis, a persistent key-value database, runs Lua scripts too, as its most serious Lua flaw showed.
What goes wrong. Embedding makes the host responsible for what a script may touch, and the manual is plain about the sharp edges. Lua does not check the consistency of binary chunks, and maliciously crafted binary chunks can crash the interpreter; the mode parameter of load can refuse them. The debug library violates basic assumptions, such as that local variables cannot be reached from outside a function, and can compromise otherwise secure code; os.execute hands a command to the system shell. A sandbox therefore depends on what the host leaves out. The Common Vulnerabilities and Exposures (CVE) entry CVE-2022-0543 showed the cost: because of a Debian packaging issue, the Redis server shipped by Debian allowed a Lua sandbox escape leading to remote code execution; the National Vulnerability Database (NVD) scored it 10.0, and the Cybersecurity and Infrastructure Security Agency (CISA) added it to its Known Exploited Vulnerabilities catalogue on 28 March 2022.
The Brazilian angle. Lua is entirely designed, implemented and developed in Brazil, as its Portuguese page says, and it is developed today at LabLua, a laboratory of PUC-Rio's Department of Computer Science.
Neighbours. Bytecode and interpreter, the machinery it runs on; programming-language, the family it belongs to; C, the language of its implementation and of the programs that embed it; jit-compilation, which Luau applies to it.
Also known as: lua language, linguagem lua
Sources
- Ierusalimschy, de Figueiredo and Celes, The Evolution of Lua, HOPL III 2007: born in 1993 at Tecgraf, PUC-Rio, for Petrobras under the market reserve; DEL and SOL; first implementation by July 1993; stack VM, register VM from Lua 5.0 (read 2026-11-23)
- Lua.org, About: designed, implemented and maintained at PUC-Rio; born at Tecgraf, now LabLua; 'Lua' means 'Moon' in Portuguese; Ginga, Lightroom, games; Lua 5.5.1 (read 2026-11-23)
- Lua.org, página em português: 'Lua é inteiramente projetada, implementada, e desenvolvida no Brasil' (read 2026-11-23)
- Roberto Ierusalimschy, Luiz Henrique de Figueiredo and Waldemar Celes, The Implementation of Lua 5.0, Journal of Universal Computer Science, 2005 (read 2026-11-23): eight basic types; tables with a hash part and an array part; the first register-based VM in wide use; 35 instructions of 32 bits; closures with upvalues; asymmetric coroutines; incremental collection planned for Lua 5.1
- Lua.org, Version history (read 2026-11-23): Lua 5.0 on 11 April 2003, Lua 5.4 on 29 June 2020, Lua 5.5 on 22 December 2025 with global declarations, named vararg tables, compact arrays and incremental major collections; current release Lua 5.5.1 of 3 August 2026
- Lua 5.5 Reference Manual (read 2026-11-23): Lua does not check the consistency of binary chunks, which can crash the interpreter, and load's mode parameter can refuse them; the debug library can compromise otherwise secure code; os.execute
- NIST National Vulnerability Database, CVE-2022-0543, API record (read 2026-11-23): a Debian-specific packaging issue in Redis allowing a Lua sandbox escape and remote code execution; CVSS 10.0; added to CISA's Known Exploited Vulnerabilities catalogue on 28 March 2022
- Luau, home page (read 2026-11-23): a small, fast, embeddable language based on Lua with a gradual type system; backwards compatible with Lua 5.1; optional JIT on x64 and arm64; a sandboxed, reduced API