— Peter K Joseph

Articles

Writing on compiler design, computer science, and software engineering.

Basics of Compiler Design

6-part series
40 min total
Part 1

From Code to Program: Unveiling the Hidden Stages of Compiler Design

A compiler is far more than a translator. It's a six-stage pipeline that breaks your source code apart, checks its meaning, and rebuilds it as machine instructions your CPU can actually run.

7 min · Mar 2023
Part 2

Breaking Down Words: The Art of Lexical Analysis in Compiler Design

Before a compiler can understand your code, it must first learn to read it. Lexical analysis is how raw characters become structured tokens — the vocabulary every subsequent stage depends on.

7 min · Mar 2023
Part 3

Parsing the Structure: How Syntax Analysis Turns Tokens into Trees

Tokens alone tell the compiler what words exist. Syntax analysis tells it how those words fit together — using grammar rules to build the hierarchical structure every subsequent stage depends on.

6 min · Mar 2023
Part 4

Making Sense of Code: What Semantic Analysis Actually Checks

A programme can be perfectly grammatical and completely nonsensical. Semantic analysis is where the compiler goes beyond structure and starts asking whether the code actually means something valid.

6 min · Mar 2023
Part 5

The Middle Layer: Why Compilers Generate Intermediate Code

Going straight from source code to machine code would be both impractical and fragile. Intermediate representation is the bridge that lets the same front end target any machine, and the same back end compile any language.

6 min · Apr 2023
Part 6

Doing More With Less: How Compilers Optimise Your Code

Code optimisation transforms intermediate code to run faster and take up less space — without changing what the programme does. It's one of the most intellectually rich parts of compiler design.

8 min · Apr 2023