Re:Better Java – Resources for Writing Modern Java
by asveikau on Sunday September 20, 2015 @12:31AM
(#10246568)
By all means, have more clumsy, less straightforward ways to represent the lack of a value in your code, because Tony Hoare says so.
[ Parent
| on HN ]
Re:Better Java – Resources for Writing Modern Java
by Peaker on Sunday September 20, 2015 @02:42AM
(#10246762)
An Optional type is more clumsy than null checks and null returns sprinkled everywhere??
Re:Better Java – Resources for Writing Modern Java
by harryh on Sunday September 20, 2015 @03:15PM
(#10248640)
The problem with NULL is that it can be there for literally any reference in your code. So, unless you are careful, you can get an NPE when calling any single object method. In languages without NULL this can never happen making them much easier to reason about.
Re:Better Java – Resources for Writing Modern Java
by asveikau on Tuesday September 22, 2015 @12:51PM
(#10259839)
My initial reaction: programming ain't bean bag. Them's the breaks.
Then I think of it and I see the real problem is languages making all nonprimitive types into pointers without being explicit. In a language like C it's more obvious what can be null.
Re:Better Java – Resources for Writing Modern Java
by harryh on Wednesday September 23, 2015 @12:56PM
(#10266225)
If null can be problematic then certainly making it more obvious when you might have a null is a pretty good idea. I tend to think, however, that getting rid of null completely as a concept is even better. One less thing to worry about.
Re:Better Java – Resources for Writing Modern Java
by cam- on Sunday September 20, 2015 @03:42PM
(#10248740)
A NullPointerException is unchecked as well. I would say about 40% of our code is checking for null to avoid NPEs especially with APIs. You have to protect yourself and cannot take nothing for granted.