What Is Lua?
Lua (Portuguese for "moon") is a small, fast scripting language designed to be embedded in other programs. It was created in 1993 at PUC-Rio in Brazil by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes.
local languages = {"Lua", "Python", "C", "JavaScript"}
for i, name in ipairs(languages) do
if #name <= 3 then
print(i, name:upper())
end
end
1 LUA
3 C
Its defining traits:
- Tiny — the whole interpreter is a few hundred kilobytes of portable C, so it fits inside games, editors, routers, and databases.
- Simple — only a handful of concepts. Almost everything is built from one data structure, the table.
- Fast — one of the fastest interpreted languages, and LuaJIT (a just-in-time compiler) is faster still.
- Embeddable — a program written in C, C++, C#, or Rust can run Lua scripts and expose its own functions to them. That's how games let players and designers write game logic.
- Dynamically typed — values have types, variables don't.
This course teaches Lua 5.4 (examples were run on Lua 5.4.8, and checked on the newer Lua 5.5). Many hosts use older variants — LuaJIT (based on Lua 5.1) in Neovim and LÖVE, and Luau in Roblox — so the course notes where they differ.