Grade 7 Computer Science · What a program is

Why a computer takes everything literally

People fill in what an instruction leaves out; a computer does not.

Why the computer never says “got it”

Send a friend the same request twice and they will assume you repeated yourself by accident. A computer will carry it out twice, without asking. Is that a weakness of the machine — or the very reason mistakes in it can be found at all?

Before writing a single line of code, one thing about the other side must be understood: a computer does not understand you. It executes. The difference between the two is the source of nearly every beginner’s mistake, and so we begin there.

Exactly the same words — and two entirely different behaviours.
What was saidWhat a person understandsWhat a computer executes
“Bring a glass of water”A roughly full glass, without spillingAn error — “glass” was not defined
“Add one”To the number we were discussingTo which value? It must be said
“Repeat that”A few more times, roughlyExactly how many times?

Why this is actually an advantage

It is easy to think this property is a limitation, but it is exactly what makes a computer useful. A machine that guessed what you meant would give a different result each time, and could not check itself. A machine that executes exactly what is written gives the same result on every run — and that is what lets you find a mistake: if the result is wrong, the mistake is in the text, and the text is in front of you. The absence of interpretation is what makes debugging possible at all.

print("Hello")
print("Hello")

Example 1 — why “roughly” does not exist

  1. A person is asked to wait “a moment”.
  2. He waits between seconds and a minute, by context.
  3. A computer needs a number: exactly how many seconds.
  4. Anything that is not a number must be made one.

Example 2 — why the same run gives the same result

  1. The program does not guess and has no mood.
  2. The same lines, the same inputs.
  3. So necessarily the same result.
  4. If the result changed — something in the input changed.
Sorting: Can a computer carry out the instruction exactly as written? — 7 items into 2 groups (It can be carried out exactly, A detail is missing that a person would fill in), with a check and a reason for each item.