← New search

Programming Languages

Lua (programming language)

Lua is a lightweight, high-level, multi-paradigm programming language designed primarily for embedded use in applications. Created in 1993 by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes at the Pontifical Catholic University of Rio de Janeiro (PUC-Rio) in Brazil, Lua combines procedural programming with powerful data description features based on associative arrays and extensible semantics. Its name means "moon" in Portuguese, reflecting its status as a satellite of the host application. Lua is widely used in game development, embedded systems, and as a scripting language in software such as Adobe Photoshop Lightroom and Angry Birds.

1993
Year of first release
Initial release
~290 KB
Size of the Lua 5.4 reference interpreter
Source size
5.4
Latest stable version (as of 2024)
Current version
MIT
License
License
1

Design and Features

Lua's design emphasizes simplicity, efficiency, and portability, making it an ideal extension language. Its core data structure is the table, which serves as both an array and an associative array, enabling flexible data modeling. Lua supports multiple programming paradigms, including procedural, object-oriented (via metatables), functional, and data-driven programming. The language features automatic memory management with incremental garbage collection, first-class functions, and lexical closures. Notably, Lua has a small footprint—the reference interpreter compiles to about 290 KB on most platforms—and can be embedded into applications with minimal overhead. Its syntax is intentionally similar to Pascal and C, making it accessible to a wide range of programmers. Lua's extensibility is a cornerstone: C APIs allow seamless integration, and metatables enable powerful customization of table behavior, such as operator overloading and inheritance.

2

History and Evolution

Lua was born out of a need for a flexible configuration language for two Brazilian software projects: a data-entry program for the Brazilian National Bank and a graphics package for the Pontifical Catholic University. The language was first released in 1993, and its development has been continuous since then. The team at PUC-Rio, led by Roberto Ierusalimschy, has maintained a steady release cycle, with major versions introducing significant features. Lua 5.0 (2003) brought the registry and multiple states, while Lua 5.1 (2006) added the module system and the goto statement. Lua 5.2 (2011) introduced integer subtypes and the bit32 library. Lua 5.3 (2015) added native integer support and a basic UTF-8 library. The latest version, Lua 5.4 (2020), introduced const variables, userdata attributes, and a new generational garbage collector. The language's evolution has been conservative, prioritizing stability and backward compatibility, which has contributed to its enduring popularity in embedded systems.

3

Applications and Ecosystem

Lua's primary niche is as an embedded scripting language, and it has been adopted by a wide range of software. In the gaming industry, Lua is the scripting language of choice for many engines, including LÖVE, Corona SDK, and the popular World of Warcraft add-on system. It is also used in non-gaming applications such as Adobe Photoshop Lightroom, Wireshark, and Nginx (via OpenResty). The language's portability has made it a staple in embedded systems, including routers and set-top boxes. Lua's ecosystem includes a rich set of libraries and frameworks, such as LuaRocks (a package manager), LÖVE (a 2D game engine), and Torch (a machine learning library). The language's simplicity has also made it a popular teaching tool, and it is often used to introduce programming concepts. Additionally, Lua has been used in scientific computing, with bindings to C and Fortran libraries, and in the Internet of Things (IoT) domain due to its low resource requirements.

4

Lesser-known aspects

Beyond its mainstream uses, Lua has several notable but lesser-known facets. The language's name, meaning "moon" in Portuguese, was chosen to reflect its role as a satellite of the host application, and it is not an acronym. Lua's reference implementation is written in clean ANSI C, and it compiles on virtually any platform, including those with limited resources. A unique feature is the ability to use multiple Lua states within a single application, allowing for isolated execution environments. Lua's metatable mechanism is powerful enough to implement prototype-based inheritance, similar to JavaScript, but with more flexibility. The language has been used in space exploration: the Robonaut 2 project at NASA used Lua for its control software. Additionally, Lua has a strong presence in the digital audio workstation (DAW) community, with applications like REAPER using it for scripting. The Lua mailing list, known for its friendly and knowledgeable community, has been active since the language's inception, and the language's reference manual is renowned for its clarity and precision.

Glossary

Table
The primary data structure in Lua, used for arrays, dictionaries, objects, and more.
Metatable
A table that defines behavior for operations on another table, enabling operator overloading and inheritance.
First-class functions
Functions that can be stored in variables, passed as arguments, and returned from other functions.
Garbage collection
Automatic memory management that reclaims memory occupied by objects no longer in use.
Embedded scripting
Using a scripting language within a host application to provide extensibility and customization.

Lua's name is Portuguese for 'moon', reflecting its role as a satellite of the host application.