← Back to context

Comment by HarHarVeryFunny

3 months ago

I've been a developer for 40+ years, and have to agree. I've never found debuggers to be the most efficient way to debug code, and it's not something I'd normally reach for during development.

The only time I normally used a debugger is for post-mortem debugging - looking at a production core file for a multi-threaded process to see where it was in the code (and maybe inspect a few variables) when it crashed. If the core isn't sufficient to isolate the problem, then I'll add more logging to isolate it next time it happens.

During development, printf is just so much more convenient. I'll always put print/log statements in my code as a combination of tracing execution flow and to validate assertions / check that variables have the types of value that I'm expecting. Often this sort of pre-emptive debugging is all you need, and if not it should point to exactly where you need to sprinkle a few more print statements to isolate an issue.

The convenience of print statements is that once you've put them there, at critical points in your code, and printing critical values, they are always there (can conditional them out once code is working, if wanted), as opposed to having to go into a debugger, navigate to points in code, setup breakpoints, monitor variables etc ...

I'm of a similar vintage, and I found debuggers valuable when I was debugging Windows 3x and 9x programs, C or MFC C++. You needed to get in to the data structures in memory sometimes, and Microsoft made good debuggers at the time.

Modern development, scripting languages and web development, I rarely use a debugger, setting it up for each of the various languages we jump to is too much bother.

  • I am in a similar boat - When I was an engineer at Intel during the Windows NT days, I used SoftICE every day... but over time I have evolved into using less debugger tools and more emulation/simulation tools to find problems.. and even just more time 'thinking' about the code paths and what could go wrong.

  • FWIW, I'm talking about C++ multi-threaded code for Linux (server software with high variety of requests and work flows).

> I'll always put print/log statements in my code as a combination of tracing execution flow and to validate assertions / check that variables have the types of value that I'm expecting.

This is where Go's superfast compiles shine. Debuggers-B-Gone.

Correct me if I'm wrong but you basically just described good logging practices, yea?

  • Maybe ? But I was mostly trying to describe how good logging / pre-emptive print statements can avoid much of the need to debug in the first place (as well as why it's more efficient).

    Of course coding discipline / experience plays into writing bug-free or easy-to-debug code too.