DEV Community

Discussion on: Dude, get a debugger!

Collapse
 
srishanbhattarai profile image
Srishan Bhattarai

From "The practice of programming" by Brian W. Kernighan, co-creator of the C programming language:

"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."

This is the problem with tech articles/blog posts these days in general. There are no silver bullets to any situation and some solutions will be better than others, but one must not be so crass as to completely ridicule a potentially viable solution that has proven to work.

I've encountered situations where a classical debugger doesn't help me and I have to work with something like dtrace. Other times, a debugger is perfect. Other times, a few log statements get the job done.

Collapse
 
nicolus profile image
Nicolas Bailly

There's a huge difference between "I don't have a debugger", and "we tend not to use debuggers beyond getting a stack trace or the value of a variable or two" which implies that they do use a debugger on a regular basis to get stack traces and variables, and that they occasionally use it for more in-depth debugging (hence the use of "tend").

Not every problem suddenly becomes a nail because you have a hammer, but you definitely need to have a hammer in your toolbox.

Collapse
 
srishanbhattarai profile image
Srishan Bhattarai

Sure. None of what I said contradicts what you're saying right now. I never said that a debugger isn't needed or isn't valuable. I even went out of my way to say that a debugger is perfect for many situations. Other times, log statements work. To discount their value by painting a picture that debuggers are always the solution is a bit misleading IMO.