3 ms·
If the bar was as low as Go it would be quite easy in Rust. It's just string concat after all.. but i'm quite glad they didn't use that low bar, it's awful to d
by lijogdfljk 4y ago
If the bar was as low as Go it would be quite easy in Rust. It's just string concat after all.. but i'm quite glad they didn't use that low bar, it's awful to deal with imo.
- c7DJTLrn 4y ago>It's just string concat after all If you're properly wrapping errors it isn't. fmt.Errorf("... %w", err)
- lijogdfljk 4y agoHas the meaning of that changed since i used Go? I thought the output of that is _literally_ a string, no? I think you misunderstand me. I'm not complaining that there is no context. I'm complaining about destroying all structured content. If you want information out of that, you have to string parse your errors! No type checking or anything useful on error types either. Yes, it's possible, but that usually comes with 3rd party libraries that manage errors with structure. Such as a large array of arrays producing a structured "stack". But if a single person uses string formatting with your nice structured error? Goodbye structure, hello string parsing. It's a very, very low bar.
- c7DJTLrn 4y ago>I thought the output of that is _literally_ a string, no >If you want information out of that, you have to string parse your errors I'm trying not to be an asshole here, but have you actually played with Go? It seems a lot of the Go hate comes from people with extremely trivial knowledge of it. The %w directive is not just a simple string format/concat. It constructs an error which when String() is called on it, will appear as a concat'd string, but the underlying error is preserved. https://go.dev/play/p/ZUGCKJDs9N5 https://go.dev/play/p/ZUGCKJDs9N5
- lijogdfljk 4y agoYea, professionally for 5 years, though it's been a good 4 years since i used it. Looking at the release notes, %w was introduced in 2019. So yea, my professional experience with Go predated that. It was all strings back then, and miserable. My team usually used libraries to deal with the shortcomings. I ended up leaving Go frustrated mostly because of how simple patterns, like Iterators (in Rust) were so horribly expressed in Go. Stretched out into many, many lines of code. All the simplicity of the language left me with no help to manage my actual app complexity. However i am aware that slowly Go is adding complexity to help you manage real problems. Generics, and apparently sane error handling. I'd love to see them add Enums, as Go's version always felt ... well, just a bunch of consts in userland pretending to be Enums heh. Maybe one day Go will be feature complete enough for me to look back. Though i'm a big fan of Rust, so maybe not. The only area i feel Go is better than Rust is the way in implements Async, but that's likely more to do with the GC - so, tradeoffs as with everything.