Introduction to Lua
1.1 What is Lua?
Lua ("moon" in Portuguese) is a lightweight, high-level, dynamically typed, embeddable scripting language. It was created in 1993 at PUC-Rio (Brazil) by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes.
It's designed to be embedded in host applications (written in C/C++ and others) to provide scripting, configuration, and extensibility.
The entire interpreter is ~30,000 lines of ANSI C, and the compiled library is around 200–300 KB.
1.2 Key Features
Small and fast Among the fastest interpreted scripting languages; LuaJIT is one of the fastest dynamic-language JITs
A clean C API; easy to integrate with C/C++ (and Rust, Go, C#, ...)
One data structure for arrays, dictionaries, objects, modules, namespaces
Closures, lexical scoping, proper tail calls Customize behavior (operator overloading, inheritance, proxies)
Built-in asymmetric cooperative multitasking Automatic memory management
Incremental and generational garbage collector (5.4) Runs anywhere with an ANSI C compiler: desktops, consoles, phones, microcontrollers Few keywords (22), easy to learn
1.3 Where Lua Is Used
Games: Roblox (Luau), World of Warcraft (UI addons), Garry's Mod, Angry Birds (early versions), Don't Starve, Factorio (mods), Civilization V/VI (scripting), LÖVE, Defold, Solar2D, PICO-8, CryEngine scripting.
Tools and editors: Neovim (configuration and plugins), Adobe Lightroom, Wireshark (dissectors), mpv, Hammerspoon, AwesomeWM, conky, Pandoc filters, LuaTeX.
Web and infra: OpenResty/Nginx (Cloudflare, Kong API gateway), Redis scripting, HAProxy, Envoy, Apache Traffic Server, Tarantool, Apache APISIX.
Embedded/IoT: NodeMCU (ESP8266/ESP32), routers (OpenWrt's LuCI), set-top boxes, automotive infotainment.
1.4 Lua vs Other Scripting Languages
list, dict, set, tuple...
Array, Object, Map, Set Threads, asyncio Event loop, promises Prototype-style via metatables Prototypes + classes Moderate (plus npm)