Re:JVM/Java: Null-Restricted and Nullable Types
by ta234234234 on Friday August 02, 2024 @07:23AM
(#41137888)
Is it really though? If your problem is introducing null's into the API, I'm not sure that's a language error. I mean I get it, its verbose and cleans things up. But isn't the problem the coders doing it?
[ Parent
| on HN ]
Re:JVM/Java: Null-Restricted and Nullable Types
by The_Colonel on Friday August 02, 2024 @07:33AM
(#41137947)
Coders work with what they have. The work itself is shaped by the tools the workers use to produce it. If you give workers inadequate tools, you can't expect high quality.
Java currently doesn't provide any decent (general) solution for the problem of nullability - JSR-305 is a failed spec, Optional is very verbose, doesn't work for many use cases (e.g. isn't Serializable) and funnily enough there's no guarantee the Optional instance is non-null, value types (primitive and the preview support for complex ones) obviously covers only very specific use cases.
Re:JVM/Java: Null-Restricted and Nullable Types
by ta10238487475 on Friday August 02, 2024 @07:52AM
(#41138070)
Not a fan of Optional, or streaming in general; where I've seen it/used it its basically ruined the codebase. I guess I find this defensive stuff a bit on the nose. If its not null, you're still gonna be testing be Non-Optional.