New: Try Voli The Bear, Fast package manager (and not only) for Windows
All topics / What Actually Happens When Your Code Runs

What Actually Happens When Your Code Runs

The journey from the text you type to a living program: how source code gets translated into machine instructions, where your data lives while it runs, and what 'running' actually means to the operating system and CPU.

Download EPUB
  1. From Source Code to Something the Machine Runs Your source code is just text; the CPU only runs machine instructions. A compiler translates the whole program ahead of time; an interpreter translates and runs it line by line as it goes - and that one difference explains most of the trade-offs you'll hear about.
  2. Where Your Data Lives: the Stack & the Heap While your program runs, every value lives in memory in one of two places: the stack - fast, automatic, tied to function calls - or the heap, flexible and for data that must outlive the function that made it. 'Stack overflow' is what happens when the stack runs out of room.
  3. What "Running" Means When you run a program, the operating system loads it into RAM and turns it into a process - and the OS then schedules that process onto the CPU, which executes its machine instructions a step at a time. This ties the whole chain together: source → translated → process → CPU executes.