Computer Program

A computer program is a set of instructions that tells a computer what to do. The computer follows those instructions one by one, in order, from top to bottom.

instruction 1  →  run
instruction 2  →  run
instruction 3  →  run
   result

Programs are lists of instructions#

Every program — no matter how complex — is just a sequence of individual steps. The computer doesn’t read ahead, make assumptions, or skip around. It runs instruction 1, then instruction 2, then instruction 3, and so on until it reaches the end.

This is one of the most important things to understand about programming: the computer does exactly what you tell it to, in exactly the order you tell it to.

If you want it to say hello before asking for your name, you write the hello instruction first. If you write them the other way round, it asks for your name first. The computer won’t notice that feels backwards — it just follows the list.

Why we need programming languages#

Computers only understand machine code — instructions written in binary (sequences of 0s and 1s). Writing programs directly in binary is possible but impractical for humans.

Natural languages like English don’t work either, because they’re too ambiguous. “Add a bit of salt” means something to a cook, but a computer can’t act on it — how much is “a bit”?

Programming languages sit in the middle: structured enough for a computer to translate precisely, readable enough for humans to write and understand. When you run your program, a tool called a compiler or interpreter translates your code into machine code the computer can execute.

Common Mistakes#

Thinking the computer understands the program The computer doesn’t understand anything — it just executes instructions mechanically. It has no common sense and won’t fill in gaps. If you forget an instruction, the computer skips it. If you write instructions in the wrong order, the computer runs them in the wrong order.

Thinking programs run all at once A program isn’t a block of text that gets processed as a whole. Instructions run one at a time, in sequence. When something goes wrong, it goes wrong at a specific instruction — which is exactly why you can track down bugs.

Thinking programming languages are like natural language You can’t write show a friendly greeting and expect it to work. Programming languages have strict, precise rules. Every character matters. A missing quote or bracket can stop the whole program from running.

Resources#