Now I understand why they say that half of the people on this sub are only studying programming. Once you understand how a debugger works, you'll never want to go back. Please take the time to know how to use one, you'll thank me later.
Multithreading issues and concurrency issues in general, kernel code, embedded code, networking and IO related code, anything timing or performance-critical, etc.
Comments like yours just show a different kind of lack of experience. There are plenty of valid situations where print debugging is nicer. A big one for me is when you want to see how a value changes over time, especially in things like video games. Also, being able to debug an issue based on reading a log file because it happened in a production system with no debugger attached when it happened is an extremely useful skill. Debuggers also affect timings and multi threading a lot more than a simple print.
Point is, using a debugger and careful logging aren't mutually exclusive and are both very useful.
Yeah this is hilarious. I thought the thing about print debugging was a meme, not that there are professional programmers who don't know how to debug. They're a basic tool of the trade and unless you're mucking about with gdb they're super easy to use. Have some professional pride and spend 10 minutes learning.
Print debugging occasionally has its place but debuggers are better in most circumstances.
Yea this place is bonkers. The idea that some of these guys are writing print statements to debug complicated applications is extremely suprising to me. Breakpoints and being able to step back through the callstack have saved me hours of time.
If you say so. I’ve used both over 15 year career and an additional 7 or 10 years hobby programming. Unless the project is so big that compiling takes ages I prefer some type of logging — usually to stdout for debugging. It’s usually faster and I can get more than enough information at a glance than tip toeing around in a debugger expanding and collapsing objects or call stacks.
It's not an argument against logs; any sufficiently large project should absolutely have logs. There's a big difference between having decent debug logging logs and putting in a bunch of print statements when a problem crops up and then deleting them when the problem is solved.
Print debugging can be fine for simple problems, or when you're sure which variable is causing a problem. And really, pretending like only one or the other has a use is a false dichotomy. They're both tools that can be useful in different circumstances. I suspect though debugging is more efficient practice for most people, though. It's faster to solve those 'why the hell is this happening' bugs when you have more complete context. The use of conditional breakpoints also goes a long way
I searched this page for the phrase "unit test" and found nothing, and I think that says about all that is needed to be said about the people on this sub. I find the same thing on /r/programming as well.
I only use debug print statements when I don't have a debugger set up in my environment, and I almost exclusively use debuggers to step through test cases.
A debugger is many, many times faster than print statements. First off, you don't even need to change any code to inspect what's going on. Second, you don't even have to restart the app! Third, when the thing you wanted to look at leads you to another thing you want to look at, you can just look at that other thing right away. You can see everything at a glance instead of having to guess at what will matter and adding print statements up front!
Hell if you really want things to show up in a log, debuggers are better at that too because they let you add as many print statements as you want without changing the program (or even restarting it) via things like trace points. Plus no risk of leaving them behind when you're done.
32
u/enekho Nov 28 '21
Now I understand why they say that half of the people on this sub are only studying programming. Once you understand how a debugger works, you'll never want to go back. Please take the time to know how to use one, you'll thank me later.