Live data from Hacker News

Debugger or print? That is the question

news.ycombinator.com

11–17 of 17 posts

Re: Debugger or print? That is the question

#11
post #10

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…

I appreciate the comment, but I'd like to make some counter arguments.

You say there are benefits to using a debugger, but I've never had any issues not using a debugger. I've been coding for 26 years. The worst thing that's ever happened to me is that I once commented out a couple lines of code, forgot to uncomment them and pushed it to production. This affected maybe 0.001% of our users. Of course, I've learned to be more careful since then. Regardless, I've asked myself many times over the years every single time I make a mistake if it could have been prevented using a debugger and the answer is always no.

You say that you use a debugger to step through every line of code to examine the state and state changes, but I always do this in my head and have never had any issues. My colleagues always use a debugger and they constantly make mistakes. I often feel that the reason they make so many mistakes is because they rely so heavily on the debugger that it has a negative impact on their ability to analyze code in their head.

This is also why I always teach my son to do math in his head and never on paper. Relying too much on calculators and paper is in my opinion the reason why so many students perform poorly in math. But this is of course another topic.

Re: Debugger or print? That is the question

#12
post #10

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…

I appreciate the comment, but I'd like to make some counter arguments. You say there are benefits to using a debugger, but I've never had any issues not using a debugger. I've been coding for 26 years. The worst thing that's ever happened to me is that I once commented out a couple lines of code, forgot to uncomment them and pushed it to production. This affected maybe 0.001% of our users. Of course, I've learned to…

It's possible you're just a much better programmer than I am and write optimal code with very few defects. I am no genius and have to rely on tools to work around my mental limitations. But I suspect you would find some latent defects in your code if you adopted the discipline I recommended above.

Re: Debugger or print? That is the question

#13
I'll use a debugger sometimes when the error is getting thrown in code I don't control but can view the source of - it can help figure out context and what the external code is doing. Otherwise I normally just put print statements for things I'm unsure of and remove them before committing.

Re: Debugger or print? That is the question

#14
You're only doing something wrong if you're failing to get your work done. The important part of the debugging process is the bit that happens in your head, so you should use whichever tools suit the way you think.

It depends somewhat on the type of work you are doing. Some problems are more easily spotted by dropping in and having a look at the program state, but there are problems a debugger cannot help you with at all.

I made heavy use of debuggers earlier in my career, but after a few years working in environments where logging was the only option, I found I preferred that style.

Re: Debugger or print? That is the question

#15

I've interviewed folk who say they don't use debuggers. They usually don't get the job.

I'll keep that in mind for my next interview. I find it's always best to avoid jobs that discriminate in such ways, and if not using a debugger helps me to dodge a bullet, I'll consider myself lucky.

You’re being disingenuous. Using a debugger is such an elementary part of a developer’s job that failure to master it is incompetence to me.

Re: Debugger or print? That is the question

#16
I think print debugging is great, but if all of your colleagues use a debugger, you might work in a context where that's a useful superpower.

You actually have an opportunity to learn how to use a debugger well right now and you should probably take it.

Once you learn how to use it well, you can make an informed decision on if it's actually better.

Re: Debugger or print? That is the question

#17

Earlier quoted context omitted.

I'll keep that in mind for my next interview. I find it's always best to avoid jobs that discriminate in such ways, and if not using a debugger helps me to dodge a bullet, I'll consider myself lucky.

You’re being disingenuous. Using a debugger is such an elementary part of a developer’s job that failure to master it is incompetence to me.

Well, at the end of the day, my job isn't so much to code as it is to make my employer, that is your competitor, money. So you've just called the man making your competitors a lot richer incompetent. Indeed, one of us is being disingenuous.
Post reply on HN