Several years ago, I worked with an engineer named John Kuslak. John was a smart, smart guy. He looked like Ben Matlock.
Another engineer in the group liked to hang quotations from coworkers in his office. He had one from John near the door:
Never fall in love with your code. Because it's crap.
Another quote from John was on the opposite wall:
This sequencer is better than sex!
I included that second quote because it makes me smile. But I really want to write about the first one.
I never understood it properly until recently, when I found myself looking at some old code I'd written about 10 years ago.
That code really was crap. The most embarassing part was the comments, many of which looked like ///////////CHECK OUT THIS AWESOME GENIOUS CODE RIGHT HERE!!\\\\\\
It made me think seriously about all the code I'd written since that time. Is it all crap?
Yes. It's all crap. Even the code that seemed good at the time, even the code that still looks half-decent today. If it's not crap now, it will be when I look at it 5, 10, 20 years down the road.
Man, that is depressing. I had strong feelings for some of that code. Maybe not love, but firm affection and respect.
But you know what? My house is also crap. It was built 115 years ago, using techniques that make zero sense today.
For instance, the wall studs don't line up. When you frame a modern house, the framing needs to be very even so the drywall doesn't bulge and dip. In 1890 the framing studs could be off by a half-inch from each other, because what went on top of them wasn't drywall. It was plaster. Plaster fills in the dips and thins out for the bulges, and the wall looks perfectly flat.
Today, nobody does that - compared to drywall, plaster is crap.
It's not just the walls - there are weird holes in strange places because different heating duct systems have been installed over the years. One of those old ducts is still in use - a sheet of tin nailed to the bottoms of two floor joists in the basement. I hate looking at that duct, it looks like crap.
But I love the old house. The hardwood floors and the oak trim are beautiful. The 9-foot ceiling makes even the small rooms seem huge. Those qualities make up for the crap.
Code is like that too. A house is a complex structure and it requires maintenance and care that correspond to the style and technology that were used to build it. So with a program.
I think more time and money are spent by people to upgrade and repair existing houses than build new ones. Same deal with code.
And every time I work on my home, I try hard to do quality work even though I know it'll be crap someday. After all, I live there now.
I used to think John's quote was good advice. Now I think it's not so simple. It's true that all code becomes crap. But you have to love it when you build it or it'll be crap from the start.
When I look at my old code, it doesn't look like crap - in fact, I'm always pretty impressed.
That's depressing.