Chapter 1

Why you should learn to program

The Mystique of Programming
One of the oddities of the personal computer revolution has been its failure to dispel the myth of the programmer as genius. Most people regard programming to be a kind of black magic accessible only to the high practitioners, the “real” programmers. We commonly lump programmers into the same category with neurosurgeons, nuclear physicists, and astronauts. Each of the latter three professions is immensely difficult, requiring long and careful training. Those who master such jobs merit a respect bordering on awe. Moreover, there are not halfway states in these three fields: either you make it or you fail. We don’t have amateur brain surgeons, nuclear hobbyists, or weekend astronauts.

But programmers do not belong in the same category with neurosurgeons, nuclear physicists, and astronauts, even though they go to great lengths to give that impression. Anyone who has been exposed to computers can testify to the dense fog of jargon that seems to shroud the machines in mystery. True, every special group of people creates its own special subset of the language; it’s a normal means of establishing a group identity and often simplifies communications. But of all the groups I have encountered, programmers have the most singular lingo. The jargon of programming goes far beyond the reasonable need for handy terms that precisely describe complex concepts unique to the group. Why, for example, should a programmer “architect the program’s user interface” instead of simply “designing how people use the program”? Why do programmers talk about “CPU cycles” as a measure of time when they aren’t actually counting those cycles? Why don’t they simply talk about time?

The answer to these questions is that programmers have developed a culture that prides itself in a sharply defined hierarchy. It is a highly structured meritocracy, with the highest positions reserved for those most knowledgeable in the arcane ways of computers. The members of this meritocracy wear no badges of rank, no feathered plumes, no sashes or medals. They carry their rank in their vocabulary; they dazzle with an opulence of acronyms.

Another aspect of this culture is its exaggerated sense of taste and discernment. Tell a programmer that you prefer BASIC; it’s like telling a Jehovah’s Witness that you worship Satan. Prepare yourself for a true fire-and-brimstone sermon on the evils of BASIC. BASIC, your programmer friend will tell you, is not merely a slow language or an unstructured language; no, it is an execrable language, and trashy language. Only peasants use BASIC. You’ll get similar reactions about anything else about computers. Hardware? Brand X was brought down from on high by Moses himself; everything else is rank trash undeserving of the name “computer”. Operating systems? Anybody who doesn’t use XXX operating system is a simpleton.

Guess where all this puts you, the nonprofessional? You haven’t even heard of this wonderful operating system or that fabulous piece of hardware. If only simpletons and perverts use other products, you must be an even lower creature not to have heard of them. Perhaps you’d better slink off before you are exposed for the presumptuous fraud you are. Leave programming to the experts who know what they are doing. Right?

Wrong! Programming is not like neurosurgery, nuclear physics, or astronautics. Programming is like writing, woodworking, or photography. Anybody can do it. Doing it well, doing it like an expert – that takes a lot of work, a lot of experience, and a lot of talent. But anybody who can write a comprehensible paragraph can write a workable program. All it takes is a computer and some time.

Two Wrong Reasons for Learning to Program
Given that learning to program is within most people’s intellectual grasp, the next question to consider is, why should anyone bother? Before I answer that question, I must first dispel two commonly cited (but incorrect) reasons for learning to program.

The first reason has bounced around in countless expressions. Computers are everywhere. They’re in your car, your kitchen, and someday there will surely be a computer in your commode. Why, you won’t be able to flush the toilet if you can’t program. A variation on this theme has shown up in television commercials. Perhaps you’ve seen them: You are standing knee-deep in snow. You are dressed in rags. You are shivering; your teeth are chattering. Looking through the nearby window, you see warm, happy people, talking and laughing, talking about computers. Someone notices you, and with a mixture of pity and contempt they close the drapes. You’re out in the cold because you never learned to program! Your parents never bought you a Brand X computer!

This may be what some computer manufacturers want you to believe, but it just isn’t true. This argument is based on naive assumptions about the relationship between people and technology. No technology, no matter how useful, makes any headway into the mainstream of society until it is accessible to the average person.

A second dumb reason for learning to program refers to the myriad employment opportunities that will be available to those graced with the skill of computer programming. Perhaps people have in mind the stunning newspaper accounts of sixteen-year-old whiz kids who made their first million before their Junior Prom. The fact is, most of those newspaper stories were grossly exaggerated. For every person who has gotten rich writing programs, there must be thousands slaving away on a typical white-collar salary. It certainly beats sweeping floors, but I can assure you that nobody should enter programming to get rich.

Some Good Reasons for Learning to Program
Why, then, should anybody learn to program? I can give you several good reasons. The first is recreation – and I’m not talking about computer games. I refer instead to the creative enjoyment one derives from writing one’s own program. It might seem strange to suggest that someone would go to all the trouble of writing a computer program for the sheer fun of it. But consider the range of similar activities that people undertake for recreation: photography, pottery, painting, music – the list is very long. Every year people spend billions of dollars and millions of hours on such hobbies.

For example, when Uncle Fred and Aunt Etna go to San Francisco, they stop by the Golden Gate Bridge where Uncle Fred takes a snapshot of Aunt Etna standing in front of the bridge. The lighting isn’t particularly good, and the wind keeps dislodging her hat, and three brats are strangling a seagull in the background, but Uncle Fred doesn’t mind. He could step into any tourist shop and purchase a picture-postcard of the Golden Gate Bridge, taken by a professional photographer in an airplane on the one day of the year when the fog and the light are perfect. But he wouldn’t value that postcard as much as the picture he took all by himself. He figured the lighting, the framing, and the composition; it’s his little work of art and he’ll take it over the professional’s picture any day.

Amateur programming is the same as amateur photography. It is a creative exercise and is therefore fun. Moreover, programming offers a tremendous range of creative possibilities. Most other creative outlets impose constraints on your efforts. Either it costs too much, or it’s simply impossible with the materials available. Sure, you could write a great symphony, if only you had a symphony orchestra to play it. You’d love to make a fun movie, but you don’t have the cameras, equipment, laboratories, actors, or stage. 

Amateur programming, on the other hand, is not so constraining. You can write a program about anything you want. Spaceships, blackjack, accounting books, wine – if you can imagine it, you can write a program about it. Computer programming is limitless in scope because its expression is not tied to a physical medium like clay or paint or photographic film. A computer program is an assembly of thought and imagination captured in much purer form than we can achieve with other media. There are constraints, it is true, but like a young bird on its first successful flight, the constraints are less of a concern than the possibilities.

The second reason for learning to program is that it will teach you the importance of clear communications. This is a lesson that I did not learn until I was well into my twenties. When I was younger, I would shoot off my mouth, propelling myself into stupid predicaments at which I can now laugh only because many years have passed. At the time, I angrily blamed these catastrophes on the blindness of my seniors, who obviously lacked the insight to recognize my genius. I now realize that these disasters arose because I did not take the responsibility to express myself clearly.

It’s not so easy to blame the computer when you fail to communicate clearly to it. The young hothead can’t blame the computer when his bad input generates an error message. He may rant and rave, but in his heart he knows that the computer is not “out to get him” or “always trying to trip him up”. (How many times do parents hear those lines?) When the temper tantrum ends he sits down and mutters to himself, “Well, let’s figure out what I have to say to this thing to make it do what I want.” 

The good thing about this experience is that the computer will eventually respond. If the hothead can only get his inputs right, the computer will do whatever he wants it to do. The lesson learned from this experience is important because people are much the same: they will do almost anything for you, but you’ve got to make the effort to communicate clearly. If only I had known that twenty years ago!

The most important reason for learning to program, though, concerns the way that it will change your thinking. I maintain that learning to program will make you a better thinker. To explain why, I’ll have to digress for a moment and talk about language.

I once had a crusty old English teacher who loved to embarrass his students. Each time an assignment was handed in, he would select the worst blooper of a sentence from the assignments and read it out loud, using voice intonation to accentuate the absurdity of the blooper. Everybody in the class (save for one) would howl with laughter at the inanity. When my turn came, I lacked the wisdom to keep my mouth shut; no, I had to dig my hole deeper. “That’s not right,” I argued, “I know what I’m talking about, and that’s not what I meant to say.” To which my teacher retorted, “If you can’t say it, you don’t know it.”

That English teacher had expressed one of the fundamental truths of human existence. Thought and language are often intimately associated. The expression of a thought is not merely a postscript to the process of thinking the thought in the first place. It’s not as if our thoughts exist and grow in some pure, ethereal “thoughtworld”, devoid of any manifestation, until such time as we choose to pluck one out of the mist and condense it into base words. No! The act of expressing a thought is part and parcel of the thinking itself. Language is the vehicle of thought.

This implies that the nature of our thinking is shaped by the nature of the language we use. For most readers of this book, that language is English. English is a powerful and expressive language. It is blessed with a vocabulary three or four times larger than that of most other languages. It is also blessed with an unparalleled flexibility. We speakers of English warp and twist the language to suit our every whim. We make puns, many of them strained. We coin a torrent of new words with wild abandon. Advertising people routinely put the language through unbelievable torture tests. And we shamelessly steal expressions from other languages. (The French are the longest-suffering victims of this last crime, yet they seem unappreciative of our attempts at reimbursement with such gems as “jeans” and “burger”.) 

Through all of this abuse, the English language performs with truly English aplomb. It readily warps and twists to conform to all the ridiculous demands we make upon it. It is the “one size fits all” language, the Gumby of languages. This flexibility bestows upon the English language vast power to express almost any new idea that comes along.

Yet, in one respect, English fails us. Sometimes we need to think with absolute precision, with hard, unyielding logic. Sometimes our thoughts must be disciplined and rigorous. On these occasions, flexibility becomes ambiguity, and plasticity becomes imprecision. When one word, “dig”, can mean three completely different things (to excavate, to insult, or to appreciate), it loses all value for absolutely precise expression.

I experienced this limitation of English when I taught college physics. Oftentimes my students, struggling with difficult concepts, would throw their hands up in frustration and confess that they just weren’t logical enough to understand physics. Their admission reflected some truth and some falsehood. It is false to assert that a human being is not smart enough to understand physics. It’s not as if there were some section of the brain labelled “Logical Thinking” that shows up as only a void in some brains. It is true that some of my poorer students were not well-equipped to learn physics, but their deficit was one of language, not of mind. Trying to think logically with the English language is like trying to cut down a tree with a hammer – it’s the wrong tool for the job.

What we need is a different language, a language that expresses precise, rigorous thoughts clearly and simply. I offer for your consideration a computer language, any computer language. Computer languages are ideal tools for disciplined thinking, for they are so emphatically narrow-minded. Every word in a computer language means exactly one thing and only one thing. Words are put together to form commands according to a simple set of rules for which there are no exceptions and no variations. Computer languages are utterly useless for the general-purpose work that human languages must handle, but they are much better-suited for the special task of rigorous thinking.

Consider, for example, the expression of one of the fundamental laws of physics, Newton’s law of gravitation. In English, the law looks like this:

“The gravitational force between two point masses is directly proportional to the product of their masses and inversely proportional to the square of the distance between them.”

The gravitational force between two point masses is directly proportional to the product of their masses and inversely proportional to the square of the distance between them.

Sounds pretty imposing, doesn’t it? You probably have to read it a few times to figure out what it’s saying, don’t you? Since you can’t understand this mouthful, you must be dumb, right?

Not necessarily. Consider now the way we would say the same thing in a computer language:

force = gravitationalConstant * mass1 * mass2 / separation**2

Now, if you can’t read computerese, this might look just as bad as the upper statement. But I’ll ask you to use your imagination for a moment. If you were equally unfamiliar with English and computerese, and I presented you with both statements, which do you think would be easier to learn: the long unwieldy one or the short simple one?

A language is a vehicle for exploring intellectual territory. English is like a dune buggy; it’s tough, it’s resilient, and it can cover a lot of territory. But a computer language is like a boat; it can take you to places you never dreamed existed. You’ll find your initial attempts at learning slow and tedious. After all, any language, human or computer, is frustrating to learn at first. But once you get rolling, you’ll experience an exhilarating sense of discovery as you chart new mental territory and think with a clarity and precision you had never thought was within your reach. You should learn to program, and do it now, for ultimately learning to program will do more for you than all the computer games and spreadsheets and word processors in the world. It will make you a better thinker.