3 ms·
A better comparison here is with C/C++/go, e.g. other languages that are designed to be fast and compiled. In any of those, dereferencing a null pointer is und
by drewcrawford 13y ago
A better comparison here is with C/C++/go, e.g. other languages that are designed to be fast and compiled.
In any of those, dereferencing a null pointer is undefined. The compiler can literally emit code that plays Nethack in this situation [0]. ObjC's "nothing will happen" behavior is a significant improvement in safety against similarly-situated languages.
[0] http://feross.org/gcc-ownage/ http://feross.org/gcc-ownage/
- frou_dh 13y agoYou're incorrect about Go. It's in the spec that derefing a nil pointer will cause a runtime panic (~ an exception). http://golang.org/ref/spec#Address_operators http://golang.org/ref/spec#Address_operators
- drewcrawford 13y agoI stand corrected.
- pnathan 13y agoNot defending "undefined" here, at all. I'd rather see the definition be, at least, exit(0xff) (or some other mechanism that reliably denotes "method not found", "message not found", etc). I'm pretty sure I'm on record in HN for ranting about the fact that C & C++'s undefined & funny behavior literally created multimillion dollar industries in building analysis tools to cove their gaping problems. Which is why I am tend to boost Rust when possible (designed for correctness and determinism! woo!). Dropping errors is not IMO better or worse. Both are silent failure modes.