Finding something worth knowing…

Science

Brazil's import barriers gave the world Lua, a programming language named for the Moon

In the early 1990s Brazilian companies faced heavy red tape if they wanted foreign software. So a team at a Rio de Janeiro university built their own scripting language. They named it Lua, Portuguese for Moon, because it grew out of an earlier tool called Sol, the Sun. It became one of the most embeddable languages anywhere.

Between 1977 and 1992 Brazil ran a market reserve policy, a wall of trade barriers meant to foster domestic computer hardware and software. Clients of Tecgraf, the computer graphics group at the Pontifical Catholic University of Rio de Janeiro, would have had to prove bureaucratically that no Brazilian firm could meet their needs before buying abroad. Tecgraf therefore wrote its own tools. Two small configuration languages, SOL and DEL, were built for engineering programs used by the oil company Petrobras, but they lacked loops and branching, and Petrobras wanted real programming power.

Roberto Ierusalimschy, Luiz Henrique de Figueiredo and Waldemar Celes created Lua in 1993. Looking around, they found the obvious existing option, Tcl, awkward in syntax, weak at describing data and limited to Unix, while Python was still young. Because many users would not be professional programmers, they wanted friendly syntax, wide portability across clients' mixed machines, and delivery as a library that other programs could call through C.

Lua borrowed freely. Its if, while and repeat structures came from Modula, multiple return values from CLU, associative arrays from SNOBOL and AWK, and over the years it absorbed more ideas from Scheme, such as anonymous functions and full lexical scoping. Its signature decision was inspired by LISP's reliance on one universal list: Lua has a single built-in compound type, the table, which serves as array, record, set and namespace. Unusually, tables start counting from 1 rather than 0.

The payoff is compactness. The complete reference interpreter weighs in at about 293 kB compiled, written in ANSI C for portability. Instead of baking in object-oriented classes, Lua supplies small meta-mechanisms, such as metatables, that let programmers build inheritance themselves, plus closures, coroutines and garbage collection. Since version 5.0 it has been released under the permissive MIT License.

Source: Lua

Related

More in Science · All topics