3 ms·
I have a couple 50k+ loc java projects written entirely by LLMs at this point that have never thrown an NPE.
by winrid 19d ago
I have a couple 50k+ loc java projects written entirely by LLMs at this point that have never thrown an NPE.
- what_hn 19d agoSame here with go, then Again go doesn't throw!
- xdavidliu 19d agosurely 'throw a npe' means something very similar to something that Go does
- mahboi 18d agoIt'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.
- samus 18d agoSo the whole webserver dies instead of just a worker thread unwinding its stack?
- mahboi 18d agoOh, 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 https://github.com/golang/go/issues/25245 . But I guess they decided it's worse to let servers crash from trivial mistakes.
- samus 17d agoI mean, it's a smaller issue in a K8s environment as it will just spin up a fresh pod.
- za3faran 18d agoGolang doesn't have solutions like these: * https://jspecify.dev/docs/user-guide/ https://jspecify.dev/docs/user-guide/ * https://openjdk.org/jeps/8303099 https://openjdk.org/jeps/8303099
- unscaled 18d agoSure it does: https://github.com/uber-go/nilaway 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.
- samus 18d agoThat one works pretty much the same way as NullAway, which is kinda unsurprising because of the name and because of who made it.
- unscaled 18d agoGo panics.
- gf000 18d agoIt just swallows errors, so you don't even know about it!
- mahboi 17d agoI 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.