cadence_learn
think_like_a_programmer / level 01 of 12 ▶ 12 min

it does exactly what you said.

Before any language, any compiler, any code: a computer has no judgment and fills in no gaps. Once you have felt that, half of programming stops being mysterious.

after this level you'll be able to
  • Say what an algorithm is in one sentence, without using the word “computer”
  • Explain why a program does the wrong thing even when nothing is broken
  • Spot the gap in a set of instructions before you run them
the whole idea

it has no idea what you meant

the one sentence

A computer does exactly what you told it to do — not what you meant, not what any reasonable person would have assumed, and it will never stop to ask.

the gap you cannot see
WHAT YOU WROTE 1. forward 2. forward 3. forward …and nothing else. RUNS WHAT THE MACHINE DID ✕ step 3 — into the wall it went exactly as far as you said, and no further
The gap is invisible while you are writing it. Nothing in the list on the left is wrong. It is just incomplete — and the machine has no way to notice, because noticing would require judgment.

This sounds obvious until it happens to you. Every human you have ever given instructions to filled in the gaps for you. Say “grab me a coffee” and a person works out the cup, the route, the door, the money. None of that was in what you said. They supplied it.

A computer supplies nothing. If you leave a gap, it walks straight into the gap — confidently, at full speed, without a flicker of doubt. Almost every bug you will write this semester is a gap you did not know you left.

the word for it

A list of steps precise enough that something with no judgment can follow it is called an algorithm. That is the entire word. It is not a maths thing, and it does not need a computer — a recipe is an algorithm, and so are the steps for tying a shoe.

try it yourself

drive the robot to the coffee

The robot is at the bottom-left and it is facing right. The coffee is top-right. There is a wall in the way. Build a list of steps, then press run and watch it obey you literally.

▤ lab 01 · the literal machine

Click steps to add them. Click a step in your program to delete it. Then press run.

your program is empty — add some steps
Build a program and press run. If it crashes, that is the lesson — not a failure.
when it crashes

Notice what it did not do. It did not stop at the wall. It did not say “are you sure?” It did not go round. You said forward, so it went forward, into a wall, because going into the wall is what you asked for. That is not the robot being stupid. That is the robot being exact.

◈ ask an ai about this

“Why can a computer not just work out what I obviously meant?”

chatgpt ↗ claude ↗

why this is level one

this is the skill your course actually grades

Your course description says the emphasis is on “problem analysis and on the subsequent development of algorithms” and that the major focus of the lectures is “top-down software design.” Read that again. It does not say the emphasis is on C++.

C++ is just the language you will write the steps down in, the way English is the language you would write a recipe in. Knowing lots of English does not make you a cook. Most people who struggle in this course study the language and never practise the thinking — then an exam hands them a problem in plain words and they have nowhere to start.

You are doing it in the right order. Six levels of thinking first, no code, no compiler. Then the language, which is the easy half.

◈ ask an ai about this

“What is the difference between an algorithm and a program? Give me one everyday example of each.”

chatgpt ↗ claude ↗

do this together

the sandwich

☶ two people · 10 minutes · do it out loud

One of you is the computer. Be a terrible, wonderful computer.

person a — the programmer

Write down the steps to make a peanut butter sandwich. Hand the paper over. From that moment you may not speak, gesture, or help.

person b — the computer

Do exactly what is written. Nothing more. “Put peanut butter on the bread” means the jar goes on the loaf — closed, in its jar, on top of the bag.

Swap roles and do it again with a different task. The point lands in about ninety seconds and it never really leaves you: the instructions felt complete when you wrote them. They were not. That feeling — “but obviously I meant…” — is exactly what a compiler error feels like.

what to keep

three things worth remembering

01

It does what you said

Not what you meant. When something goes wrong, the machine is almost never the thing that is wrong.

02

An algorithm is just exact steps

No maths required. If something with zero judgment could follow it, it is an algorithm.

03

The gaps are invisible to you

You cannot see your own assumptions. That is why you test, and why you have someone follow your steps literally.

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

Your instructions say “go forward” three times. There is a wall after two steps. What does the machine do?

02

What is an algorithm?

03

You give someone instructions and they do something absurd. Whose mistake is it, usually?

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