A computer will do exactly what you told it. Not what you meant, not what would obviously be sensible — exactly what you told it, billions of times a second, without ever once wondering whether that was a good idea.
Ask someone to make you a jam sandwich, and tell them you will follow their instructions exactly. Then do exactly that, and nothing else.
"Put the jam on the bread." Fine — you put the jar on the bread. Jar and all. You were not being difficult; that is what the sentence said. "Open the jar first." With what? Your hands are not mentioned anywhere.
Everyone laughs, and then everyone gets slightly annoyed, and the annoyance is the useful part. That feeling — you knew what I meant — is what programming actually feels like, and it is where every bug you will ever meet comes from.
A program is a list of instructions, in order, for a machine to follow.
That is genuinely the whole definition. Not "a clever thing a computer does." A list. In order. It is close to a recipe — but a recipe is written for a cook who already knows what a pan is, that eggs break, and that stir does not mean stir for eleven hours.
A program has no cook like that. Whatever the machine needs to know has to be in the list, because there is nothing else anywhere.
The computer supplies speed and patience. Every single piece of the thinking has to be supplied by you, in advance, written down.
Here is the part that takes a while to believe. When a program stores a number in a box and you name that box `score`, the machine does not know what a score is. It does not know what a game is. It is moving a number into a slot in its memory, and the word `score` is a label for you — the machine would run exactly the same if you had called it `banana`.
Underneath, a processor only really does a handful of tiny things: put a number somewhere, add two numbers, compare two numbers, and jump to a different instruction. Everything — every game, every video call, every photo filter — is those tiny moves, stacked up in colossal numbers and run billions of times a second.
So the machine is not smart. It is fast, and it is exact, and those two together look a lot like smart from the outside.
Here is a whole program, in words:
Now stop being a person who can see where this is going, and follow it one line at a time. The right column is what is in the box.
You change the program to repeat 2 times and run it. Nothing appears on the screen. What has happened?
That tiny program contained the three moves that nearly every program in the world is built from.
Add "remember this number in a box" and you have the whole toolkit. A flight simulator is not made of different stuff from your six-line program. It is made of a great deal more of the same stuff.
A game shows a health bar. Every time a monster hits you it drops by 10, and at 0 the screen says GAME OVER. Which of the three moves is doing the GAME OVER part?
An instruction only works on a computer if it can be carried out with no judgement whatsoever — no taste, no guessing what you meant, no knowing anything you did not say. Sort each one and read why.
Tap an item, then tap where it belongs
A friend says: "Computers are so smart — mine finished that in under a second." What is the most accurate reply?
You’re previewing as a parent — nothing here is recorded.
The trace is a real program's behaviour: starting at 0 and adding 2 three times gives 6, which passes 'more than 5'; adding 2 twice gives 4, which does not, so the conditional line does not run and nothing is printed. Processor instruction sets are built from a small number of primitive operations — load/store a value, arithmetic such as add, compare, and branch/jump — and modern consumer processors run on the order of billions of clock cycles per second (a 3 GHz chip is 3 billion cycles per second). The jam-sandwich exercise is a long-standing classroom activity for teaching algorithmic precision, not a research finding.