Many years ago, like 16 or 18 years ago, I was sitting around with some co-workers late at night waiting for a long software build to finish. I remarked that we were all addicted to programming. Eyebrows went up so I explained:
You spend most of your time frustrated. Seeking something. That Aha! moment that makes it all worthwhile.
You work for hours or days on a concept. Once you’ve got it straight in your head you start to try to implement it. It won’t compile. Then it compiles but it won’t link. Then it links but it won’t run. Then it runs but it misbehaves. You spend most of your time trying to figure out what went wrong.
You look things up in manuals. You examine your code and others’ code line by line running it through a large complex simulation in your head. When you think you’ve got the answer you run the code line by line in a debugger hoping to figure out which part of the code has the bug. Hoping there’s only one.
You change some code and run it and see that the same misbehavior remains. You change it again. And again. You finally try something radical only to realize you haven’t even been building and running the code you’ve been changing. Then you can’t remember the first four things you tried in order to apply them to the right copy of the code.
Then the inevitable happens while you’re looking at some part of the well established code. Something clicks, your head snaps up and you exclaim, “How could this have ever worked?!” My friends and I used to say that’s the point when you know you’re about half done.
Sometimes you get so deeply involved you start to lose touch with reality and begin to entertain fantastical notions. “Maybe there’s a bug in the compiler…” C’mon, admit it. You’ve all thought that.
Eventually you figure it out. You spot the flaw. You know deep in your bones this is it, the bug. That little voice in your head screams, “Aha!” Maybe you shout out loud and do a few fist pumps, “Gotcha, you son of a bitch!”
It’s hard to describe the euphoria. The intense frustration of the preceding hours or days melts instantly away.
Your co-workers come by and ask where you want to go to lunch. You tell them, “Not yet, one more bug fix and I’ll be ready to go.”
And that’s why programming is like crack.