3 ms·
> To a first approximation, the purpose of Go is to stop every codebase from reinventing its own tuples or Result<> type. Rust has this too. You can throw away
by asdkhadsj 7y ago
> To a first approximation, the purpose of Go is to stop every codebase from reinventing its own tuples or Result<> type.
Rust has this too. You can throw away type information and incur a runtime cost just like with Rust by using "Trait Objects", which are Rusts version of interfaces, basically. Luckily most choose not to use this for error communication.
However I struggle to understand that throwing type information away and incurring runtime cost is the pinnacle of error communication.
Furthermore, the idea that this somehow prevents codebases from "reinventing" anything is absolute nonsense. Basically every Go lib out there has different error handling. Hell, I wrote a library of my own (similar to pkg/errors). The very items I listed in my OP showed how every lib has it. You have no idea how each Go lib reinvented the wheel to know how you handle their errors. All with runtime checking. Madness.