Re:A Reply to “Let’s stop copying C”
by ChrisSD on Saturday January 25, 2020 @08:16PM
(#22149754)
I think the main issue is that the program should never reach a state where you're in a position to dereference a null. If it does, that means you didn't handle an error condition earlier in the program. Sure you can handle the null safely but that doesn't handle the real cause of the error.
[ Parent
| on HN ]
Re:A Reply to “Let’s stop copying C”
by MaxBarraclough on Saturday January 25, 2020 @08:32PM
(#22149818)
I agree that's also a valid point.
The solution is for the language to offer 'option types', which essentially force you to check for null. Zig does this, and the result is much nicer than how things work in C: https://ziglang.org/documentation/master/#Optionals
More importantly, they let you safely not check for null (because with null-types, you should really always be handling it, because anything can go from never-null to null-in-this-one-case without warning)