Python has long been considered a "language for all", but Lua moves the bar even lower: 22 keywords, 8 data types and one data structure. This is enough to write a game, set up a web server, or automate a cloud infrastructure.
Due to such a small core, the language reads like pseudocode, and you can learn it literally in an evening. In this article, we will dive deep: we will see how tables and coroutines are arranged, where Lua wins over Python, we will provide usage statistics and show live examples.

Minimum syntax — maximum power ⏱️
-- рекурсивный факториал
function fact(n)
if n == 1 then return 1 end
return n * fact(n - 1)
end
print("fact(5) = " .. fact(5)) -- 120Blocks are closed end, lines are concatenated .., comments begin --. Clear and without hidden rules. Need a loop? Single-line for solves:
for i = 1, 10 do print(i) endDry numbers: Lua vs Python, Ruby, JavaScript 📊
Indicator | Lua 5.4 | Python 3.12 | Ruby 3.3 | Node.js 20 |
|---|---|---|---|---|
Keywords | 22 | 35 | 41 | 44 |
Hello World, bytes in exe (Linux, UPX compression) | 404 KB | 27 MB | 31 MB | 61 MB |
Start time of the "empty" script, ms | 6 | 22 | 38 | 45 |
Memory peak of the "empty" script, MB | 1.9 | 9.3 | 10.8 | 15.4 |
LOC for factorial (with i/o) | 5 | 7 | 9 | 9 |
GitHub ★ per year (2024→2025) | +7 % | +3 % | −1 % | +4 % |
Kernel + stdlib, C code lines | 29 k | 500 k | 380 k | 620 k |
Conclusion: Lua starts faster, takes up less memory and remains more compact than its competitors, while retaining all the necessary features.
One data structure — a table 📦
local arr = {1, 4, 9}
local map = {width = 200, height = 100}
print(arr[1]) -- 1 (индексация с 1)
print(map.width) -- 200Want an array? Use numeric indexes. Need a dictionary? Assign by name. Want both? No problem — the table can simultaneously store both positional and named elements.
The advantages of this approach:
A simple memory model is a single allocator.
There is no difference between a JSON object and an array when exchanging data with JS.
The learning time is reduced: "I learned the tables and understood all the Lua data structures."
Productive environment 🔧
Multiple assignments and return values
local a, b = 10, 20
function size() return 800, 600 end
local w, h = size()Iterators
ipairsandpairs
for i, v in ipairs({"a","e","i"}) do print(i, v) end
for k, v in pairs({john=120, ann=80}) do print(k, v) endCoroutines — an easy way to write non-blocking code without async/await:
local co = coroutine.create(function()
for i = 1,3 do print("tick", i); coroutine.yield() end
end)
coroutine.resume(co) -- tick 1
coroutine.resume(co) -- tick 2
coroutine.resume(co) -- tick 3Where Lua is already working 🚀
Project / Product | What Lua does | Reason for selection |
Roblox | Game logic of millions of games | Sandbox + JIT speed |
Blizzard WoW | UI and add-ons | "Hot" reboot without rebuild |
Nginx (OpenResty) | Dynamic rendering and A/B | Lightweight, embeddable |
Adobe Lightroom | Extensions and presets | Cross-platform scripting |
Wireshark | Custom dissectors | Fast integration of C-modules |
This is just the tip of the iceberg: Lua can be found in Redis, in DJI embedded systems, and even in Tesla Autopilot.
Minimum but powerful standard library 📚
local msg = "Hello Lua"
print(msg:sub(7):lower():reverse()) -- aulStrings, tables, coroutines, file system,
os,debug— everything is already sewn in, nothing needs to be imported.The "lightweight regex-like" pattern system occupies <500 lines of C.
The garbage collector with a list tricolor algorithm works automatically.
Error handling without a headache 🚑
function grade(score)
if score > 100 then error{code=1002,msg=">100"} end
return score>=50 and "P" or "F"
end
for _, s in ipairs({20,120,60}) do
local ok, res = pcall(grade, s)
if ok then print("Grade:", res)
else print("Error["..res.code.."]:", res.msg) end
endpcall catches exceptions, and the result of (ok, data) simplifies the processing flow.
Modules without special keywords 📦➡️📦
-- calc.lua
local M = {}
function M.add(a,b) return a+b end
return M-- main.lua
local calc = require("calc")
print(calc.add(2,3)) -- 5No export/import; tables and require — that's the whole "assembly".
Ecosystem: small but growing 🌱
LuaRocks: >9,000 packages (+12% growth in 2024).
LuaJIT: accelerates code to C-speed, used in Nginx and Redis.
Job trends: Upwork notes +18% demand for Lua freelance for 2024.
Why learn Lua right now 🎓
Low‑code boom: startups are looking for embedded DSL — Lua integrates with two C files.
Gaming industry: Roblox, Defold, Corona SDK are based on Lua scripts.
IoT market: ESP firmware with Lua takes up <512 KB of flash.
OpenAI API? 🤖 It's cheaper to write A‑B test scripts in Lua than to raise full‑stack.
After "Kodik: Programming Training" application you can take an interactive course on Lua in the evening — 🔥 and immediately apply the skills.
Conclusion 🎯
Lua combines extreme minimalism with practicality: JIT compiler, LuaRocks, coroutines and metatables allow you to write games, web servers and scripts for DevOps. If you need a language that you can explain to a friend over coffee, try Lua. And if you want to go from scratch to the first coroutines in a couple of hours, check out "Kodik: Programming Training".
