4 ms·
In my experience, debuggers are only useful in stepping over someone’s code. In your own code, a logging^ output is simply faster to read and reason about. It i
by wruza 4y ago
In my experience, debuggers are only useful in stepping over someone’s code. In your own code, a logging^ output is simply faster to read and reason about. It is like a trace of debugger, but you don’t have to set up sessions with different watches and conditions every time you start a project. I rarely want to “step”, I want to see the path. That “still debug using print()” part is misleading. Debuggers suck by design. Loggers are the better debuggers.
Also, if you don’t log and someone asks you “what was that yesterday” (not necessarily an error), good luck with your debugger-only approach. Logs are everything - ask your sailor, pilot, vehicle maintenance guy, credit manager.
If I was forbidden to log and was asked how to make a debugger better, I’d say that it should use #preprocessor directives right in modules, in which I could set up watches, object dump conditions, i.e. essentially logging. Please realize that at the end of the day all debugger does is printing something conditionally. But then why not just use plain ifs and prints (and few “if (DEBUG_ENABLE)” in case you want to omit it from the executable).
^ doesn’t matter if it is console or some service, as long as you can see it in real-time
- hamburglar 4y ago> at the end of the day all debugger does is printing something conditionally This ignores an awful lot of nuance. If I’m stepping through an algorithm interactively and deciding on the fly what I want to pay attention on a given iteration (or which iteration I want to start paying attention at), or running until a particular thing of interest changes, or any number of debugger scenarios, you can argue that logging all such info all the time and then poring over the output in a log technically gives the same information, but at that point you are positively drowning in data. A debugger gives you the ability to dynamically change what you care about “logging” as your idea of what you need to know changes. I feel like nobody who has ever ever experienced a truly fast (perf-wise) and fluid debugging experience would ever deny how nimble it feels and how you’re never going to get there by deciding ahead of time what is important to log (or by logging absolutely everything). I also think a lot of people are tainted by the debugging experience in a lot of more modern languages. Golang, python, even Java.. the debugger perf is miserable. Give me msvc 6 and three Fn keys and it feels like you are controlling the processor in real-time.
- wruza 4y agoGood points, I summarized it here: https://news.ycombinator.com/item?id=31617858 https://news.ycombinator.com/item?id=31617858
- hamburglar 4y agoTruly, I can’t find fault if you’ve tried both and find one much more productive for yourself. But I run into a lot of junior devs these days that don’t even know what they’re missing because they’ve never had that experience of the debugger being an extension of your arm that’s controlling the program in a very efficient way.