Aren’t bugs a pain? Wouldn’t it be great if we could all just write bug free code? No, not at all. Bugs are an unavoidable part of programming. Though they may seem like a step backwards to some, the truth is bugs are great. They embody many of things I love about programming: learning, responsibility and mindset.
One of the most important parts of deep learning is the feedback loop. This loop is a three part process: input, action, outcome. While it’s nice to get things right the first time, there is less value in a single iteration of this loop. The value comes from getting things wrong and then having to understand why you got them wrong. Bugs provide this type of feedback.
A bug tends to arise because there was some misunderstanding about what you built or how it interacts with it’s environment. Mark, here at BitFountain, once said something to the effect of software starts as one huge bug and it’s our job to get this down to as few as possible. As programmers, we build to start compartmentalizing these bugs and make them more manageable. Programming is an exercise in divide and conquer.
Bugs are also an opportunity for self-evaluation and reflection. More often than not, bugs arise from our own mistakes or misunderstandings. In order to fix bugs, the programmer must go over their own code and it’s context. While we would all love more time to refactor, deadlines rarely present that opportunity. Bugs force refactoring out of necessity. You get to go back see what you were thinking. There have been bugs of my own that I’ve fixed that made me laugh. There was something so obvious I missed but at the time I couldn’t see it. Not all of the program was in my head so I made a decision based on what I knew. With an opportunity to revisit, I can turn a hack into an elegant solution (or into a smarter hack).
Though bugs present a natural path for learning, learning requires an essential component — responsibility. My null hypothesis for bugs is that I created the bug. I assume that everyone else who is remotely involved in a project (libraries included) has handed me stable, functioning code. This may not always be true but in my experience, it is true 95% of the time. One of the crucial parts of making the learning feedback loop work is acknowledging one’s own mistakes. It’s taking the outcome part of the learning loop and forcing it back as the input. Of course, there are cases where the bug is due to a third party library, someone else’s code, tools, etc. In those cases, I make sure I find real evidence that proves without a doubt that the source is not my own code. Often times, the bug is a result of my code interacting with other code. In that case, it’s still my mistake for not understanding the environment. Sometimes the fix requires changing the other code. Regardless, it’s still my bug. That said, debugging isn’t about blame, it’s about learning and building better. Part of why I love bugs is because although responsibility makes it your bug, it also makes it your opportunity to learn and, even better, your opportunity to fix.
Tied to responsibility is the humility that bugs bring. I’ve often heard the joke that 80% of programmers think they are in the top 5%. We all like to think that we’re pretty good. This is because being a programmer requires a high degree of confidence in one’s problem solving abilities. Despite our best attempts to be perfect, thankfully we’re not. There’s always more to learn. While this is most obvious with new languages and frameworks, on a day to day basis, bugs serve as a reminder. They force the Beginner’s Mind.
The last thing I want to mention is that bugs display a lot about a person’s mindset. All problems have two options: be a victim or solve it. You can ignore a problem for a while but eventually you still have to make one of these two decisions. Everyone is familiar with the victim. They’re the person that screams at the computer or their given tool of choice. Of course, everyone initially experiences frustration but, for me, bugs tend to kick in a moment of Flow.
Ultimately, the reason why I love bugs is because I am a problem solver and a bug is nothing more than a problem. One that I know I’m going to fix.
by Matt Parker, Developer