Hacker News new | ask | show | jobs
by winrid 79 days ago
I have a couple 50k+ loc java projects written entirely by LLMs at this point that have never thrown an NPE.
1 comments

Same here with go, then Again go doesn't throw!
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.

That one works pretty much the same way as NullAway, which is kinda unsurprising because of the name and because of who made it.
surely 'throw a npe' means something very similar to something that Go does
It's a panic in Go, not an exception. In practice that's usually a whole process crash. You can catch panics and kinda use them like exceptions, but it's not conventional.
So the whole webserver dies instead of just a worker thread unwinding its stack?
Oh, net/http recovers from a panic inside a handler and sends error 500. I don't know if that was always the default. Where I worked before, our own Go servers didn't recover, and it did cause outages.

This is kinda bad practice. Go and Rust panics are similar, they aren't exceptions that you can safely recover from. Say there's a panic in the middle of modifying some global state like a database connection. Hence complaints about the net/http recover like https://github.com/golang/go/issues/25245 . But I guess they decided it's worse to let servers crash from trivial mistakes.

I mean, it's a smaller issue in a K8s environment as it will just spin up a fresh pod.
It just swallows errors, so you don't even know about it!
I don't get why they didn't just do !/? syntax like in Rust. Or at least make it a compiler error to ignore err returns.
Go panics.