What Actually Happens When Your Code Runs
You can write a little code. You've typed something, pressed Run, and watched it work - or watched it break - without ever being told what happened in between. The file you wrote is just text. The machine in front of you doesn't read English, or Python, or anything that looks like what you typed. So how does a page of words become a thing that does something?
That gap - between the code you write and the machine that runs it - is where a lot of programming feels like magic, or superstition. "Use Go because it's compiled." "Python is slow because it's interpreted." "Watch out for stack overflow." These are real, knowable things, and once you can picture the whole chain - text → translated → running program → CPU - they stop being spells and start being something you can reason about.
This guide walks that chain end to end, in plain language, with pictures.
How to read this
- Want the big picture fast? Read Phase 1 - it's the heart of it: how your text becomes something the machine can run.
- Want it to finally make sense? Read in order. Each phase is one link in the chain, and they connect: how code is translated, then where its data lives while running, then what "running" even means.
The phases
- From Source Code to Something the Machine Runs - your code is text; the CPU runs machine instructions. How a compiler (translate-ahead) and an interpreter (translate-as-you-go) bridge that gap, and the trade-off between them.
- Where Your Data Lives: the Stack & the Heap - when code runs, every value sits somewhere in memory. The stack (fast, automatic, for function calls) versus the heap (flexible, for things that outlive a function) - and what "stack overflow" really is.
- What "Running" Means - your program becomes a process the operating system schedules onto the CPU, using RAM as its workspace. We tie the whole chain together.
Deeper material lives in neighboring guides: how the OS juggles many running programs at once is Processes, Memory & the CPU; how the hardware itself is laid out is CPU, RAM & Storage; and how a program's memory gets cleaned up afterward is Memory & Garbage Collection. Brand new to writing code at all? Start with Programming from Zero.