Channels ▼

Andrew Koenig

Dr. Dobb's Bloggers

Debugging: Art or Science?

November 29, 2012

More Insights

White Papers

More >>


More >>


More >>

Debugging is the hardest part of programming to describe systematically, because its very purpose is to deal with unsystematic behavior. A programmer plans for a program to behave in a particular way; debugging is what happens after the programmer discovers that the program is not behaving as planned. As a result, it is hard to write — or even think — about debugging in general. Every bug is different, so saying something that applies to the act of debugging requires finding something general to say about a bunch of unrelated specific cases that defy generalization by their very nature.

From this description, it is easy to see why debugging is like art. Art takes a part of our experience and distills it in a way that expresses the artist's personality. Different programmers will attack the same debugging problem differently, just as two different artists will portray the same scene differently. Moreover, although art encompasses many techniques that can be described in detail, written about, and taught, there is an inspirational core that is an essential part of each artist. Similarly, highly skilled debuggers often have difficulty describing how they came up with the idea that ultimately led them to the bug they were hunting.

Despite these similarities, I think that debugging is more science than art. To explain this viewpoint, I'd like to start with a particular view of what science is.

At its core, science is the process of modeling the physical world. Here, I am using model as a physicist or mathematician might: to describe an intellectual structure (such as a collection of equations) that behaves in ways that match some (but not all) of the properties of the physical world. There is much art in choosing such models in the first place, so it is fair to say that there is much art in science. However, where science differs from art is in how it deals with a model that does not match reality.

A work of art is always inaccurate; that's its point. If you set out to make a statue of an elephant, there's no art in simply using an elephant for the purpose. Yet nothing is as much like an elephant as an elephant is; which means that there will always be differences between any artistic representation of an elephant and an actual elephant. A model, however, is not an artistic representation. Although it is most useful if it is accurate, it does not attempt to be complete. Its purpose is only to explain — or predict — some aspects of the behavior of what is being modeled. So, for example, if someone can come up with a robot that behaves similarly to an elephant, but happens to be small enough to fit in the palm of one's hand, the size discrepancy is not relevant to the model's purpose. For the purpose of validating a model, it might not even be necessary to build a physical robot. The software itself might suffice.

In short, discrepancies between the world and its representation are a necessary part of art. In contrast, such discrepancies in scientific models are either irrelevant or something to be studied and reduced. This study and reduction is a fundamental difference between art and science.

A program is like a scientific model. We have an idea of what we would like that program to do; when we write a program, we want to make it behave as much as possible according to that idea. When our program does not behave that way (i.e., when we encounter a bug), we follow what is essentially a scientific process:

  • Is the difference between the model (i.e., the program) and reality (i.e., how we want the program to behave) what we think it is? For example, are we running the right program? Can we reproduce the misbehavior consistently?
  • Can we come up with a hypothesis that explains the difference between the model and reality? This step is probably the most creative part of debugging, just as it is the most creative part of science.
  • Once we have a hypothesis, how do we construct an experiment to test the hypothesis?

If our experiment shows that the hypothesis is correct, our debugging task is finished — at least for now. If not, the failed experiment may reveal how we were incorrect about the first step, namely finding the difference between the model and reality. After understanding how our hypothesis was incorrect, we can repeat the process with a new hypothesis.

There is no question that this analogy between debugging and scientific experimentation allows for much creativity, especially in the area of forming hypotheses. However, not all creativity is art, and there is more creativity in systematic experimentation than may appear at first glance. As a result, despite the creativity that so often goes into debugging, I think that debugging is more science than art.

Related Reading

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.



It seems this article uses the words "art" and "science" to refer to "science" and "craft", respectively. What is said here about debugging that cannot also be said about scientific research?

Is not every discovery in DNA genetics different? Do different medical researchers not attack the same disease differently? Is there not an an inspirational core that is an essential part of each theoretical physicist? Do mathematicians not have difficulty describing how they came up with the idea that ultimately led them to the proof they were hunting?

So in what possible way can debugging be more like art than like doing science?

Now if you want to talk about designing user interfaces -- _that_ has more of an artistic element.


The geeks, of which I am one think about a problem, and try to eliminate the irrelevant. Then we start with some binary searching of the code, with each set of tests, cutting in half the areas that are contributing to the bug or problem.

We are using judgement, and, if we were not the author of the failing executable, our approach would be the same.

With each set of tests, we learn more about the failing logic, until, we add a test for a new condition, or we rewrite the logic.

From what I described as my skills, I am the code detective, and that, my peer, is not an art, it is a science, a method developed from years of performing technical support.

The question to answer is: "Is a method a science or an art?"

To me the answer is obvious.


Science or art, it can be either or neither. It is only in ones mind that it must be, or what one wants it to be. There's a disconnect between thought and execution, upon finding the bug it becomes evident that either thought was imcomplete or mis-understanding of something not as trivial as assumed. Nothing more/nothing less. For me, programming along with its warts is truely an art form.


Thank you, Andrew, for your discussion on this fascinating topic. I too have been thinking over this for a while on the art vs science in programming and debugging. And it's interesting that I went through similar threads of thought regarding creating less-than-perfect models of the world in programming as we do in art. Although I came to a slightly different conclusion that programming/debugging IS more art than science. I'd love to discuss further on how I diverged from your reasoning, but overall I think we're in agreement more than not, so I'll leave it at that.

However, more important discussion in this topic I think is the fact that what this programming industry "needs" is more appreciation for art in its field. Your post seems to make the assumption that the prevalent belief is that debugging is more art than science. Whatever the actual practice for programmers may be, my observation is that this industry tries to fit programming overly into engineering molds. (Engineering, I understand is different than science from which you made comparison, but I believe engineering is subset of science.) As you mentioned, no two bugs are the same, which can be said for code as well. Therefore, in the current situation this industry is in, I believe what we need is more appreciation for art in programming.