
I Built a Programming Language with an LLVM Backend at 15. Here's How It Actually Works
I wanted something with Java's clean syntax, Rust's memory safety, and C's raw speed. Nothing out there gave me all three so I just built it myself. That's Apex. A compiled, statically typed language that compiles to native machine code through LLVM. Not an interpreter, not a transpiler. A real compiler, written in Rust, finished in about a month. Here's how the whole thing works and what actually hurt building it. -- The Pipeline Every compiler is just a chain of transformations. You keep transforming source code until you get something the machine can run. Source (.apex) → Lexer → Parser → AST → Type Checker → Borrow Checker → LLVM Codegen → Native Binary Each stage does one thing and hands off to the next. Lexer Reads raw text, turns it into tokens. KEYWORD_IF , INTEGER_LITERAL , LBRACE . Nothing clever, just recognition. Smallest stage, but if you get it wrong everything downstream breaks in confusing ways. Parser and AST Takes the tokens and builds an Abstract Syntax Tree. A tree
Continue reading on Dev.to Beginners
Opens in a new tab




