Re:New Features in Java 14
by tmpz22 on Tuesday March 03, 2020 @06:05PM
(#22479594)
I can't speak for Rust, but in Go accessing properties of nil objects and dealing with 0-values for non-pointer values can cause bugs in certain contexts where you "let your guard down".
Also worth noting dealing with booleans in JSON is wonky because boolean values default to false, even if that json property wasn't set over the wire. Thus you end up unmarshaling to a pointer to a boolean, which now requires nil guards throughout your codebase when working with that unmarshaled object...
[ Parent
| on HN ]
Re:New Features in Java 14
by steveklabnik on Tuesday March 03, 2020 @06:34PM
(#22479790)
Rust does not have nil objects nor zero values.
The equivalent rust code would fail to compile.
Re:New Features in Java 14
by erik_seaberg on Tuesday March 03, 2020 @07:02PM
(#22479981)
Go also has https://golang.org/doc/faq#nil_error, so interface != nil doesn't ensure it's safe to call any of its methods.