Why Go Can't Try: Comparing Go and Zig error types

,

This is a nice article comparing Zig and Go error types:

1 Like

Similar topic: Go's Error Handling Is a Form of Storytelling

Very interesting example of how early decisions can have such a big impact later.

1 Like

Agreed. It’s interesting to me that other things with high levels of coupling like structured logging ( log/slog package in Go) or JSON v2 (json/v2) are able to evolve; whereas, something like try stalls out.

Another interesting thought is that Zig has kinda implemented union types of error sentinels. Having a native union type makes that an easier sell when designing the language / compiler… and also makes a more sense from a C interoperability perspective because C functions only have 1 return type.

At any rate, I am still loving Go and despite reading a lot of the Zig specification and getting excited about new I/O APIs in 0.16, I haven’t built anything with it yet.