News for hackers. Stuff that matters.
Re:What does debugging a program look like? by saagarjha on Monday June 24, 2019 @12:32AM (#20260573)
> accept that it’s probably your code’s fault

One “unpopular opinion” I have is that once you’ve written enough code, ignore this advice and assume that it’s the library’s fault very quickly into your debugging session. Some small fraction of the time you’re actually going to be right and you’ll have saved yourself some work, and the times you’re wrong I argue that you’re actually not any worse off. For example, if you have a function returning an error, just assume that the framework is making a mistake somewhere: I tend to find myself that I’m a lot more thorough and open-minded at reviewing other people’s code than my own, so I’ll look a lot more for the reason why it’s behaving in an unexpected way. Often this gives me insight in to the internals of something new for free along with the solution (oh, the error is being created at this check inside an internal function because I passed in NULL and I shouldn’t have).

Re:What does debugging a program look like? by thinkingkong on Monday June 24, 2019 @12:58AM (#20260662)
How much code are you writing before testing the functionality / behaviour of the library in question? Ive seen folks write pages and pages of code before trying to run anything, but my personal approach is to prototype the smallest working bit before integrating it into a codebase.
Re:What does debugging a program look like? by saagarjha on Monday June 24, 2019 @02:10AM (#20260904)
I write a lot of code in the debugger, to be honest.
Re:What does debugging a program look like? by taneq on Monday June 24, 2019 @02:15AM (#20260920)
This depends hugely on what kind of code you're doing. If you're mostly writing "glue" code between in-house libraries which may not be battle-tested, it's probably a reasonable assumption. If you're writing large amounts of application code yourself and the libraries you're using are widely used, then it's much less likely that there's something wrong with the libraries.
Re:What does debugging a program look like? by saagarjha on Monday June 24, 2019 @02:25AM (#20260970)
Again, it doesn’t really matter whether the library actually has a bug in it: you’re just tricking yourself into finding the bug by looking at code that’s not your own. However, from personal experience well-used libraries and tools have more bugs in them than you’d think ;)
Re:What does debugging a program look like? by TeMPOraL on Monday June 24, 2019 @02:38AM (#20261034)
Alternatively, you can just internalize that anything running on your machines is your code. There's no difference between the piece of software you're writing and the library it's calling; you can and should step back and forth between them when debugging. Abstractions are cool, but there's great value in just getting your hands dirty and looking under the hood.
Re:What does debugging a program look like? by saagarjha on Monday June 24, 2019 @03:11AM (#20261188)
I can’t always fix “my” code, then :(
Re:What does debugging a program look like? by kdelok on Monday June 24, 2019 @07:28AM (#20262373)
I'd generally agree with this (bumped up against more gcc, libc and kernel bugs than I'd have liked), but I find that my code has even more bugs than that. :)