Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Lua runs inside other programs, from Neovim plugins to Pandoc filters. This course teaches Lua 5.4 to programmers who already know one language. You start by running a script. Then you use Lua’s table to represent a list of values, a record with named fields, and an object with methods. Later you test and package a module, call Lua from C, and adapt a plugin to its host. The final module also examines which limits a host can enforce on plugin code.

Work through 14 modules, five programming assignments, and two self-tests at your own pace. For the capstone, you release a Lua package for your portfolio. The course has no deadlines or grades.

Start with setting up your environment.

Learning objectives

By the end of the course, you can:

Each module’s objectives serve the course objective in brackets. Every exercise, lab, and self-test question names the objectives it tests.

Module 1: First steps [LO-1]

Module 2: Control flow and functions [LO-1]

Module 3: Tables [LO-2]

Module 4: Strings and patterns [LO-2]

Module 5: Closures and iterators [LO-3]

Module 6: Errors, modules, and tests [LO-4]

Module 7: Metatables [LO-3]

Module 8: Objects and classes [LO-3]

Module 9: Coroutines [LO-5]

Module 10: Files, the operating system, and data [LO-4]

Module 11: Packages and tooling [LO-6]

Module 12: Performance and memory [LO-6]

Module 13: Lua and C [LO-7]

Module 14: Versions, sandboxes, and hosts [LO-8]

Prerequisites

You need one finished programming course in any language, such as Python, Java, JavaScript, or C, and some practice with Git and a terminal. Module 13 asks you to read and write short C functions; its reading explains the C it uses.

Self-check. If you can do all five of these, in any language, you are ready:

  1. Write a function that returns the largest number in a list, and a test that calls it.

  2. Explain what happens to a list passed to a function that appends to it.

  3. Write a recursive function, and say what happens when it recurses too deeply.

  4. Run a program from a terminal with a file path as its argument, and read its error message.

  5. Clone a Git repository, change a file, and commit the change.

Suggested pace

The course is self-paced, so it has no deadlines: take as long as you need. This pace takes 15 weeks at about 9 hours a week. Most modules take about 9 hours: about 2.5 for the reading, 2 for the lab, 1.5 for the practice, and 3 for the assignment or self-test that follows, as each module’s reading says. Modules 7 and 8 take less, and Modules 4 and 14 take about 10.

WeekTopicReadingThen
1First stepsModule 1
2Control flow and functionsModule 2PA1
3TablesModule 3
4Strings and patternsModule 4PA2
5Closures and iteratorsModule 5
6Errors, modules, and testsModule 6PA3
7MetatablesModule 7Self-test 1, on modules 1–7
8Objects and classesModule 8
9CoroutinesModule 9
10Files, the operating system, and dataModule 10PA4
11Packages and toolingModule 11The capstone project’s proposal
12Performance and memoryModule 12PA5
13Lua and CModule 13The capstone project’s milestone
14Versions, sandboxes, and hostsModule 14Self-test 2, on all modules
15The capstone projectThe briefThe capstone project’s release

Checking your work

The course has no grades. Instead, every piece comes with a way to check it, so you can tell what you have learned and what to review:

PieceHow you check itObjectives
Labs 1–14Every check cell in the notebook passesEach lab’s module
PA1: Numbers and functions (notebook)Its visible testsLO-1.1, LO-1.2, LO-1.4, LO-2.1–2.4
PA2: Tables and text (notebook)Its visible testsLO-3.1–3.4, LO-4.1, LO-4.2, LO-4.4, LO-2.2
PA3: An iterator library (Lua project)Its example tests, your own tests, and its rubricLO-5.2, LO-5.3, LO-6.1–6.3, LO-3.1, LO-4.2
PA4: A discrete-event simulation (Lua project)Its example tests, your own tests, and its rubricLO-7.1, LO-7.2, LO-8.1, LO-8.2, LO-9.2, LO-9.3, LO-5.3, LO-6.3
PA5: A command-line tool (Lua project)Its example tests, your own tests, its rubric, and the course’s project checkerLO-10.1, LO-10.3, LO-11.1–11.4, LO-4.2, LO-6.1, LO-8.1
Self-test 1, after Module 7The answers and scoring notes in the pageModules 1–7
Self-test 2, after Module 14The answers and scoring notes in the pageAll modules, weighted toward modules 8–14
Capstone project: proposal, milestone, and releaseThe brief’s checklists and rubric, and the course’s project checkerLO-6.1–6.3, LO-11.1–11.4, LO-12.1, LO-12.3, and those of the idea you choose

Later pieces revisit earlier objectives on purpose, so that you keep practicing them.

Policies

Course materials