Skip to content

A Program Is Instructions

A program is a list of instructions. The computer does each one in turn, exactly as you wrote it.

This course teaches the ideas behind every programming language, rather than one language. You do not need a computer to follow it.

We write each idea in pseudocode: plain words for a person to read, not a machine to run. Every real language spells these ideas its own way. The ideas underneath stay the same, and those are the ones worth keeping.

A program is a list of instructions

A program is a list of instructions. The computer starts at the top and does each one in turn. It does exactly what each instruction says. It never guesses what you meant.

Here is the smallest program there is. One instruction, which shows a word.

SHOW "Hello"

Run it and you get:

Output
Hello

That is a whole program. You asked for a word, and you got a word. Nothing else happened, because you asked for nothing else.

Every language has its own way of showing something. BASIC says PRINT. Python says print. C calls printf. We say SHOW. Get close enough to the machine and there is no word for it at all: you put the letters where the screen will find them. The job is the same either way.

The computer does what you say

A computer does not make mistakes the way people do. It follows your instructions exactly. That sounds helpful, and it is. It also cuts both ways: write the wrong instruction, and the computer carries out the wrong instruction perfectly, without complaint.

So when a program goes wrong, start with what you wrote. Nearly every problem you meet in your first months is there. The last unit of this course is about finding it.

When it’s wrong, see why

  • The computer refuses the line. Check the quotation marks. SHOW "Hello has one at the start and none at the end, so the computer cannot tell where the words stop.
  • Nothing happens. You wrote the program but never ran it. A program waits until you tell it to go.
  • You get a message you do not understand. Read it anyway. It usually names the problem and the line it happened on, which is more help than it looks.

What you’ve learnt

  • A program is a list of instructions. The computer follows them in order, from the top.
  • The computer does exactly what you write, not what you meant.
  • Output is how a program shows you something: SHOW here, PRINT in BASIC, and its own way in every language.

What’s next

One instruction is a program. So is a hundred. In Unit 2 we give the computer more than one thing to do, and find that the order matters as much as the instructions do.

You can try this idea by entering real instructions on a Spectrum in Meet BASIC. The lesson explains the Spectrum’s own syntax as you use it.