7 ms·
The slow-down doesn't come from NPEs occurring as bugs. The slow-down occurs from all the extra thinking that happens once [your teammate] allows nulls into th
by mrkeen 4y ago
The slow-down doesn't come from NPEs occurring as bugs.
The slow-down occurs from all the extra thinking that happens once [your teammate] allows nulls into the code "as a feature".
If you assume no nulls, then you get to lean on the type system. A String is actually a String, not an instruction to GOTO the nearest enclosing RuntimeException handler.
And honestly, I'd be mostly happy to work on the no-null assumption, hit a few NPEs, and fix them as I go. But someone else will decide that nulls are OK as values, and now every value is suspect. Which means you can no longer just blindly assert against nulls.
And that's the value-add of Optional. You can use it to deliberately represent things that aren't there, meaning you can go back to treating every null as a bug to squish, rather than a design choice.