Sugar for error handling is already a solved problem (.e.g: Rust, Swift, or Zig).
Go will be damned by the community's NIH syndrome.
Sugar for error handling is already a solved problem (.e.g: Rust, Swift, or Zig).
Go will be damned by the community's NIH syndrome.
Sum types + pattern matching + tuples alone are so powerful, they could fix like top 5 of my biggest annoyances with Go.
Add some syntax sugar (like '?' from Rust), and it fixes a majority of the boilerplate issues.
Imo, people praise Rust too much for the ownership and safety story, and way to little for its (more simplistic) excellent decisions around simple types.
Long before Rust I used to implement this (to the extent possible) with templates in C++ when I'd start work on a new code base, if it didn't exist. With generics added to Go I might start the same at my current role. It's too bad there aren't other tools to support it (e.g. macros).
It would not be as bad if they were typed at least. My main pain point of Go error handling is that it's all `error` everywhere, and you have to read docs or even library code to understand what kind of errors there can be and how to handle them.