Instructions, and nothing but
What Is a Computer Program?
A program is a list of instructions so precise that something with no understanding at all can follow them.
-
Step 1 of 5
The computer understands nothing.
It cannot guess what you meant, notice that a step is silly, or skip an obvious mistake. It does exactly what it is told, in order, which is why programs are so fussy to write.
-
Step 2 of 5
Three ideas cover almost everything.
Do this, then that. If something is true, do this instead. Keep doing this until something changes. Nearly every program ever written is those three, nested inside each other.
-
Step 3 of 5
A repeat is where the power is.
A person writing out ten thousand names would take a week. A loop does it in a moment, and the instruction to do so is three lines long whether it is ten names or ten million.
-
Step 4 of 5
Bugs are usually correct instructions for the wrong thing.
The computer did precisely what it was told; the trouble is what it was told. That is why programmers spend more time reading and testing than typing.
-
Step 5 of 5
Underneath, it is all switches.
The words a person writes are translated down into millions of tiny on-or-off switches flipping. Every program, however clever, ends up as switches — just an enormous number of them.
The first program is generally credited to Ada Lovelace, written for a machine that was never actually built.
The short version
A program is exact instructions run in order, with tests and repeats — and the computer follows them without understanding any of it.
Try it yourself
Write instructions for making toast, then have someone follow them literally and stupidly. The gaps you find are bugs.
Topics