Hobby Notes written while learning
Source
to Machine.
A small hobby site where I share the notes I take while learning about compilers and programming languages. No profit motive. I'm not an expert; I'm learning too.
Featured Posts
Plain-spoken notes from inside compilers; AI-assisted for now, from an amateur’s notebook.
Learning the Toolchain, Piece by Piece
The pieces that turn code into a running program. None of them is a finished tool; this is a map of what I want to learn.
Compiler
Reads source code, checks it and translates it to machine code. Usually split into a front end, middle end and back end.
Linker
Combines object files, resolves symbols and lays out the executable.
Language Server
Gives the editor completion, go to definition and live error messages.
Debugger
Lets you pause a program, step through it and inspect variables.
Build System
Tracks dependencies and rebuilds only what changed.
From Source Code to Machine Code
Follow a small Rust function through the compiler step by step. Click a stage to see its output.
Lexing: The source text is split into tokens such as keywords, identifiers, types, numbers and operators, each with its position.
Parsing: Tokens become a tree following the grammar. The grey type notes are not added here but later, during type checking; the borrow checker also runs later.
IR: The for loop is lowered to a counted loop over the slice. The slice is split into a pointer and a length; variables still live in memory.
Optimization: Memory slots are promoted to registers (SSA and phi), the loop test moves to the bottom and redundant loads disappear.
Codegen: Instruction selection and register allocation produce machine code. On x86-64 Linux the slice pointer usually arrives in rdi and its length in rsi.
Outputs are simplified for readability: release build, x86-64.
Open Source and Helping Out
There is no public code repository yet. When the first small experiment is ready, it will go up on GitHub.
- Compiler
Reads source code, checks it and translates it to machine code. Usually split into a front end, middle end and back end.
No repo yet
How Can You Help?
For now, the easiest way is through the posts.
- 1Spot a Mistake
If something in a post is wrong or unclear, let me know.
- 2Suggest a Source
Share a book, paper or talk that helped you.
- 3Learn Together
If you are learning too, send your notes or questions.