page updated on February 06, 2016
In 50 years, computers have gone from the room-sized stuff of the space program and science fiction to devices so small and ubiquitous that they're boring. Your car and microwave, for example, have computing power undreamed of half a century ago. The computer or tablet or phone you're reading this on is so much more powerful than the computers that sent astronauts into space that no one in the Apollo program would have dared to believe they would ever exist.
Despite science fiction predictions (and warnings) that computers would automate away all of the work of humans, humans have more power than ever over computers. Humans are vital to the work of computers—because only humans can program computers. If you'd asked all of those scifi authors how to describe software, they might have waved their hands and given answers about math, science, engineering, and construction. They didn't know. (Think of them trying to explain software maintenance, the idea that working code needs regular attention to keep working!)
Exactly what is programming?
A computer is a simple device that knows how to remember things and how to look up those memories. At its core, that's all it does. It starts out with a blank slate of memory and relies on a human to tell it what to do with that memory. This was true of the first computers and it's true of modern devices; the history of computing shows an increase in the complexity of the mathematical transformations possible.
Your phone—perhaps the one you're using to read this—is countless times more powerful than the computers that sent astronauts to the moon and back. In a couple of human generations, we've seen dozens of generations of computers.
A program is a set of instructions for managing that memory. Whatever you want to do with a computer, you're manipulating a set of electrical symbols the computer understands in a particular way. This is obvious if you're running a calculator program (take 10% off the price of this $43 sweater) and less obvious (but no less true) if you're writing a document. Think about it this way; every word you type has to be in memory somewhere, right? The same goes for a sentence you emphasize as and a word you write as bold. Even the changes you make to move one paragraph here or delete a sentence are themselves stored in memory so that you can hit undo to revert a change you didn't intend.
Ever play the game Monopoly? The rules start simple. You roll the dice, move your token that many spaces around the board, and follow the directions where you land. They're easy to describe in a page or two.
The game never ends quite that simply. Maybe you add some rules, like putting all of the fines collected on the Free Parking space, and the first person who lands there gets to collect the money. Maybe you let players take loans from the bank without mortgaging properties.
Maybe two players disagree over the interpretation of a specific rule, and you have to read the rule out loud and discuss what a single word in that rule really means, and why the game designers chose that word over another. Sometimes you agree on one interpretation with one group of players and another interpretation with another group of players.
The rules—as simple as they might seem—produce a framework in which countless players have played innumerable games, each one a little different. One player strategy is not another. One roll of the dice can change the entire game.
Programming is like that. Programming means implementing the rules in such a way that complicated systems are possible. Programmers discover and build systems out of these kinds of rules. Good programmers minimize the number and complexity and potential ambiguity of the rules to maximize the flexibility, ease, and correctness of a system. In a very real sense, programming means coming up with the rules for a process and combining them in a coherent way. These rules can be simple or complex, but they're usually part of a larger system in which the interaction of multiple rules leads to consequences intended and not!
Programming isn't a series of equations. It's like equations, but it's also a little messy where it interacts with the real world. It has to deal with the fundamental ambiguities of human language and communication. (If you think quantum mechanics is weird, try linguistics sometime!)
For every right triangle, the old Greek thinker Pythagoras discovered, the sum of the square of the lengths of the sides which make the right angle is equal to the square of the length of the remaining side. (You can prove this trivially yourself.) Every triangle which matches this property is a right triangle. Every triangle for which this is not true is not a right triangle. Mathematicians try to discover and express relationships and identities like this every day.
If telling a computer what to do is like coming up with the rules to a board game, it's also like discovering the invariant properties of a complicated system. "It's impossible to withdraw more money from the ATM than you have in your savings account," one program might say. "It's impossible for the airplane to take off while the cockpit door is open," another might explain.
Computer programs in the real world often have to be more complicated than the rules of a board game. They have to deal with objects in the real world: money, cars, books, employees, paychecks, automatic sprinkler systems. Even though a computer program is ephemeral and untouchable, it has to deal with reality. "If the sprinkler system runs for more than 20 minutes, it'll overflow the pipes and cause damage to the floorboards, so cut it off at a maximum of 19 minutes." These are simple machines, but their interactions are anything but simple. They're logical, yes. On their own they're small but functional. Together, they make complex systems.
These rules may seem arbitrary, even when they have their roots in the real world, but they're anything but arbitrary in the world of the computer program. They're the rules by which the world of the program operates. Writing a program often means designing an ideal version of the real world and setting up these rules that cannot be violated.
If you know that a right triangle always has the property that follows the Pythagorean theorem, you can build up more complicated systems. You know something that will never change, and you can make more and more assertions based on the combinations of these simple rules. Just like Monopoly can't only be "Roll the dice" but has to include buying and selling properties and paying rent and passing Go to collect $200, any computer program which does anything useful in the real world must make assertions about the world it inhabits and define a set of rules built on rules built on rules from there.
Good programmers see these patterns. Great programmers exploit them.
A computer program must touch the real world somehow. Even if it's as simple as giving you a calculator so you don't have to do long division in your head, it has to follow the rules of the real world, where 27 divided by 3 is 9. A calculator that couldn't get that right would be awkward and difficult to use.
Similarly, a program that has inconsistent rules or rules which don't match your expectations will be frustrating (at best) to use or impossible or expensive or dangerous (at worst). A space probe that doesn't understand gravity might smack into a planet. A spreadsheet that silently forgets about compound interest may cost you lots of money. A brake sensor that can't detect temperatures above a hundred degrees might not warn you of a failure in time to react quickly enough. A music program that plays the wrong notes isn't even worthwhile for jazz. A drawing program that can't draw straight lines isn't worth the binary bits it's made of.
A computer program always touches the real world somehow, else why would it be written? Even a program written for the sake of writing it has the real effect of generating pleasure by being a piece of art or the comforting diversion of a hobby. Real life always finds a way to intrude into our carefully crafted models, and our software is all the better for it.
A program need not concern itself with the laws of physics which bind the real world; a game might have a zero gravity mode where players bounce around in space like balloons. Yet a program to calculate the amount of cement necessary to use in bridge pilings to support rush hour traffic across a bridge needs to follow the real world to a great degree.
But what is programming? It's:
Programming a computer requires discipline and patience and practice and study—like any creative act. It is part logic and proof (like math) and part design (like producing a board game that is easy to understand but fun to play). It can be difficult and enjoyable at the same time. It's not easy to define what programming software feels like, as it's different from every comparison we make. Yet it's similar too.
Like any other worthwhile human endeavor, writing a program is not easy, but crafting good software is essential to multiplying the power of human creativity and effort to meet the needs and realize the goals of our modern world.