Lua Fundamentals
Lua is a small, fast scripting language designed to be embedded inside larger applications, from video games to network servers. Instead of running programs on its own, it usually acts as the configuration and extension layer that a host program calls into.
itProgramming languages | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Intro
Lua Fundamentals
Lua is a dynamically typed scripting language designed at PUC-Rio, the Pontifical Catholic University of Rio de Janeiro, with development starting in 1993. It is small, fast, and built from the start to be embedded inside a host application written in C or another language. You rarely run a bare Lua program the way you run a Python script; more often, a game engine, a proxy server, or a text editor loads Lua as its scripting layer and calls into it.
That embedding design shapes everything else about the language. Lua has a tiny core, a simple C API for the host to call Lua and for Lua to call back into the host, and a small standard library. Features that other languages bake in — classes, modules, exceptions — Lua builds instead from a few general mechanisms: tables and metatables. Learn those two well and most of the rest follows.
Values and types
Every Lua value has one of eight types: nil, boolean, number, string, function, userdata, thread, and table. nil means "no useful value here." number covers both integers and floating-point values as two subtypes of the same type, a distinction Lua has kept explicit since Lua 5.3. userdata is how the host application exposes its own C data structures to Lua code. thread is the type of a coroutine, not an operating-system thread.
Continue the course
This section is part of the paid course.
See pricing to subscribe, or log in if you already have access.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://www.lua.org/about.html
Supports
- Lua is a small, efficient, lightweight, embeddable scripting language
- Origin at PUC-Rio (Pontifical Catholic University of Rio de Janeiro), development began 1993
- Supports procedural, object-oriented, functional, data-driven, and data-description styles
- Distributed under the MIT license
- Bytecode compiled, register-based virtual machine
- https://www.lua.org/manual/5.4/manual.html
Supports
- Eight basic types - nil, boolean, number, string, function, userdata, thread, table
- number has integer and float subtypes (since Lua 5.3)
- Tables are the sole built-in data-structuring mechanism, used as arrays, records, sets, and objects
- Global variables are fields of the global environment table _G; local declares block scope
- Generic for loop calls an iterator function until it returns nil; pairs and ipairs
- Functions are first-class values, support multiple return values and varargs (...)
- Metatables attached with setmetatable define metamethods (__index, __newindex, __add, __eq, __call, __tostring, __len)
- No built-in class keyword - object patterns built from tables plus __index
- error raises and never returns; pcall/xpcall run a call in protected mode and return a status flag
- Coroutines only suspend via explicit coroutine.yield, never preempted; coroutine.create/resume/status/wrap
- require checks package.loaded before loading, then searches package.path; module convention returns a table
- string library pattern matching (not regular expressions): string.find, string.match, string.gmatch, string.gsub, string.format; character classes %a %d %s %w
- table library: table.insert, table.remove, table.concat, table.sort
- Arithmetic operators including / (always float) and // (floor division)
- https://www.lua.org/versions.html
Supports
- Lua version history - 5.0 (2003), 5.1 (2006), 5.2 (2011), 5.3 (2015), 5.4 (2020), 5.5 (2025)
- https://www.lua.org/download.html
Supports
- Current stable release is Lua 5.5.0, released 2025-12-15
- https://www.lua.org/uses.html
Supports
- Lua is used in many products and projects, including well-known games and embedded/extensible applications
- https://luajit.org/luajit.html
Supports
- LuaJIT is a Just-In-Time compiler for Lua
- LuaJIT supports the Lua 5.1 API and ABI
- https://luarocks.org/
Supports
- LuaRocks is the package manager for Lua modules, installed as self-contained packages called rocks
- https://www.lua.org/pil/contents.html
Supports
- Programming in Lua (first edition) is freely available online for personal use, by Roberto Ierusalimschy
- https://github.com/LewisJEllis/awesome-lua
Supports
- Curated ecosystem entries - LuaJIT, LuaRocks, busted, OpenResty, LOVE, AwesomeWM, Hammerspoon
