News for hackers. Stuff that matters.
Re:Ask HN: What habits make a programmer great? by nostrademons on Thursday July 06, 2017 @04:49AM (#14708973)
Only if a.) you can do something to recover from the null pointer or b.) you can provide more information about its cause than you could recover from an ordinary stack trace. Otherwise you're just adding code without changing the ultimate result of the NPE: a debugging session.

Assertions, however, are great. If you can force the program to throw that NPE closer to the point where it actually illegitimately became null, the debugging session becomes much shorter. Null-safety in the type system (like with most modern languages: Swift, Haskell, Kotlin, Scala, Rust, etc.) is even better.

Re:Ask HN: What habits make a programmer great? by brlewis on Thursday July 06, 2017 @08:20AM (#14709784)
This! I especially see this problem in Java, where IDEs always suggest catching an exception. Like a dog chasing cars, you really should think through what you're going to do when you catch one. I've wasted a lot of time debugging problems that get masked over by try/catch only to pop up at some later point in a seemingly unrelated part of the code.
Re:Ask HN: What habits make a programmer great? by sgift on Thursday July 06, 2017 @06:18AM (#14709280)
I have almost never seen a program where you have neither a nor b, but I agree - if you are in a situation where neither a nor b apply, don't do anything.

And: Using a different language is always a great idea, but often not possible.