4 ms·
I have changed my mind a couple of times on that subject. My opinion now is that printf debugging is not ok, but that it is not your fault. printf debugging is
by GuB-42 2y ago
I have changed my mind a couple of times on that subject. My opinion now is that printf debugging is not ok, but that it is not your fault.
printf debugging is a symptom of poor tooling. It is like saying that driving in nails with a rock is fine. It works, but the truth is that if you are using a rock, that's probably because you don't have a good hammer. And if on every job site, there are seasoned workers banging rocks like cavemen, maybe hammer manufacturers should take notice.
- poincaredisk 2y agoMaybe, but it's also the only method that works everywhere. I write very different things - python scripts, scripts for weird programs that use ancient or weird languages, web applications, binary exploits, I do small patches to large projects - most recently a custom LLVM pass. With maybe exception of web dev, having a toollit for debugging every of that kinds of software would be hard to impossible to get.
- K0balt 2y agoThe nice thing about printf debug is the preemptive debugging. You can leave them in the source as conditional comments, and it makes the code self documenting at runtime. I find it useful as a pre-source review step reopening a project after a few years. Documentation at runtime gives a faster mental map of the execution then reviewing the source without seeing the runtime debug flow. So my debug builds often self document at runtime, and in production the printfs become comments.
- lolc 2y agoOften I want to know the sequence of some events, what points are reached. Adding print statements is a quick way to trace that. How can tooling make that more convenient?