5 ms·
I've never really used debuggers routinely. They are a last resort for me. I use print statements and logs for the most part.
by ams6110 8y ago
I've never really used debuggers routinely. They are a last resort for me. I use print statements and logs for the most part.
- mruts 8y agoI think debuggers are actually a lot less useful than people think. Just by thinking, using a REPL, or putting in print statements you can solve probably 99% of all bugs. Debuggers are useful when you really have no fucking idea what's going on.
- tom_ 8y agoOr instead of putting in print statements, you could use a debugger. You don't even need to know which print statements you need, because when the program is stopped you can look at whatever you like. Thinking is still required, but I don't recommend relying on it, since it's typically what gets you into this whole mess in the first place. At the very least, don't rely on thinking to guess what the computer is doing, when you can use the debugger to find out for certain.
- AnIdiotOnTheNet 8y agoI'd agree generally. I pretty much have only used debuggers when reverse engineering something or when I'm so hopelessly unable to see what the problem could be that I start suspecting the compiler might be at fault. Even when reverse engineering something it's best not to get bogged down in the instruction-by-instruction details and instead try to follow the general program flow and reason about how you would do something if you were in the programmers' shoes.
- magduf 8y agoThis has been my experience as well: I only resort to the debugger when my other avenues have proven fruitless. They can also be useful for Heisenbugs. However, I did have one job working on an embedded device with no console at all, and a JTAG debugger was invaluable there. But I would have preferred to have a console and be able to do printf debugging, as for easier bugs it's just a lot quicker.
- ilikehurdles 8y agoI use a repl with a debugger attached in clojure. Best of both worlds :).
- jshowa3 8y agoThe problem with print statements is that you're now adding unnecessary code to the application that you then have to take out. How many of us have been lazy and just left them in? I know I have. Thus you violate KISS and add unnecessary complexity to code when you could've just used a debugger. As for logs, those are a necessity and should be in every complex program not just because of exceptions, but because of program logic that you implement and want to know where you are, and were, while the program is in use.
- kevin_thibedeau 8y agoIt's not exactly challenging to have prints only show up in debug builds.
- Koshkin 8y agoYeah, but they're still in the code. Tracing is nice when it is a feature built into the language implementation (i.e. the compiler or the interpreter).
- lunchables 8y agoSame, but I always feel like using a debugger has to be a better way to handle that stuff and that I just haven't invested enough time to get the workflow right. Maybe prints and log statements are better.
- tomc1985 8y agoI was the same way until I worked at a place that would not let us merge clearly WIP code. Now, debuggers are life!
- Jorge1o1 8y agoUsing a print statement to display the value of a variable is no different than putting a breakpoint at that line and just reading the state of your program off the locals window
- kevin_thibedeau 8y agoThe latter freezes your program for non-trivial amounts of time which can be problematic in some cases.
- yorwba 8y agoYes, for example setting a breakpoint in your input method engine while it's relaying your keystrokes to the terminal with the debugger tends to go poorly. On the other hand, gdb supports the "commands" command, which allows you to automatically run a script when a specific breakpoint is run. That way, you can do essentially everything you can do by inserting logging statements directly into the code, but without having to restart the process.
- pjmlp 8y agoWith dynamic trace points and scripting there is no freezing.
- jstimpfle 8y agothere are significant differences as discussed elsewhere. Additionally, you can't read globals or other complex computed expressions from the locals window...
- deleted 8y ago[deleted]