Course description

This course is designed to be a beginner-friendly introduction to compilers. As we evolve, we will incrementally put together an interpreter for a very simple scripting language.

We'll cover:

  • Lexical analysis
  • Syntax analysis
  • Parsing algorithms
  • Intermediate representation (AST)
  • Formal languages & grammars
  • BNF notation & syntax diagrams
  • Identifying and reporting errors
  • Code generation
  • Writing our own VM
  • Emitting opcodes and instructions
  • Type checking
  • ...and much, much more!

Compilers always had a reputation for being a difficult topic, and their historical association with dragons 🐉 (starting with the Dragon Book) never really help the cause.

make your own programming language

We'll try to approach every explanations with beginners in mind. You can think of it as a "first course" on compilers for developers that never wrote an interpreter before.

What we'll build

We'll build together, from the ground up, a compiler for a simple programming language called Pinky. Think of a toy scripting language with a syntax inspired by Lua and ALGOL W.

x := 0
pi := 3.141592
name := 'Pinky'

-------------------------------------
-- Find the max between two numbers
-------------------------------------
func max(a, b)
  if a > b then
    ret a
  end
  ret b
end

-------------------------------------
-- Compute the factorial of a number
-------------------------------------
func factorial(n)
  if n == 1 then
    ret 1
  else
    ret n * factorial(n - 1)
  end
end

-------------------------------------
-- Main function
-------------------------------------
func main()
  i := 0
  while i <= 10 do
    print(i)  
    i := i + 1
  end
  for i := 1, 10 do
    print(factorial(i))
  end
end

main()

Our main host language will be Python. Python allows us to focus our attention on compiler-specific concepts while being extremely productive. Still, I'll try to include some helpful tips on how to implement the ideas we just learned using the C programming language.

The tools you'll need

All you need is a command-line, a simple code editor, and a Python interpreter. All these tools are cross-platform, so you'll be able to code along on either Windows, macOS, or Linux!

operating system

Is this course for you?

If you never wrote an interpreter before, or even if you did but still feel you have some blind spots in your understanding of how it all works, then this course is definitely for you!

build your own compilers

This is a self-contained course with no prerequisites. However, you will probably get the most out of it if you already know the basics of coding (if-else, loops, functions).

About the instructor

gustavo pezzi

Gustavo Pezzi is a university lecturer in London, UK. He has won multiple education awards as a teacher and is also the founder of pikuma.com.

Gustavo teaches fundamentals of computer science and mathematics; his academic path includes institutions such as Pittsburg State University, City University of London, and University of Oxford.

teaching certification
higher education academy
pgclt teaching certification
bpp university award

Course content

27 hours total length 21 Chapters Last updated April 2025
  • Motivations & Learning Outcomes
  • How to Take This Course
  • Compilers as Translators
  • A Trip to the Metal
  • CPU Components
  • Opcodes & Instructions
  • Stack Push & Pop
  • Control Flow
  • CPU Status Flags
  • Quiz: CPU Components
  • The 68000 Processor
  • What is a Program?
  • Tokens & Lexemes
  • IR & Syntax Tree
  • Types of Compilers
  • Quiz: Structure of Programs
  • Setting Up our Project Folder
  • Makefile
  • Scanning Tokens
  • A Simple Scanning Algorithm
  • Single-Character Tokens
  • Whitespace & Comments
  • Two-Character Tokens
  • Scanning Integers
  • Scanning Floats
  • Why Not Just Use Regular Expressions?
  • Scanning String Literals & Identifiers
  • Programming Languages & Code Comments
  • Multiline Comments
  • Watching our Memory Footprint
  • Quiz: Lexing
  • Syntax Analysis
  • Context-Free Grammars & BNF
  • Grammar for Simple Expressions
  • Abstract Syntax Tree Nodes
  • Recursive Descent Parsing
  • AST for Simple Expressions
  • "Pretty" AST Printing
  • Polish Notation
  • Quiz: Grammars
  • Error Messages
  • Storing Line Numbers
  • Standardizing Error Messages
  • Quiz: Reporting Errors
  • A Simple Tree-Walking Interpreter
  • Data Types
  • Dynamic Types at Runtime
  • Runtime Type Checks
  • Concating Strings
  • Can We Subtract Strings
  • Parsing Equality & Comparison
  • Exponent Operator Associativity
  • Logical AND and Logical OR
  • Short-Circuit Evaluation
  • TDD & Testing Expression Code
  • A Program as a List of Statements
  • Parsing Print Statements
  • Interpreting Print Statements
  • PrintLn Statements
  • If Statements
  • Quiz: Parsing Statements
  • Identifiers & Assignments
  • State & Memory
  • The Environment Class
  • Declaring Variables?
  • Environment Load & Store
  • Global & Local Variables
  • Quiz: Variables
  • While Statements
  • For Statements
  • Stringifying Booleans & Integers
  • Coding a Fractal (Exercise)
  • Coding a Fractal
  • Functions in Pinky
  • Parsing Function Declarations
  • Parsing Function Calls
  • Interpreting Function Declarations
  • Interpreting Function Calls
  • Max. Number of Parameters
  • Parsing Return Statements
  • Interpreting Return Statements
  • Quiz: Functions
  • Code Generation & VMs
  • Example of Stack Instructions
  • Adding classes for "Compiler" and "VM"
  • Emitting Instructions
  • Printing Opcodes & Mnemonics
  • Where are Instructions Stored?
  • VM Execution
  • VM Expression Evaluation
  • Type Checking at Runtime
  • VM Branches & Jumps
  • Global Variables
  • Keeping Track of Scope Depth at Compile-time
  • Local Variables
  • Stack Slots
  • Exporting Program Symbols
  • Register-Based VMs
  • Register-Based Bytecode
  • Looking at CPython Bytecode Disassembly
  • Type Systems & Type Checking
  • Type Annotations
  • Purposes of a Type System
  • Shunting Yard for Simple Expressions
  • Exercise: Shunting Yard Evaluation
  • Shunting Yard Code
  • Parsing Parentheses
  • Parsing Right Associativity
  • Introduction to Pratt Parsing
  • NUD, LED, and Binding Powers
  • Pratt Parser for Simple Expressions
  • Pratt Code (Parentheses)
  • Pratt Code (Right Associativity)
  • Pratt Code (Prefix Unary)
  • Parsing Expression Grammar
  • Using a PEG Library
  • Optimization & Transformations
  • Constant Folding & Propagation
  • Algebraic Simplifications
  • Dead Code Elimination
  • Syntactic Sugar Transformations
  • Loop Unrolling & Inlining
  • Branch Prediction & Vectorization
  • Tail Call & Peephole Optimization
  • LLVM & Clang
  • LLVM IR
  • SSA Form
  • Installing Clang & llvmlite
  • Emitting LLVM IR
  • Using External C Functions
  • Simple llvmlite Implementation
  • Important Considerations
  • Conclusion & Next Steps

How is this course different?

This course is not just a simple tutorial on how to use third-party tools to parse an existing language. We'll build an interpreter for a toy programming language from scratch while exploring the foundations of formal languages & compilers.

abstract syntax tree ast

We will always try to put things into historical context so you understand why modern compilers work the way they do.

If you want to understand how computers translate high-level languages to instructions that the machine can execute, then buckle up! This is going to be a super cool journey of pure nerd fun!

73% of our students come back for another course

We don't offer discounts on our courses. Ever.

What students are saying

5.00
5 star
100.0%
4 star
0.0%
3 star
0.0%
2 star
0.0%
1 star
0.0%
"I liked the content, the presentation, and the direct way it was spoken."
16 Oct 2025
"No friction, supreme didatics.

I'm taking this course as a master's student of CS, studying HPC.

This is my first course on PIKUMA. The professor has a gift for teaching. He breaks down information to the minimal digestible size and goes step by step, explaining every detail with patience. I personally don't feel like I'm studying. My brain feels like it's watching a Netflix series. No need to take a break, it's pure flow. More importantly, this doesn't happen because the content is shallow or easy. It's a purposeful effort from the professor to make it seem easy, just like any student would want.

The content starts from first principles and goes deep afterwards. Compiler books seemed too dry before this course; I'm sure after completing it, I'll be able to face them better."
30 Aug 2025
Eduardo Blázquez González
PhD, Universidad Carlos III de Madrid
"Amazing Course in such a small time! It is amazing all the content this course teaches you in such a very short time. It works as a perfect complement for any compiler book you wanna read, and if some concept is not understood in a book, you can go to the code of the compiler programmed in this course to have a practical idea and being able to continue with the compiler book."
10 Aug 2025
Anton Yarkov
Principal Software Engineer
"This course covers everything you need to start your journey in compilers and interpreters. Gustavo provides detailed introduction including some historical overview that allows to understand the field deeply and build necessary reasoning about some of the concepts. I particularly like the intro into various parsing algorithms and LLVM bonus covered in the end, which makes this knowledge very practical and useful in production.

Compilers and interpreters can be found everywhere - software like browsers, databases, designers, configuration systems, etc etc Interpreters enable it to be flexible enough for the customer needs. It is essential part of all major products.

Nowadays when AI easily replaces simple coding patterns it is essential for engineers to understand low level systems as this knowledge cannot be easily replaced and stays important and valuable. I do recommend the course for every developer out there."
26 May 2025
"Amazing course! I have been stuck in tutorial h*** for a while now and actually sitting down and learning how to do projects is probably the best way to learn how to program. I recommend starting a second language project alongside this course's pinky and make it in another programming language. and even modify the second language to make it your own."
31 Mar 2025

Other similar courses

C++ 2D Game Engine Development

30 hours
  • Learn to make a simple 2D game engine using modern C++, SDL, ECS, and Lua.
raycasting texture c

Raycasting Engine Programming with C

18 hours
  • Write a raycasting engine with textures and sprites using the C programming language.

Game Physics Engine Programming

35 hours
  • Learn how to create a 2D rigid-body game physics engine from scratch with C++.