Lua (programming language)
Lua (programming language)
Lua is a lightweight, high-level, multi-paradigm programming language designed primarily for embedded use in applications. Created in 1993 at the Pontifical Catholic University of Rio de Janeiro in Brazil, Lua combines procedural, functional, and object-oriented features with a simple yet powerful C API. Its name means "moon" in Portuguese.
Lua is widely used as a scripting language in video games, web servers (e.g., NGINX with OpenResty), image processing (ImageMagick), and embedded systems. Its reputation for speed, small footprint, and ease of integration has made it a popular choice for extending software.
Features
- Lightweight and fast: Lua has a tiny memory footprint (under 200KB for the core interpreter) and is one of the fastest interpreted languages.
- Dynamic typing: Variables are dynamically typed, with eight basic types: nil, boolean, number, string, function, userdata, thread, and table.
- Tables: The sole data‑structuring mechanism; tables serve as arrays, dictionaries, objects, and modules.
- First‑class functions and closures.
- Automatic memory management via generational garbage collection.
- Metatables and metamethods: Allow customizing behavior (operator overloading, inheritance).
- Coroutines: Support cooperative multitasking.
- Portable, embeddable C API: A single header and library make it trivial to integrate Lua into C/C++ applications.
History
Lua was developed by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes to provide a flexible scripting language for a petroleum data‑processing system. Early versions (1.0–2.x) were released in the 1990s. Lua 3.1 (1998) introduced lexical scoping. Lua 4.0 (2000) added full syntax for object‑oriented programming. The major Lua 5.0 (2003) brought coroutines, metatables, and a new registry. Lua 5.1 (2006) introduced modules, the C API for upvalues, and a standard library with weak tables. Lua 5.2 (2011) added `goto`, bitwise operators, and ephemeron tables. Lua 5.3 (2015) introduced integers and a basic UTF‑8 library. Lua 5.4 (2020) added generational GC, const variables, and to‑close variables.
Usage
Lua is the de‑facto scripting language for the Roblox game platform. It is also used in World of Warcraft, Angry Birds, Adobe Photoshop Lightroom, and the LÖVE game framework. Its reference implementation is written in C; LuaJIT is a popular just‑in‑time compiler for performance‑critical applications.
See also
- Luau (programming language) – a derivative used in Roblox
- MoonScript – a coffee‑script‑like language that compiles to Lua
- LuaTeX – a TeX engine embedding Lua