logoalt Hacker News

munksbeeryesterday at 5:37 PM1 replyview on HN

We have a java monorepo of relatively large size and sophistication, driving our entire fintech, and I haven't seen a NPE for years.

Use NullAway and it basically makes the problem go away. Our application won't build if it detects a potential NPE.


Replies

unscaledyesterday at 7:52 PM

Congratulations. You've added another build tool and sprinkled your code with ugly annotations and ifs and Optional Optional.of(x).map(y) all over the place to get the same thing you'd get by moving to Kotlin.

I get it why this seems like a less drastic change, but this saddens me. Kotlin solves more issues with the type system (smart casts, reified types, immutability by default), without sacrificing readability. Unless I can see a solution in Java that makes dealing with NPEs as easier for lazy developers as ignoring them, I don't consider it a solved issue.

show 2 replies