Why you should learn to program


The Mystique of Programming
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 practice.

Given that learning to program is within most people’s intellectual grasp, the next question to consider is, why should anyone bother? It’s certainly true that computers have penetrated so many factors of our lives that some small degree of computer literacy is essential. Anybody who has tried to use a smartphone has to learn a great deal to get the damn thing working right. But it’s getting harder and harder to avoid the need to do at least some small amount of programming in many jobs these days. Spreadsheets use a simple kind of programming. Plenty of people need to set up their own websites, and sometimes paying a professional to do the job is just not within the budget. Just as reading and writing became necessary for most people in our society by about 1850, the ability to program computers is growing ever more important. You might be able to evade the requirement for some years, but the walls are closing in.

Another good reason to learn to program is for recreation. I refer 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 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. You can make beautiful pottery — if you have a good kiln. You could sew beautiful clothing, if only you had a good sewing machine and plenty of good cloth. Most hobbies require a goodly amount of money. But you already have a computer.

Amateur programming, on the other hand, is not so constraining. You can write a program about almost anything you want.  Computer programming is limitless in scope because its expression is not tied to a physical medium like clay or paint. A computer program is an assembly of thought and imagination captured in 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.

And in fact, there are a zillion computer-programming-hobbyist groups on the Internet. Just Google “programming hobbyist” to find some of them. There’s a whole world of “retro programming”: people who program old computers like Apples, Ataris, or C64s for the fun of it. I used to be one of the best programmers of the Atari 800 (40 years ago), but I am flabbergasted by what hobbyists are doing with these machines these days.

Amateur astronomers have taken to computers to improve their photographs. People are using tiny computers like the Arduino and the Raspberry Pi to build all sorts of fascinating doodads. This web page (actually, it has 278 pages as of this writing) shows projects people have built using just Arduino. Some of its projects include an affordable quadruped robot cat, a cheap laser rangefinder, a simple programmable robotic arm, and a glove that translates sign language into text and speech. One survey found that there are at least 10 million hobbyist programmers out there.

Another 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 when I was young!

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 a void in some brains. It is true that some of my weaker 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 ideally 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.

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.