LearnAI ToolsCareerPractice BuildsPlayContact
Lesson 114 min read

Introduction to Lua

Learn what Lua is, who created it and why, its core philosophy as a small embeddable language, and write your first line of Lua code.

Introduction

Lua is a lightweight, high-level scripting language built around one central promise: be small, fast, and easy to embed inside another application. Rather than competing to be the language you write an entire operating system or database in, Lua is designed to be the scripting layer other software drops in to become extensible.

This lesson introduces what Lua is, who created it and why, the philosophy that shapes every design decision in the language, and gives you your very first taste of actual Lua code.

What You Will Learn
  • What Lua is and what kind of language it is (dynamically typed, interpreted, embeddable).
  • Who created Lua, and the goals that shaped its design.
  • The core philosophy — small, fast, and mechanism-not-policy — that guides every Lua feature.
  • The key features that make Lua stand out from other scripting languages.
  • What a minimal Lua program looks like.

What is Lua?

Lua is an open-source, dynamically typed, interpreted scripting language. "Dynamically typed" means a variable's type is determined at runtime, not declared up front — the same variable can hold a number, then later a string, with no type annotation required. "Interpreted" means Lua source (or a precompiled bytecode form) runs through the Lua virtual machine rather than compiling to a native executable.

What sets Lua apart from most other scripting languages is how deliberately small it is. The entire reference manual is short enough to read in an afternoon, the standard library is minimal by design, and the reference implementation compiles to well under a megabyte. That smallness is not a limitation — it is the entire point, since Lua is meant to be embedded inside a host application (most often written in C or C++) rather than run entirely on its own.

Who Created Lua, and Why

Lua was created in 1993 at PUC-Rio, the Pontifical Catholic University of Rio de Janeiro in Brazil, by Roberto Ierusalimschy, Waldemar Celes, and Luiz Henrique de Figueiredo. "Lua" means "moon" in Portuguese — a fittingly short name for a language built around being small.

The team was working with Petrobras, Brazil's state oil company, which needed a way for non-programmers to configure and describe data for engineering applications. Earlier in-house tools (simple description languages called DEL and SOL) proved the concept, and Lua was built as their unified, general-purpose successor — a full scripting language, but still small enough to embed and simple enough for non-specialists to pick up. At the time, trade restrictions on importing foreign software into Brazil also pushed local teams toward building their own tools rather than buying proprietary ones, which shaped Lua's early open, freely available distribution.

Core Philosophy

Every feature Lua has — and every feature Lua deliberately leaves out — traces back to a small set of guiding principles.

  • Small and simple — the whole language fits in a short reference manual, with very few core concepts to learn.
  • Mechanism, not policy — Lua gives you a small set of general-purpose building blocks (like the table) rather than many specialized, opinionated features.
  • Portable — the reference implementation is written in clean, portable ANSI C, so Lua compiles almost anywhere a C compiler exists.
  • Fast — Lua is consistently one of the fastest interpreted languages in independent benchmarks, and LuaJIT pushes performance even further.
  • Embeddable first — Lua is designed from the ground up to be linked into a host application through a small, well-documented C API.

Key Features at a Glance

Tiny Footprint

The reference interpreter is small enough to embed in resource-constrained and embedded systems.

One Data Structure

The table does the job of arrays, dictionaries, objects, and namespaces — no separate type for each.

First-Class Functions

Functions are values like any other — they can be stored, passed around, and returned from other functions.

Built-In Coroutines

Lightweight cooperative multitasking is a core language feature, not a bolted-on library.

Simple C API

A clean, well-documented API lets a host application embed Lua and exchange data with it easily.

Fast Interpreter

Lua consistently ranks among the fastest interpreted languages, with LuaJIT offering near-native speed.

Your First Taste of Lua

No introduction to a language is complete without seeing actual code. Here is the smallest complete Lua program — one that prints a greeting to the screen.

print("Hello, Lua!")
Output

Click Run to see what this code prints.

That is genuinely the entire program — no imports, no main function, no boilerplate. print() is one of Lua's small set of built-in global functions, and a Lua script is simply a sequence of statements executed from top to bottom, exactly like this one line.

Where Lua Is Used Today

Lua has grown from a Brazilian oil company's configuration tool into the scripting layer behind some of the most-used software in the world.

Project / CompanyHow Lua Is Used
World of WarcraftThe entire addon ecosystem is written in Lua, exposed through the game's own Lua API.
RobloxUses Luau, a typed dialect of Lua, as the scripting language for every game built on the platform.
NeovimLua is a first-class configuration and plugin language alongside Vimscript.
RedisSupports running Lua scripts directly on the server via the EVAL command for atomic, complex operations.
Nginx (via OpenResty)Embeds LuaJIT to let developers script request handling at high performance.
Adobe LightroomExposes a Lua-based plugin API for extending the application's functionality.

Common Mistakes

Avoid These Mistakes
  • Assuming Lua is "just for games" — it is equally common in server, editor, and embedded scripting.
  • Expecting classes and objects the way Python or Java has them — Lua builds OOP-like patterns out of tables and metatables instead (covered in lesson 9).
  • Judging Lua's capability by its small standard library — that smallness is deliberate, and most missing conveniences are one small library or a few lines away.
  • Skipping the philosophy section and jumping straight to syntax — understanding *why* Lua stays so small makes several later design choices click faster.

Best Practices

  • Read the official Lua reference manual at lua.org early — it is unusually short and genuinely worth reading start to finish.
  • Install a Lua version manager or your OS package manager's Lua build so you can experiment in the interactive interpreter immediately.
  • Keep the interactive Lua REPL (lua -i, or just lua with no arguments) open while learning — Lua's tiny startup time makes it ideal for quick experiments.
  • When a host application (a game, an editor) exposes Lua, check its specific API docs — the core language stays the same, but available functions vary by host.

Frequently Asked Questions

Games are Lua's most visible use case, but it is equally common in server configuration (Nginx/OpenResty, Redis), editor extensibility (Neovim), and as an embeddable scripting layer inside countless C/C++ applications.

Yes. Lua has been freely available since its creation and is distributed under the permissive MIT license, maintained by its original creators at PUC-Rio.

No. Lua is a beginner-friendly language on its own — C knowledge only becomes relevant if you want to embed Lua inside a C application yourself, covered in lesson 12.

Yes — the standard Lua interpreter is consistently one of the fastest interpreted languages in independent benchmarks, and LuaJIT (a separate, highly optimized implementation) pushes performance close to native compiled code for many workloads.

Key Takeaways

  • Lua is an open-source, dynamically typed, interpreted scripting language designed to be small and embeddable.
  • It was created in 1993 at PUC-Rio in Brazil by Roberto Ierusalimschy, Waldemar Celes, and Luiz Henrique de Figueiredo.
  • Lua's core philosophy is smallness, portability, speed, and giving you general mechanisms instead of many specialized features.
  • A minimal Lua program is a single line — no imports, no main function required.
  • Lua powers scripting in World of Warcraft, Roblox, Neovim, Redis, and Nginx via OpenResty.

Summary

You now know what Lua is, who built it, why it exists, and what its guiding philosophy is. You have also seen your very first line of runnable Lua code. Next, you will dig deeper into Lua's history — from its origins as a data-description tool for Petrobras through today's Lua 5.4 and the wider Lua ecosystem.

Next Lesson →

History & Evolution of Lua