http://qs321.pair.com?node_id=14419

Have you ever really thought about what an odd process debugging is?
You sit there, pitter patting away at the keyboard, staring at the screen.
Looking for something you know is there, because it manifests itself
or because you know it is there. Switching editors, adding prints,
running debuggers. Trying to logically eliminate the problem.

I don't think I have ever logically eliminated a bug. The solution comes to you,
Like a flash.
Like enlightenment, what was previously mysterious is now clear.
Logic helped, I have no doubts. But the solution does not come from logic.
The real solution is comes from somewhere else, I don't know the place.
But I can feel it and I know I have entered that place.
It feels like returning home.

When I try to explain what coding is like, I always try to explain debugging.
A fruitless exercise, like explaining the moon to those who do not look up.
Still, the reflection of the moon in water can show them what to look for.
I think the Hacker's worldview is shaped by debugging. Dealing with the
computer is like dealing with reality. Harsh, Sharp, Unforgiving.
Though Life is a taskmaster far more cruel than the interpreter.

Monks gain insite into life by their way of viewing reality.
Hackers gain insite into life by how they debug.
I've never met a good Hacker that couldn't debug.

Crulx

Replies are listed 'Best First'.
RE: Debugging
by perlmonkey (Hermit) on May 24, 2000 at 08:47 UTC
    Debugging is not such an odd concept once you realize you are fallible. Nobody is perfect, and debugging is a good humbling and learning experience for us all. I always learn more debugging than when I am coding.

    I have friends that get so frustrated when they compile something and get 300 errors. Like they expect their code to be perfect. I would be frustrated if there were no errors, because then I would have to find my errors with out the aid of the compiler.

    I dont know, I find my compilers/interpreters extremely forgiving, and actually fairly polite.
    $a ='foo' print $a syntax error at - line 2, near "print"
    Isnt that cool. Not only is it non judgemental, it tells you where your error is and then even gives you the chance to fix it. I cant think of a better reality. They could be a lot more realistic:
    $a = 'foo' print $a Error you idiot. Your code has been deleted, you no longer have permission to use this compiler, and all the other computers and programmers on the network have been informed of your imcompetence!
    Now that is harsh, sharp and unforgiving.
    Debugging, like life, is what you make of it. So enjoy!
RE: Debugging and Reciprocality
by neshura (Chaplain) on May 23, 2000 at 22:08 UTC
    This seems like as good a place as any to provide a link to Reciprocality. (site by "The Programmer's Stone" author, Alan Carter)

    e-mail neshura

RE: Debugging
by Ovid (Cardinal) on Jun 11, 2000 at 23:14 UTC
    Oddly enough, I see a parallel to morality problems here. In college, philosophy professors would pose a problem like the following:

    Your plane crashes in the jungle. Everyone lives, but is captured by rebels. The leader of the rebels asks you to kill one of the passengers. If you don't, he will kill them all. The question: do you kill someone? If so, how do you select the person?

    I realized that all moral dilemmas that he came up with always stemmed from a previous immoral action over which you have no control. In the case of the problem above, the previous immoral action is the rebel leader deciding that some or all survivors will be murdered.

    Though the parallel is tenuous, it's there.

    In debugging, we are attempting to apply logic to a previous breakdown in our logic. It's the poor choices of ourselves or others that lead us down the path of debugging. Is there a universal logical approach to resolving breakdowns in logic, or is it more of an art?

    I debug well, but I don't always succeed. Your comment "hackers gain insite into life by how they debug" is very applicable to me. Oftimes, when faced with my breakdowns in logic, I am tempted to just run to others for help (hence, some of my posts to Perl Monks). Sometimes, I just want an answer, rather than figure out what's going on. Hmmm... now I'm seeing parallels to religion. I'll stop now before this becomes a full-fledged rant.

      Is there a universal logical approach to resolving breakdowns in logic, or is it more of an art?

      It's both. While there has to be an organized, test-one-thing-at-a-time approach for debugging anything more complex than a one-timer, art and experience come in when you have to figure out exactly where and what the error is. The more mistakes you make -- and fix -- the more easily you can recognize new ones.

      Some people are so good at this, it appears to be magic. It's like the Knuth series -- though programming is essentially breaking a complex task down into little chunks and then describing them as succinctly AND in as much detail as necessary, it's a creative process. That's why it's an Art.

RE: Debugging
by BigJoe (Curate) on May 24, 2000 at 03:20 UTC
    You can feel it, you have felt it all your life. What you feel you can not explain but you know it is there.

    Have you ever had a dream that seemed so real? What if you never woke from that dream? Could you tell the difference between the dream world and the real world? --Morpheus
      There is no spoon.

      Seriously though, I beleive that the flash that you where refering to is when you realize that you did it wrong in the 1st place. I rarely use perl's debugger. At most, I run -c just to see if I don't have a typo somewhere, but TRUE debugging, very rare. Mind you, that, I'm not a programing super-hero or anything of the sort. Its just my way of doing things.

      When scoping through code, instead of trying to find the logic in what was just written, I find it more productive to review the logic itself and what it was I was trying to accomplish in the 1st place (ie: read it as if I were reading perlmonks). This is a habbit I aquired when reviewing trainees' coding. I always ask myself, "How would I do it?" even if the code is mine. I just pretend it isn't.

      Invariably, I'll hit the bad spot (if it isn't just a typo) during the 1st run through. Else, I give it to someone else to read and come back to it later. It also helps to explain out loud why each line is written the way it is.

      Just my R$0.02 (Brazilian two cents) worth.
        I used to debug a lot like you do, it works fine. Another good trick is to abuse Data::Dumper for debugging when diving into data structures and objects. But these all can be trememdously slower sometimes, especially if the original code is not yours. I did not really start using debuggers until I got to my current job where some of the programs are 30k lines long, none of which were written by me. They are not a bad sized programs, but some were written in the most bizzare way, and no strict. Yet I still have to fix the bugs that are reported.

        It is hard to get into debuggers at first, but investigate some of the gui ones like Devel::ptkdb or DDD. Getting really familiar with a good debugger is (in my opinion) one of the most advantageous things any programmer can do.
RE: Debugging
by Anonymous Monk on May 24, 2000 at 09:47 UTC
    Have you ever really thought about what an odd process debugging is?
    You sit there, pitter patting away at the keyboard, staring at the screen.
    Looking for something you know is there, because it manifests itself
    or because you know it is there. Switching editors, adding prints,
    running debuggers. Trying to logically eliminate the problem.

    I don't think I have ever logically eliminated a bug. Solutions come,
    Like a flash.
    Logic helped, I have no doubts. But the solution does not come from logic.
    It comes from somewhere else, I don't know the place.
    But I can feel it and I know when I have entered that place.

    When I try to explain what coding is like, I always try to explain debugging.
    A fruitless exercise, like explaining the moon to those who do not look up.
    I think the Hacker's worldview is shaped by debugging. Dealing with the
    computer is like dealing with reality. Harsh, Sharp, Unforgiving.

    Crulx patch by StickMan
RE: Debugging
by Anonymous Monk on May 24, 2000 at 09:51 UTC
    Have you ever really thought about what an odd process debugging is?
    You sit there, pitter patting away at the keyboard, staring at the screen.
    Looking for something you know is there, because it manifests itself
    or because you know it is there. Switching editors, adding prints,
    running debuggers. Trying to logically eliminate the problem.

    I don't think I have ever logically eliminated a bug. Solutions come,
    Like a flash.
    Logic helped, I have no doubts. But the solution does not come from logic.
    It comes from somewhere else, I don't know the place.
    But I can feel it and I know when I have entered that place.

    When I try to explain what coding is like, I always try to explain debugging.
    A fruitless exercise, like explaining the moon to those who do not look up.
    Still, the reflection of the moon in water can show them what to look for.
    I think the Hacker's worldview is shaped by debugging. Dealing with the
    computer is like dealing with reality. Harsh, Sharp, Unforgiving.
    Though Life is a taskmaster far more cruel than the interpreter.

    original Crulx
    patch StickMan