logoalt Hacker News

za3faranyesterday at 6:19 PM1 replyview on HN

Golang doesn't have solutions like these:

* https://jspecify.dev/docs/user-guide/

* https://openjdk.org/jeps/8303099


Replies

unscaledyesterday at 8:06 PM

Sure it does:

https://github.com/uber-go/nilaway

Not exactly the same solution as JSpecify, since it doesn't rely on annotations, but it's also more ergonomic.

I'm not comparing this to "null-restricted types", since that's a draft JEP that hasn't made it even into a preview feature. Go also had multiple proposals for explicit nilability in types, and while they probably have less prospect of ever seeing the light of day compared to Project Valhalla, as things currently stand, Go is in the same position as Java: They are both extremely prone to NEPs out-of-the-box and they both have external tooling that can help you avoid them.

Java null checkers have more comprehensive coverage potential compared to Go, but Go is the more ergonomic one here. You don't need a single extra annotation on your code.

show 1 reply