Nepedia
Back to Discover
Advanced Reader
💻

Lua

technology Maturity 7-9 war conflict Next article →

This article covers sensitive topics: war_conflict. Parents can manage visibility in Parental Controls.

Lua is a lightweight, high-level, multi-paradigm programming language. It is primarily designed for embedded use within other applications. This means Lua is often used as an extension language to add features to existing software. Because its interpreter is written in ANSI C, it is cross-platform and can run on many different systems. Lua is highly portable and has a simple C application programming interface, or API. This API makes it easy for developers to embed Lua into their own programs.

To achieve its goals, Lua focuses on speed, portability, and extensibility. It does not provide a massive set of specific features for every possible task. Instead, it offers a small set of general, flexible tools. Programmers use these tools to build the specific features they need. This approach is why Lua is called a multi-paradigm language. It can be adapted to many different styles of programming. The base language remains very light and compact.

The core of Lua is a single, powerful data structure called a table. A table is a heterogeneous associative array. This means it can store different types of data together using various types of keys. In Lua, a table can act as a list, a set, or a record. It can even represent more complex structures like arrays or namespaces. Tables are the foundation for almost all user-created types in the language. This design keeps the language simple while allowing for great complexity.

Lua was created in 1993 by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes. They were members of the Computer Graphics Technology Group, known as Tecgraf, at the Pontifical Catholic University of Rio de Janeiro in Brazil. At the time, Brazil had a policy called a market reserve. This policy created strong trade barriers for computer hardware and software. Because of these barriers, Tecgraf's clients could not easily buy customized software from abroad. This forced the team to implement their own basic tools from scratch.

Before Lua, the team used two languages called SOL and DEL. SOL stands for Simple Object Language, and DEL stands for Data-Entry Language. These were developed in 1992 and 1993 for engineering projects at Petrobras. However, these languages lacked flow-control structures. The creators needed more programming power, which led to the birth of Lua. The name Lua means "Moon" in Portuguese. This was a tribute to SOL, which means "Sun."

Lua's design was influenced by many different programming languages. Its syntax for control structures was borrowed from Modula. It also took ideas from CLU, such as multiple assignments and multiple returns. The creators used ideas from C++ regarding local variable declarations. They also drew from SNOBOL and AWK for associative arrays. Most importantly, the decision to use tables as the primary data structure was influenced by LISP and Scheme. Over time, Lua's semantics have been increasingly shaped by Scheme, especially through the use of anonymous functions and lexical scoping.

Lua is highly efficient and occupies very little space. The full reference interpreter is only about 247 kB when compiled. This small size allows it to fit onto a wide variety of host platforms. The language manages memory automatically through a process called garbage collection. It also supports advanced features like coroutines for cooperative multitasking. These features allow Lua to handle complex tasks while remaining a small, fast, and easy-to-use tool for developers.

567 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.