The fact that safe language implementations have to think hard about how to handle null pointer exceptions safely should have been a warning sign that null pointers are a bad thing to have in a language. Sadly nearly always unheeded.
-
-
I think that argument works for Rust but not, say, Go. Nobody would notice if Go switched to emitting explicit null checks. Heck Swift *branches on all arithmetic* and that cost is not prohibitive within its domain.
-
1. I’m not sure nobody would notice. 2. To the extent that it wouldn’t be noticed, it’s because Go’s compiler generates slow code, somewhat hiding the problem. This doesn’t make it less of a problem. 3. Why go to all this trouble? Is null really so great that it’s worth it?
- 2 more replies
New conversation -
-
-
The difference between Option<T> and nullable pointers is that you typically only use Option<T> where you actually need it, and the programmer can hoist the null checks out and only do them once instead of repeatedly inside loops, etc.
-
A decent compiler would automatically hoist them out of loops.
- 2 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.