Kernighan and Pike on debugging

While reading the log4j manual, I came across this excellent quote from Brian W. Kernighan and Rob Pike’s “The Practice of Programming”:

As personal choice, we tend not to use debuggers beyond getting a stack trace or the value of a variable or two. One reason is that it is easy to get lost in details of complicated data structures and control flow; we find stepping through a program less productive than thinking harder and adding output statements and self-checking code at critical places. Clicking over statements takes longer than scanning the output of judiciously-placed displays. It takes less time to decide where to put print statements than to single-step to the critical section of code, even assuming we know where that is. More important, debugging statements stay with the program; debugging sessions are transient.

+1 to that.

Tags: , , , , , , ,

4 Comments »

  1. Marcus Ramberg said,

    January 8, 2007 @ 8:53 pm

    +1 to that from me as well. I agree 100% :)

  2. Aidan Kehoe said,

    January 10, 2007 @ 11:46 am

    Neither of you write much C lately, I suspect …

    I find I use debuggers more when dealing with other people’s code, people who aren’t to hand and whose thought processes I don’t necessarily get.

  3. Michael Sander said,

    January 12, 2007 @ 1:42 am

    What is needed is a debugger that puts printf’s everywhere. A debugger where you can step backwards and check out the programs state after it executed. Such debuggers exist… check em out: TimeMachine: C/C++ http://www.ghs.com/products/timemachine.html Amber: C/C++ (Still in development) OmniCore: Java – http://www.Omnicore.com There are plenty of others too!

  4. a said,

    October 15, 2010 @ 7:44 pm

    that was written before eclipse. it doesn’t apply today if you’re using java or other programming language for which eclipse’s (or vs’s) visual debugger is fully integrated.

RSS feed for comments on this post

Leave a Comment

Comment text formatting: Markdown Extra syntax is supported, as is plain old HTML. (Quick reference for Markdown basics)

View blog reactions using Technorati