TL; DR: As the scripting language behind Angry Birds, Civilization, and World of Warcraft, Lua appeals to developers for being a fast, small, and compatible scripting language. We spoke with Roberto Ierusalimschy, one of the three founding developers who created the language in Brazil and continue to add and adapt new features as the needs arise. He shared Lua’s steady, organic growth to mainstream usage and popularity among gamers and makers of embedded and Internet-of-Things devices.
As three Brazilian developers worked on a project for the country’s major oil company in 1993, they discovered they didn’t have the tools they needed.
Unable to buy customized solutions, the team began creating the programming and scripting languages needed to configure applications and manage data.
Originally, they created a data description language similar to XML or JSON. SOL, which means sun in Portuguese, also stood for Simple Object Language. The developers eventually gave up SOL for a new idea — a satellite language of sorts that interfaced with other types of code. Somewhere along the way, someone suggested a name: Lua, or the Portuguese word for moon.
As with its namesake, Lua has steadily risen to global significance behind the Founders’ vision for an easy-to-use, fast, portable, and extendable language that particularly resonates with developers of games, embedded systems, and Internet-of-Things devices.
“Lua is a language that has been created since the beginning to be used as a real scripting language used together with other languages,” Roberto said. “It allows for several interesting constructions and several kinds of new ways of programming things.”
Lua’s Organic Growth and Evolution as a Lightweight Language
Roberto and Waldemar Celes, associate professors at the Pontifical Catholic University of Rio de Janeiro, joined researcher and consultant Luiz Henrique de Figueiredo to create interactive graphical programs for engineering applications run by Brazil’s largest oil company.
Strict trade barriers meant the Brazilians couldn’t afford to buy customized programs from abroad, and the developers lacked flow-control structures in SOL and another Lua predecessor, a homegrown data-entry language called DEL.
“At that time, there was nothing else we could use,” Roberto said, noting that XML and JSON didn’t exist yet. Perl was very cumbersome and mainly used for system administration, and Python was still in its infancy.
Tcl was an option, but with so many non-professional programmers expected to use the tools, the developers opted to avoid the difficult syntax and Unix-only support.
“We decided to create our own language for our own needs,” Roberto said. “It’s been the three of us working on the language since the beginning. It was very successful in our use, and it has kept growing since then.”
Although Roberto told us Lua’s name isn’t an acronym, the community of users has casually and unofficially assigned Lua Uppercase Accident to represent the times when Lua is mistakenly written in all capital letters.
Developing and maintaining the language has been surprisingly simple, according to Roberto. The slow, organic growth meant the contributors could evolve the language as they wished.
“Our clients at the beginning were ourselves, and we knew exactly what we needed,” he said. “We don’t have outside pressures, so if there is a big obstacle that we don’t know how to solve, we can just postpone it until someone discovers a new algorithm or something like that.”
The Potency of Being Proven, Portable, and Performant
Lua provides a small set of general features that can be extended to fit different scenarios. Built on simplicity, Lua offers one data structure, the table, a Lua term for an associative array.
Lua syntax closely follows Modula, while the semantics have been influenced by Scheme. Written in ANSI C, Lua is cross-platform and compiles directly in Windows, Linux, macOS, mobile devices, and microprocessors.
A strong API enables developers to easily embed Lua into applications and external code. In addition to C, C++, and .NET frameworks, Lua interacts with other scripting languages, including Perl and Ruby.
The language gets its performance from its small size and efficiency. The entire Lua distribution, which includes documentation, examples, and binaries where needed, is less than 1MB. The standard Linux interpreter, built with all the standard libraries, takes only 143KB.
“Of course Lua is not as fast as C or a compiled language, but in the realm of scripting languages, it’s very fast,” Roberto said.
A Leading Language for Gaming, Embedded Systems, and IoT Devices
Although Roberto knows the gaming industry, embedded systems, and Internet-of-Things devices to be major Lua users, he said it can be difficult to learn about specific uses and implementations.
Game developers have asked Roberto to sign nondisclosure agreements before showing any code, and the systems behind embedded and IoT devices are quite fragmented and differentiated.
“The groups have these separated cultures and do not share much code,” he said. “Even for us, it’s hard to measure how others use Lua.”
In addition to the small size and speedy performance of Lua, Roberto said the language’s main selling point is the compatibility with other languages.
“Most games have an engine in C++ that does all the graphics and physics, and the game itself is created on top of that engine with Lua,” Roberto said.
Coming Soon: A New Generational Garbage Collector
Currently, Roberto, Waldemar, and Luiz Henrique are working on something Roberto calls “not very exciting but very important for the language.”
Lua currently employs an incremental garbage collector, which identifies data objects that cannot be accessed in the future and reclaims the memory and computing resources.
“It’s quite good, but it has some problems when people start using lots and lots of data inside the language,” Roberto said, adding that the team will be implementing a generational collector.
Incremental garbage collectors run through an application’s entire codebase a bit at a time to detect objects, while a generational collector gathers objects into generations based on age and stability, allowing for scanning to be done more efficiently and with fewer computing resources.
“A generational garbage collector will help a lot with those big problems,” Roberto said.
Balancing Brazilian Roots With Global Adoption
The team of developers live and work close together, so Roberto said they maintain a rather old-fashioned, low-tech work environment of face-to-face meetings every few weeks. “We don’t use any fancy technology to communicate,” he said.
Lua’s founding team takes special pride in creating a globally adopted technology from outside the traditional centers of innovation like Silicon Valley. Brazilian pride, however, has come with unique challenges. Roberto sometimes hears criticism that his book for programming in Lua is written in English, rather than Portuguese. Roberto called English “the universal language for software” and points out that gaming and embedded systems are not major Brazilian industries.
“We created the language for our particular needs, and they were Brazilian at the time,” he said, laughing. “Brazil has a lot of good people working on other projects, particularly in free software. I’m very proud to have contributed to that.”
HostingAdvice.com is a free online resource that offers valuable content and comparison services to users. To keep this resource 100% free, we receive compensation from many of the offers listed on the site. Along with key review factors, this compensation may impact how and where products appear across the site (including, for example, the order in which they appear). HostingAdvice.com does not include the entire universe of available offers. Editorial opinions expressed on the site are strictly our own and are not provided, endorsed, or approved by advertisers.
Our site is committed to publishing independent, accurate content guided by strict editorial guidelines. Before articles and reviews are published on our site, they undergo a thorough review process performed by a team of independent editors and subject-matter experts to ensure the content’s accuracy, timeliness, and impartiality. Our editorial team is separate and independent of our site’s advertisers, and the opinions they express on our site are their own. To read more about our team members and their editorial backgrounds, please visit our site’s About page.