How Code Works
Tap an idea to open it — none of this needs a computer to understand What a Program Is · Order of Steps · Loops · Conditions · Variables · Functions · Bugs & Debugging · How Machines Hold Things · Algorithms · The People Who Made It · Input and Output · Lists and Arrays.
Ages 11–13
What's inside
What a Program Is — orders a machine obeys without understanding
A program is a list of instructions written so exactly that a machine can carry them out without knowing what any of them mean. That sounds cold, and it is the most useful thing to understand about it: the machine brings speed and obedience, and you bring every single scrap of the thinking. Nothing in a program is obvious to it, because nothing is obvious to something that cannot guess.
Order of Steps — same steps, different order, different result
Instructions are carried out one after another, top to bottom, and that plain fact carries far more weight than it looks. Each step changes the situation the next step lands in, so a list of orders is really a chain, not a pile. Shuffle the chain and you often do not get a worse answer — you get a completely different one.
Loops — write it once, run it a thousand times
A loop is the instruction “do this part again”. It exists because repeating work is what machines are best at and what people are worst at, and because a hundred copies of the same line is a hundred chances to make a typing mistake. Getting a loop right means answering two questions honestly: what repeats, and what makes it stop.
Conditions — if this is true, take that road
A condition is a question with only two possible answers, and the machine takes a different path depending on which one it gets. This is what lets one program behave differently on a Tuesday, in the rain, or when the battery is low — without anyone rewriting it. Every clever-looking response a device gives you is, underneath, a pile of these yes-or-no forks.
Variables — a named box whose contents can change
A variable is a labelled place where a program keeps something it will need again. The label stays put; whatever sits inside it can be replaced whenever you like. That split between the name and the thing is one of the quietest and most powerful ideas in the whole subject, because it lets you write rules about things you do not yet know.
Functions — name a piece of work, then just say the name
A function is a chunk of work that has been given a name, so that from then on the name is enough. It is the difference between describing a whole journey and saying “take the bus”. Once you can wrap steps up and label the bundle, a program stops being one endless list and becomes a set of ideas built on top of each other.
Bugs & Debugging — a fault is information, not failure
A bug is the gap between what you meant and what you actually wrote. It is not a sign that you are bad at this; it is the ordinary, expected, everyday state of unfinished work, and the whole profession is organised around finding them. What separates a beginner from someone experienced is not making fewer mistakes at the start — it is having a method for cornering them.
How Machines Hold Things — a photo, a song and a name, all as numbers
Everything a machine keeps has to be turned into numbers first, because numbers are the only thing it physically has. This is not a secret code and nothing is being hidden — it is a translation everyone agrees on in the open, and the interesting question is always what gets lost on the way across.
Algorithms — a precise recipe — and some cost far more than others
An algorithm is a recipe written so precisely that following it always gives the right answer and always finishes. That is the whole definition. What makes the subject worth studying is that two recipes for the very same job can differ enormously in how much work they demand, and the difference only becomes obvious when the job gets big.
The People Who Made It — ten real lives, ten checkable contributions
Computing was not handed down by a lone genius. It was assembled over two centuries by mathematicians, engineers, navy officers, teachers and code-breakers, in several countries, and a great many of them were women at a time when they were rarely credited. Here are ten of them, with what they actually did and when.
Input and Output — the machine's senses and its voice
A program shut off from the world would be useless: it needs a way to receive something and a way to hand something back. We call these input and output, and once you learn to see them, every gadget in your house splits neatly into the two. The doorbell takes a press and gives a chime; the kettle takes a switch and gives heat.
Lists and Arrays — many things in one named place
Sooner or later you need to keep not one thing but a whole row of them: every score in a game, every name on a register, every note in a tune. A list gives all of them a single name and a set of numbered slots, so the program can reach any one instantly. It is the difference between thirty loose socks and a drawer with thirty labelled compartments.
Keep exploring
Other languages
Loading LeoNes…