Debugger vs Print Debugging
This cluster debates the effectiveness, productivity benefits, and personal preferences between using interactive debuggers and print statements (like printf or logs) for debugging code. Commenters share experiences on when each method excels, with some advocating for debuggers and others preferring prints or mental reasoning.
Activity Over Time
Top Contributors
Keywords
Sample Comments
Bah! If you need a debugger, you're not thinking hard enough.
You are doing something wrong. There are huge productivity benefits in learning how to use a debugger effectively. Debuggers have benefits that go beyond just fixing known defects. I have disciplined myself to step through every line of code that I write while watching the control flow and state changes. This allows me to proactively find and resolve defects and inefficiencies that would have otherwise leaked through testing. Issues that you would never notice while reading source code or lookin
I'm somewhat embarrassed to say that I very rarely use debuggers. Print statements have always worked for me even in large codebases. What am I missing here?
Learn how the debugger works for whatever language you use. You will be very tempted to just use logs as it's way easier and debuggers seem intimidating, but take a day out of your schedule to learn the debugger. When you really have no clue what's going on in your code there's no substitute for being able to stop your program mid run and inspect it's state interactively.
Tools help you be more productive. The keystroke reduction in using debuggers far supercedes print debugging.Imo you've blamed tool fetish when it's really inexperience that is the problem.
A world where most people don't use debuggers?
Agreed! Personally I've found that I can find and fix problems much faster with a few print statements than with a debugger--debuggers can make it harder to trace through the full execution of a program.
I always feel like I should get better with a debugger, but whenever I'm debugging I always fallback on printf and crashing. It just feels so immediate
You think that print debugging is wrong and debuggers are the way to go?
Debugger usage has been non-monotonic with time for me. When I first started coding I would print. Then I discovered debuggers and experienced a massive improvement in productivity on bug fixing and problem solving tasks. But over time I found myself reaching for the debugger less and less often as I became better at solving problems. In the last 5 years I have to admit I've barely used debuggers at all.