Concepts explained
How to Speak to a Machine
The phrase 'computer language' sounds like something made for machines. It is the opposite. The machine understands exactly one thing — numeric orders — and every programming language was built for humans to read. And the first program was written before any computer existed.
As the first two pieces showed, the inside of a computer is a heap of switches, and the orders that move them are themselves rows of on and off — numbers. 'Move this number there' is some code; 'add these two' is another. This is called machine language.
In the early days, people handled those numbers by hand: holes punched in paper cards. A hole meant 1, no hole meant 0. One program was thousands of cards, and dropping the stack meant ruin.
The first program came before the computer
Astonishingly, the first person to write a program never saw a computer. She could not have. None existed.
In nineteenth-century England a man designed a calculating machine of gears and wheels, and it was never finished. But a mathematician studying its plans wrote out, for that non-existent machine, a list of orders — in sequence, loops and all.
She saw further still: the machine need not handle only numbers, she wrote — given the rules, it might handle music. The world took a century to catch up with that sentence.
Handing the translation to the machine
After the punched cards, people gave the numeric orders short nicknames: MOV for move, ADD for add. Easier to memorise, but still the machine's terms.
In the 1950s one programmer took the next step: write sentences close to human language and make the computer itself do the converting into numbers. Build a translator program.
The reception was cold — computers do arithmetic, how would one 'understand words'? She was right. Every programming language today stands on that translator. Humans write near their own language; the translator renders it into the machine's numbers.
A little further in
The machine does exactly what it is told
The strangest thing about speaking to a computer is the total absence of common sense. Follow the shampoo bottle: 'lather, rinse, repeat.' A person stops after a round or two. A computer repeats forever — no one said stop.
Most program errors are of this kind: the machine is not broken; it did precisely what it was told, and what it was told was wrong. Which is why half of programming is not writing but working out what it was you actually said.
A line of words takes on lives
At first, programs ran errands of arithmetic. By the 1960s a crewed spacecraft was flying on one. The weight of a line had changed.
As the lunar lander descended, alarms sounded: the computer was being flooded with more work than it could carry. But its program carried a provision written in advance: when overloaded, drop the less important work and do what the landing needs first.
The computer did as told, shed the lesser tasks, and the lander came down safely. Saying in advance what to do first when things go wrong — the woman who led that team gave this work the name 'software engineering'.
One strangeness remains. Swap the program and the same machine does something entirely different — calculator, then writing desk, then game board. How can one machine become anything? The next piece begins with that question.
The question that remainsLearning to speak precisely to a machine with no common sense — is that learning the machine's language, or learning to put your own thoughts in order?