Build a Virtual Machine in Lua
Build a tiny machine that runs programs like '3 4 + 5 *' off a stack, the same core idea that powers Lua's own interpreter.
What you'll be able to build
Build a tiny machine that runs programs like '3 4 + 5 *' off a stack, the same core idea that powers Lua's own interpreter. Along the way you pick up real, transferable Lua skills, not just this one project:
- using a table as a stack (push/pop with #)
- string.gmatch tokenization
- tonumber to distinguish operands from operators
- dispatch tables (operators as a map of functions)
- first-class functions as instructions
- the length operator # and array semantics
A course like this one
Yours is built from your own placement, so module count and depth will differ. This map shows what a advanced-level Lua learner building Build a Virtual Machine in Lua actually gets.
- Module 1: Idiomatic Lua and string patterns5 lessons
Builds the production-ready version of the script for your build a virtual machine in lua.
- Module 2: Closures, upvalues, and varargs5 lessons
Builds the production-ready version of the reusable module for your build a virtual machine in lua.
- Module 3: Metatables, OOP, and coroutine schedulers5 lessons
Builds the production-ready version of the metatable behaviour for your build a virtual machine in lua.
- Module 4: Sets, lookups, and sparse tables5 lessons
Builds the production-ready version of the table model workflow for your build a virtual machine in lua.
- Module 5: Iterators and stateful loops5 lessons
Builds the production-ready version of the function that powers your build a virtual machine in lua.
- Module 6: Sandboxing and production hardening3 lessons
Builds the production-ready version of the release package for your build a virtual machine in lua.
How the lessons actually work
Every lesson has you predict what a piece of Lua code will output before you run it, then run it for real in your browser and fix what you got wrong. Each module ends in a challenge gate with hidden tests, so you can't advance until your code actually works. The course closes with a capstone that assembles everything into Build a Virtual Machine in Lua, and a runnable proof page tied to your own code.
Common questions
How long does the Build a Virtual Machine in Lua course take?
about 7 hours, across 6 modules and 28 lessons, at roughly 15 minutes per lesson. Your own course may run shorter or longer, since it's sized to your placement result, not a fixed template.
Do I need experience?
Yes. This is an advanced-tier Lua project, so it assumes you're already comfortable writing and reading Lua before you start.
How much does it cost?
$15 one-time, no subscription. The first module is free, so you can see exactly how the course teaches before you pay for the rest.
No subscription. Module one is free.