cadence_learn
think_like_a_programmer / level 07 of 12 ▶ 14 min

no magic in the box.

Memory, a processor, and a translator called a compiler. Step a real machine one instruction at a time, then watch one missing semicolon stop everything.

after this level you'll be able to
  • Describe what a processor does, in one sentence, with no hand-waving
  • Say what a compiler is and why one typo stops the whole program
  • Explain the difference between a compiled and an interpreted language
the whole idea

there is no magic in the box

the one sentence

A computer is a machine that reads one instruction from memory, does it, moves to the next, and repeats — billions of times a second, which is the only reason it looks clever.

the whole machine, in one picture
STORAGE the drive slow · remembers when power is off LOADS MEMORY — NUMBERED BOXES 1 put 10 in box A 2 put 5 in box B 3 add B to A 4 show A your program lives here, as data, beside the numbers FETCH THE PROCESSOR FETCH DO IT NEXT it can hold only a couple of values at a time Everything a computer has ever done is this loop, a few billion times a second. There is no other trick and no extra layer. Memory forgets the moment power goes — which is why “did you save it?” is a question at all.
Three parts, one loop. Storage remembers slowly, memory holds what is in play and forgets on power-off, and the processor does one small thing at a time — forever.

Your course description calls this “the fundamentals of systems”. It matters more than it sounds, because everything strange that happens to you later — why your program crashed, why it was slow, why the compiler refused — comes from this machine and not from magic.

Three parts and you have most of it. Memory is a long row of numbered boxes, and it forgets everything when the power goes. Storage is the drive, which is slow and remembers. The processor is the part that actually does things, and it can only do very simple things, one at a time.

the part that surprises people

Your program lives in memory as data, right next to the numbers it is working on. The instructions are not somewhere else. They are just more contents in more boxes, and the processor walks along reading them.

try it yourself

step the machine one instruction at a time

Memory is on the left, holding a tiny program. The processor is on the right. Press step and watch it fetch one instruction, do it, and move on.

▤ lab 07a · the machine

This is the fetch–execute cycle. It is all a processor ever does.

memory — numbered boxes
the processor
Idle. Nothing is happening until you press step.
BOX A
BOX B
screen: (nothing yet)
Five instructions. The processor has no idea what any of it is for — it just does box 1, then box 2, then box 3.
◈ ask an ai about this

“What is the fetch-execute cycle, and what is the difference between memory and storage?”

chatgpt ↗ claude ↗

the bit that is new in c++

you do not write what the machine reads

all or nothing
1 · YOUR TEXT show "hello"; 2 · COMPILER reads EVERY character first ALL CLEAN ONE TYPO 3 · MACHINE CODE 01001000 01101001 4 · IT RUNS hello error: expected ‘;’ before end of line nothing was produced · nothing ran · not even the first line A compiler error is punctuation, not judgment. It says nothing at all about whether your idea was any good.
It is all-or-nothing, and that is the part nobody warns you about. C++ translates the whole file before a single line runs — so one missing semicolon produces no program at all.

Here is the thing that trips people up in week one, and it is not a concept — it is a step in the process nobody warned them about.

The processor cannot read what you type. It reads numbers. So between you and the machine sits a program called a compiler, whose job is to translate everything you wrote into machine instructions, all at once, before anything runs. If it cannot translate one single character of it, it translates none of it and nothing runs at all.

▤ lab 07b · from your text to something that runs

Press compile. Then break it on purpose and press compile again.

show "hello";
1 · what you typed

Text. Readable by you, meaningless to the machine.

2 · the compiler

Reads all of it and checks every character.

3 · machine code

Numbers the processor can actually do.

4 · it runs

Only now does anything happen.

Press compile and watch it move through the four stages.
why this matters for your morale, not just your marks

In week one you will hit a wall of compiler errors over a missing semicolon, and it feels like the machine hates you. It does not. A compiler error means nothing ran — not that your thinking was wrong. It is the strictest possible proofreader, complaining about punctuation before it will even look at your ideas. Everyone gets these. Every day. Forever.

◈ ask an ai about this

“What does a compiler actually do, and why does one missing semicolon stop my whole program from running?”

chatgpt ↗ claude ↗

one more distinction

compiled and interpreted

Some languages skip the translate-everything-first step. Python and JavaScript are interpreted — another program reads your code line by line as it goes. C++ is compiled — translated whole, in advance, into a file the machine runs directly.

The trade is real and it is worth knowing which side you are on. Compiled is faster when it runs, because the translating already happened, and it catches whole categories of mistake before anything starts. Interpreted is faster to try things in, because there is no waiting, but a typo on line 400 will happily run for ten minutes before it finds it.

what this means for you this semester

You are learning a compiled language, so the compiler is going to argue with you before every single run. Friends learning Python will not have this and it will look like they are moving faster. They are just meeting their mistakes later.

do this together

be the processor

☶ two people · 10 minutes · index cards or scrap paper

Write a tiny program across separate cards. One card, one instruction.

person a — memory

Hold the cards in a numbered stack. Hand over exactly one when asked, in order. Never explain what is on it.

person b — the processor

Ask for the next card, do exactly what it says, put it down, ask for the next. You may only hold two numbers in your head at a time.

Then try one that says “go back to card 2” and watch a loop appear out of nothing but ordering. Two numbers in your head is not an arbitrary rule — a real processor works on a tiny handful of values at a time and keeps everything else in memory. That constraint is why programs are written the way they are.

what to keep

three things worth remembering

01

Fetch, do, repeat

That is the entire job of a processor. Everything else is speed and scale.

02

Your program is data too

Instructions sit in numbered memory boxes right beside the numbers they work on.

03

A compiler error means nothing ran

It is punctuation, not judgment. It says nothing about whether your idea was any good.

check yourself

3 questions before you move on

Not recall — these are the shapes an exam actually uses. Every answer below was produced by compiling and running the code, so if you disagree with one, the compiler is the one to believe.

▢ check yourself3 questions

Have a real go before revealing. Being wrong here is worth more than being right in three weeks.

01

What does a processor actually do?

02

You leave out one semicolon in a 200-line program. What gets built?

03

What is the difference between memory and storage?

answered: 0 of 3right first time: 0
Stuck? Peter reads these personally and replies to your email.
Ask Peter →