plementation simple and portable. Because the new language
was partially inspired by SOL (sun in Portuguese), a friend
at Tecgraf (Carlos Henrique Levy) suggested the name ‘Lua’
(moon in Portuguese), and Lua was born. (DEL did not in-
fluence Lua as a language. The main influence of DEL on
the birth of Lua was rather the realization that large parts
of complex applications could be written using embeddable
scripting languages.)
We wanted a light full language with data-description fa-
cilities. So we took SOL’s syntax for record and list con-
struction (but not type declaration), and unified their imple-
mentation using tables: records use strings (the field names)
as indices; lists use natural numbers. An assignment such as
T = @track{ y=9, x=10, id="1992-34" }
which was valid in SOL, remained valid in Lua, but with
a different meaning: it created an object (that is, a table)
with the given fields, and then called the function track on
this table to validate the object or perhaps to provide default
values to some of its fields. The final value of the expression
was that table.
Except for its procedural data-description constructs, Lua
introduced no new concepts: Lua was created for production
use, not as an academic language designed to support re-
search in programming languages. So, we simply borrowed
(even unconsciously) things that we had seen or read about
in other languages. We did not reread old papers to remem-
ber details of existing languages. We just started from what
we knew about other languages and reshaped that according
to our tastes and needs.
We quickly settled on a small set of control structures,
with syntax mostly borrowed from Modula (while, if, and
repeat until). From CLU we took multiple assignment
and multiple returns from function calls. We regarded mul-
tiple returns as a simpler alternative to reference parameters
used in Pascal and Modula and to in-out parameters used in
Ada; we also wanted to avoid explicit pointers (used in C).
From C++ we took the neat idea of allowing a local vari-
able to be declared only where we need it. From SNOBOL
and Awk we took associative arrays, which we called tables;
however, tables were to be objects in Lua, not attached to
variables as in Awk.
One of the few (and rather minor) innovations in Lua was
the syntax for string concatenation. The natural ‘+’ operator
would be ambiguous, because we wanted automatic coer-
cion of strings to numbers in arithmetic operations. So, we
invented the syntax ‘..’ (two dots) for string concatenation.
A polemic point was the use of semicolons. We thought
that requiring semicolons could be a little confusing for en-
gineers with a Fortran background, but not allowing them
could confuse those with a C or Pascal background. In typi-
cal committee fashion, we settled on optional semicolons.
Initially, Lua had seven types: numbers (implemented
solely as reals), strings, tables, nil, userdata (pointers to
C objects), Lua functions, and C functions. To keep the lan-
guage small, we did not initially include a boolean type:
as in Lisp, nil represented false and any other value repre-
sented true. Over 13 years of continuous evolution, the only
changes in Lua types were the unification of Lua functions
and C functions into a single function type in Lua 3.0 (1997)
and the introduction of booleans and threads in Lua 5.0
(2003) (see §6.1). For simplicity, we chose to use dynamic
typing instead of static typing. For applications that needed
type checking, we provided basic reflective facilities, such
as run-time type information and traversal of the global en-
vironment, as built-in functions (see §6.11).
By July 1993, Waldemar had finished the first implemen-
tation of Lua as a course project supervised by Roberto.
The implementation followed a tenet that is now central to
Extreme Programming: “the simplest thing that could pos-
sibly work” [7]. The lexical scanner was written with lex
and the parser with yacc, the classic Unix tools for imple-
menting languages. The parser translated Lua programs into
instructions for a stack-based virtual machine, which were
then executed by a simple interpreter. The C API made it
easy to add new functions to Lua, and so this first version
provided only a tiny library of five built-in functions (next,
nextvar, print, tonumber, type) and three small exter-
nal libraries (input and output, mathematical functions, and
string manipulation).
Despite this simple implementation — or possibly be-
cause of it — Lua surpassed our expectations. Both PGM
and ED used Lua successfully (PGM is still in use today;
ED was replaced by EDG [12], which was mostly written
in Lua). Lua was an immediate success in Tecgraf and soon
other projects started using it. This initial use of Lua at Tec-
graf was reported in a brief talk at the VII Brazilian Sympo-
sium on Software Engineering, in October 1993 [29].
The remainder of this paper relates our journey in im-
proving Lua.
5. History
Figure 1 shows a timeline of the releases of Lua. As can be
seen, the time interval between versions has been gradually
increasing since Lua 3.0. This reflects our perception that
1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006
1.0 1.1 2.1 2.2 2.4 2.5 3.0 3.1 3.2 4.0 5.0 5.1
Figure 1. The releases of Lua.