Picture a cook working from a recipe card, one line at a time: read the next instruction, figure out exactly what it's asking for, then actually do it, before moving to the next line. A CPU runs a running program using that exact same repeating pattern — read, figure out, do — applied to one tiny instruction at a time, over and over, billions of times every second.

The formal names for those three steps are fetch, decode, and execute. Fetch retrieves the next instruction from memory — the equivalent of the cook's eyes moving to the next line on the recipe card. Decode figures out what that instruction actually means and what it needs — is this an addition, a comparison, a request to move data from one place to another, and which specific pieces of data does it need to work with. Execute actually performs that operation — doing the addition, making the comparison, moving the data — using a part of the chip built specifically to carry out that category of operation.

A single program instruction that reads like one simple line of code — "add these two numbers" — still has to go through this full fetch-decode-execute cycle, and a real program is built from an enormous number of these small instructions chained together: a single line of code in a language like Python or JavaScript typically compiles or interprets down into several to dozens of these tiny CPU-level instructions, each one going through the complete cycle on its own.

What makes this loop feel instantaneous rather than sluggish is raw repetition speed rather than any single step being smart. A modern CPU can complete billions of these fetch-decode-execute cycles every second, and additional hardware tricks — like starting to fetch the next instruction before the current one has even finished executing, called pipelining — squeeze even more of these cycles into the same span of time by overlapping their steps instead of running them one at a time, back to back.

The reason this three-step loop matters to understand, beyond raw curiosity, is that it's the honest floor underneath every abstraction layered on top of it — a function call, a loop, an if-statement, an entire framework, all eventually get translated down into a long sequence of these small, repetitive fetch-decode-execute cycles. Nothing about the CPU itself is "understanding" a program's logic in any richer sense than this — the intelligence lives entirely in how a compiler or interpreter breaks a program down into the right sequence of these small steps in the first place.

The fetch-decode-execute cycle, in plain language.

StepWhat It DoesRecipe-Card Equivalent
FetchRetrieve the next instruction from memoryLook at the next line on the card
DecodeFigure out what the instruction is asking forUnderstand what that line means
ExecuteActually carry out the operationDo what the line says
FetchDecodeExecute
The fetch-decode-execute cycle — this loop repeats billions of times a second.