▲ | jajko 5 hours ago | ||||||||||||||||
I wouldn't put that much drama into nulls, these are mostly academic discussions. In real world its much less drama in well maintained codebases, once you learn working with them you don't even actively think about it. In the meantime, basically all companies run on it, and will do so for next 50 years minimum, plus you have what... 17 million devs working with it? Defensive programming is generally a good approach regardless of domain or language used, and if used well you don't have to worry about nulls in Java, at least not in your own code. | |||||||||||||||||
▲ | brundolf 4 hours ago | parent | next [-] | ||||||||||||||||
I worked at a Java shop for a while, with a small and new-ish codebase built by experienced devs, and most of the errors we encountered were null pointer exceptions. It was always just, "alright where do we need to add another if-statement this time" Of course you could be "defensive" by adding an if-statement every single time you use any object. But that would mean an order of magnitude more lines of code, and even then it would be easy to miss cases | |||||||||||||||||
▲ | lolinder 4 hours ago | parent | prev | next [-] | ||||||||||||||||
Every thread about null has someone come in and make this claim that it doesn't come up in production in well-maintained codebases, but it feels very No True Scotsman: every counterexample that someone can point to immediately doesn't count, because the definition of a "well-maintained codebase" seems to be one in which null pointers aren't an issue. I guess that's a fine definition in theory, but every codebase that I've ever worked in that was written in a language with null references has had null pointer exceptions as one of the top recurring bugs. Maybe that means all my codebases have been poorly maintained, but if so that's a very good reason to design languages that require less maintenance. | |||||||||||||||||
▲ | tshaddox 4 hours ago | parent | prev | next [-] | ||||||||||||||||
Of course it's physically possible for a software project to exist where all contributors flawlessly handle nullability. The point is rather that, because this can be automated, it ought to be automated. The same could be said of automated tests ("in well-maintained codebases contributors manually run through a large suite of tests to ensure there are no regressions.") | |||||||||||||||||
▲ | stouset 4 hours ago | parent | prev | next [-] | ||||||||||||||||
This is the “as long as programmers are perfect and remember to always do the right thing everywhere, everything will be great” argument. Developers are not perfect and the footguns in languages have a cumulative effect. Any one thing isn’t necessarily a big deal but when you have multiple interacting footguns (always check for nil, nil interfaces don’t actually equal nil, default zero values need to be sane even when they make no sense, etc.) both the surface area for errors and the level of care needed to avoid them increases dramatically. | |||||||||||||||||
▲ | vlovich123 5 hours ago | parent | prev | next [-] | ||||||||||||||||
Do you have null dereference bugs that you occasionally solve, even if only during development? The "billion dollar mistake" is a reference to the economic cost of all bugs it created as a concept. That doesn't mean you don't build techniques to work around it, but it does mean that that's the economic efficiency left on the floor. In other words, the cognitive overhead you spend on worrying about nulls (however you do that), programmers in other languages spend on other things. | |||||||||||||||||
| |||||||||||||||||
▲ | skitter 3 hours ago | parent | prev [-] | ||||||||||||||||
Finding out a piece of software I'm using is written in Go because crashes with SIGSEGV does not spark joy. |