Skip to content

Lua: Brazil's Scripting Language

Abstract

Lua was created in 1993 at the Pontifical Catholic University of Rio de Janeiro by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes, as a configuration language for engineering software at the oil company Petrobras. It exists because Brazil’s trade barriers on computing made it easier to write a language than to buy one. A LucasArts programmer found it in a magazine in 1996 and used it for Grim Fandango; since then it has become the usual scripting language inside games, from World of Warcraft to Roblox. Its authors describe it as the only programming language from a developing country to reach worldwide use.

Tecgraf and the Market Reserve

Tecgraf, the computer graphics group at PUC-Rio, was founded in 1987 and lived on contracts with industry. Its largest client was Petrobras, for which it wrote interactive graphical programs used by engineers and geologists.

The group built almost everything it used. From 1977 until 1992 Brazil kept strong trade barriers on computer hardware and software, the policy known as the market reserve. As the three authors later wrote, Tecgraf’s clients “could not afford, either politically or financially, to buy customized software from abroad”; to do so they would have had to prove through a bureaucratic process that no Brazilian company could supply it. Brazil was also far from the centres where such tools were written, and in 1993 the only real candidate, Tcl, had an unfamiliar syntax, little support for describing data, and ran only on Unix. Writing their own tools was the path of least resistance.

DEL and SOL

Petrobras ran numerical simulators whose input was files of bare columns of numbers, a format inherited from punched cards. In early 1992 it asked Tecgraf for at least a dozen graphical front ends in which engineers could click on a diagram and type the values in. Instead of writing twelve programs, Luiz Henrique de Figueiredo and Luiz Cristovão Gomes Coelho wrote one, driven by a small description language called DEL, for data-entry language. Users soon asked for conditions and loops.

At the same time Roberto Ierusalimschy and Waldemar Celes were building a report generator for lithology profiles, to be configured by geologists on oil platforms. They gave it a description language too, called SOL, for Simple Object Language; sol is also Portuguese for sun. A first implementation was finished in March 1993 and never delivered, because by the middle of that year the two teams had concluded that both languages needed to become real programming languages and that one would do for both. A colleague at Tecgraf, Carlos Henrique Levy, suggested the name. Lua is Portuguese for moon.

A Small Language in C

Lua was designed to be embedded. It is a library written in portable C that a host program links in, and the language proper is deliberately small. It has one data structure, the table, which serves as array, record, dictionary, and object. Functions are first-class values. Features that other languages build in, such as classes and inheritance, are assembled by the programmer from tables and a mechanism the authors first called fallbacks. The whole implementation, as of version 5.5, is about 32,000 lines of C.

Version 1.1 was released by FTP in July 1994 under a licence that was free for academic use only. That part of the licence, the authors wrote, “did not work”: no commercial use was ever negotiated, and other scripting languages such as Tcl were free, and from version 2.1 in February 1995 Lua was free for all uses. Version 5.0, in April 2003, introduced coroutines and a register-based virtual machine and moved to the MIT licence.

Grim Fandango

Outside Brazil, hardly anyone knew of it until the authors published an article in Dr. Dobb’s Journal in December 1996. In January 1997 they received an email from Bret Mogilefsky, lead programmer on an adventure game under development at LucasArts. He had read the article, and the studio planned to replace its home-grown scripting language with Lua. Grim Fandango came out in October 1998, and in May 1999 Mogilefsky reported that “a tremendous amount of the game was written in Lua”.

The game named Lua and PUC-Rio in its closing credits. Several people at the university, the authors noted, first learned of the language from that screen, and were surprised to find Brazilian software in a hit game. Mogilefsky described the experience at a round table on game scripting at the Game Developers Conference, and Lua spread through the industry by word of mouth. It suited the job: designers who were not systems programmers could write game logic in it, a mistake in a script could not corrupt the engine’s memory, and the interpreter was small enough to fit in a console’s budget. Informal polls on GameDev.net in 2003 and 2006 found it the most popular scripting language for games, and the Game Developers Conference held round tables on Lua in 2004 and 2006. The authors, who had built it for oil engineers, wrote that the adoption in games “came as a surprise to us”.

World of Warcraft and Roblox

Blizzard wrote the user interface of World of Warcraft (2004) in Lua and left it open, so that players could replace or extend it with their own scripts (see MMORPGs and Virtual Worlds). A large ecosystem of add-ons followed, and with it a generation of players who learned to program in Lua because they wanted a better raid interface.

Roblox adopted Lua 5.1 around 2006 as the language in which its users script their own games (see Game Engines). It stayed on that version for more than a decade, modifying the runtime for sandboxing, and eventually reshaped it into a derivative language, Luau, with optional type checking and a rewritten interpreter. Luau is a fork, and its programs are not in general valid Lua 5.5, but it is what most children who write “Lua” today are writing.

Beyond games, Lua configures Adobe Lightroom, the Neovim editor, the Redis database, and the Nginx web server (see The Web Server Wars), and Wikipedia’s more complex templates are Lua modules.

At Home

The authors described their history in a paper for the third History of Programming Languages conference in 2007. One sentence in it reads: “It has always bothered us that Lua is widely known abroad but has remained relatively unknown in Brazil.” The language is still developed by the same three people at PUC-Rio, who release a new version every few years and, by their FAQ, “never incorporate third-party code verbatim”. Version 5.5 appeared on 22 December 2025.

📚 Sources