▲ | cbanek 6 days ago | |||||||||||||||||||||||||
This is absolutely true. If anything, interactive debuggers are a crutch and actual logging is the real way of debugging. You really can't debug all sorts of things in an interactive debugger, things like timing issues, thread problems, and you certainly can't find the actual hard bugs that are in running services in production, you know, where the bugs actually happen and are found. Or on other people's machines that you can't just attach a debugger. You need good logging with a good logging library that doesn't affect performance too much when it's turned off, and those messages can also provide very useful context to what things are going on, many times as good if not better than a comment, because at least the log messages are compiled in and type checked, as opposed to comments, which can easily go stale. | ||||||||||||||||||||||||||
▲ | TheRoque 6 days ago | parent | next [-] | |||||||||||||||||||||||||
Both are valid, if your code is slightly complex it's invaluable to run it at least once with a debugger to verify that your logic is all good. And using logs for this is highly inefficient. E.g. if you have huge data structures that are a pain to print, or if after starting the program you notice that you forgot to add some print somewhere needed. And obviously when you can't hook the debugger, logs are mandatory. Doesn't have to be one or the other. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | brongondwana 5 days ago | parent | prev | next [-] | |||||||||||||||||||||||||
This is why I trigger a segfault which dumps core at the spot where I had the printf when the conditions aren't what I want, so I can then open the debugger on the core (obviously: not if I have a copy of the input which can recreate it, if so then a debugger with a conditional breakpoint at the same spot is even better) | ||||||||||||||||||||||||||
▲ | lenkite 5 days ago | parent | prev | next [-] | |||||||||||||||||||||||||
Timing and concurrency issues are actually easier to discover in a debugger than using printf logging. | ||||||||||||||||||||||||||
▲ | JustExAWS 5 days ago | parent | prev [-] | |||||||||||||||||||||||||
Really? I’ve been using interactive debuggers since the days of Turbo C/Turbo Pascal in the mid 1990s. Yes you need good logging also. |