Lua

MIT
Platform
Linux Windows macOS
Licence
MIT Open source
Website
lua.org/
Lua

Overview

Lua is a lightweight, high-level scripting language built to be embedded inside other programs. It was created in 1993 by a team at PUC-Rio, the Pontifical Catholic University of Rio de Janeiro in Brazil — Roberto Ierusalimschy, Luiz Henrique de Figueiredo and Waldemar Celes — who still maintain it today. The interpreter is written in ANSI C and the whole thing is small: a few hundred kilobytes of source that compiles in seconds and links into a host application as a library. That small footprint, a clean C API and a syntax that non-programmers can pick up in an afternoon are why Lua sits inside so much software people already use, from Redis and Wireshark to Nginx, Neovim and a long list of games. It is free software under the MIT licence, and the current release is Lua 5.5.1 (July 2026), with the 5.4 series still maintained (5.4.9, August 2026).

Key Features

  • Built for embedding — the C API (a lua_State, a stack of values, one call to lua_pcall) lets a host program expose its own functions to scripts and call back into them, without changing how the host is built.
  • Tables as the one data structure — arrays, hashes, records, namespaces and objects are all tables, so the language definition stays small and predictable.
  • Metatables and metamethods — operator overloading, inheritance, proxies and read-only tables are all built on one mechanism instead of separate language features.
  • First-class functions and closures — functions are values with lexical scoping, so callbacks and small internal DSLs need no special syntax.
  • Coroutines — cooperative concurrency is a first-class type, which is how Lua handles streaming, state machines and generators.
  • Small, fast and predictable — integers and floats are distinct subtypes since 5.3 (64-bit integers by default), and 5.4 added a generational mode to the incremental garbage collector, plus const and close to-be-closed variables.
  • Batteries that fit — string patterns, a UTF-8 library, a compact standard library and the debug library cover the scripting jobs a host does not want to re-implement.
  • Ecosystem — LuaRocks installs and manages modules, and LuaJIT runs Lua 5.1-compatible code at speeds close to C for the workloads it suits.

Why Use Lua?

Lua is the cheapest way to add a real programming language to a program you already have. A host application links one small library, registers a handful of C functions, and its users get a scripting environment they can learn in an afternoon — which is exactly what game studios, network tools and editors wanted, and why so many of them chose Lua instead of writing their own. It stays out of the way: no build system to take over, no runtime to ship separately, no large standard library dictating the design. Its portability is unusually broad for a dynamic language, from Linux, macOS and Windows to BSD and firmware-sized targets, and bytecode can be precompiled with luac or dumped with string.dump and loaded from a string or a file. The trade-off is a deliberately small core: everything from JSON to sockets comes from a module, so a project that needs a large standard library may prefer Python or Ruby — but when the goal is a stable, sandboxable extension language inside another product, Lua is still the reference answer.

Use Cases

  • Game scripting and modding — LÖVE, Defold and Roblox’s Luau dialect, plus the user-interface code of World of Warcraft.
  • Server-side scripting in Redis (EVAL) and in Nginx through OpenResty.
  • Editor and desktop extensibility — Neovim, mpv and the Awesome window manager all script themselves in Lua.
  • Protocol and packet analysis — Wireshark dissectors and Nmap’s NSE scripts.
  • Document pipelines — Pandoc filters and LuaTeX.
  • Embedded and configuration logic in routers, appliances and IoT firmware, where the interpreter has to fit in a few hundred kilobytes.

Getting Started

Install the interpreter from your distribution (sudo apt install lua5.4 on Debian and Ubuntu, brew install lua on macOS, or the binaries from lua.org for Windows) and check it with lua -v. Run a file with lua script.lua, or start the REPL by running lua with no arguments. Modules come from LuaRocks: luarocks install luasocket, with the paths added by eval $(luarocks path). The reference manual at lua.org/manual is the authoritative documentation, and lua -e 'print(_VERSION)' reports the series you are running — the 5.4 shipped by most distributions and the 5.5 series differ in a few details, so read the manual that matches your version.

Explore More Categories

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.