Advice to a Young Programmer

I was pleased and impressed with your missive. You seem to be headed down a promising path; your attitudes and approaches are sound. Let me offer an observation: programming is a medium, not an end. That is, programming is an interesting and powerful way to say things. You are still in the process of learning the many elegant ways to say things with programming. But do not fall into the trap so many bright young programmers fail to evade: becoming so obsessed with the elegancies of programming that you spend your entire life pursuing the medium rather than its content. In other words, programming is a way to say things about the world; will you use this medium to say interesting things or to say boring things in an ever-more interesting manner?

Here’s an analogy: programming is like writing. You can spend your entire life polishing your grasp of English, but at some point you should begin to focus on what you say, not how you say it. Videogames and computer games right now are analogous to "See Spot run. Run, Spot, run" written with polysyllabic vocabulary, multiple clauses, and liberally sprinkled Latin phrases and literary allusions.

For now, it is appropriate that you soak up all the technical knowledge you can. The best way to do this, of course, is to write code. You can study other people’s methods all day long but they don’t really sink in until you’ve used them.

Another crucial point: most of the high-falutin techniques of programming make no sense until you are dealing with huge projects. Writing little programs is trivial; the real problems don’t come out of the woodwork until you have written a monster so big that you can’t remember what the various parts do. For example, the notions of structured programming really don’t do you any good until you get above, say, a couple thousand lines of code. Object-oriented stuff doesn’t kick in as a useful way of doing things until you get above, say, 10,000 lines of code. When you’re just getting started, it’s all too easy to read all this theory and dismiss it as useless hooey. But I assure you, there is nothing more sobering than struggling with a tiny bug hiding deep inside a huge program.

I’ll digress with a tale about that. I have a big program that I’ve been building for the last ten months. Recently a bug surfaced, a really insidious little monster, for it corrupted the primary data file that this program is designed to edit. I’ve got good bug-hunting instincts, but this thing baffled me. I’ve wasted a lot of time tracking it down, and I think that I’ve killed it although this bug is so tricky, I’ll never really know that I killed it; the best I can hope for is the future knowledge that it hasn’t struck in a long time. The problem that I solved arose because I wrote a routine with one set of assumptions, and then months later added a feature that indirectly called my old routine using assumptions that were no longer valid. Because the problems arose from several layers of deferred execution, I never noticed it. How in the devil could I have prevented that mistake? I don’t know.

Don’t ever take your code personally. There’s always going to be somebody who can rewrite your code better. Recognize that the way that you write code is a matter of personal style, and somebody else’s way could well be better. A few months ago a fellow I was working with suggested a change in my style: why not write my program constants in ALL CAPS? It would make them stand out in the program so that it would be harder to confuse them with variables. I resisted at first; it just seemed ugly. But I know this guy is good, and I adopted his technique solely out of respect for his judgement. Well, he turned out to be right; now that I’ve gotten used to it, I find it a practical and salutary improvement in my style.

Two books I will recommend are Code Complete and Writing Solid Code. I’ll warn you, though, that these books are most useful for somebody who has a few years of programming behind him. To a beginner, the numerous precautions and defensive measures might seem defeatist. At this stage in your career, you are likely more excited by the possibilities than worried by the dangers. So get one of these books, read it, and make a promise to go back and read it in five or ten years.

My most important advice, though, is to keep your breadth. Most programmers get sucked into the narrow world of programming and never come out. Remember, programming is a way to say something, not an end in itself. If you don’t have anything to say to the world, what’s the point of learning how to speak? And the only way that you’ll develop an interesting point of view is to steep yourself in the knowledge of the world. How do you get your news? Television nightly news? That’s childish pap, dedicated to showing you video of the latest gruesome disaster. Who cares about twisted wreckage and bloody bodies -- it happens all the time. What matters are the important undercurrents of our culture, not the sensational crimes and disasters. Do you read the newspaper? Time or Newsweek? I read the Economist. It goes way beyond the childish stuff I read elsewhere. I’ll warn you, though, it can get pretty dense at times.

Related essay: Scribes versus Authors
related essay: Reading habits of the Rich and Famous


What books do you read? How many books do you read? How varied are they? There is so much out there to be learned! Right now I’m reading Stephen Jay Gould’s stuff on evolution he’s great! I’m also studying linguistics, although I’ve not had the courage to tackle Chomsky yet. I love Erasmus and devour his stuff. Every night I curl up with a Latin edition of his Adages and an English translation, and go through it line by line. Eventually I’ll learn Latin that way. I also read a lot of history just finished The Rise of the West, a truly penetrating analysis of history. It tempts me to go back and tackle Toynbee. I am also reading some Thomas Jefferson, and I am sad to admit that my copy of Herodotus hasn’t been opened in a month. Have you read any good psychology lately? I’ve been reading about consciousness, particularly its historical development. I read Jayne but I’m not so sure about his thesis ("The Origin of Consciousness in the Breakdown of the Bicameral Mind"). It’s certainly interesting and he has some good points, but I think he squeezes the data too hard.

Broad learning is important; it is the foundation of solid thinking. Think of it as a well-balanced diet for a growing mind. It will take you decades to develop your mind, but if you don’t get started now, you’ll never catch up. All those ideas out there will help you develop a strong and clear point of view, and give you the power to think interesting thoughts. Once you have developed such interesting thoughts, you’ll be in a position to express them through programming. But if you never train your mind, you won’t have anything interesting to say, and you’ll spend the rest of your life shoveling pixels onto the screen.

Good luck,

Chris