News for hackers. Stuff that matters.
Re:Low-Level Optimization with Zig by Zambyte on Saturday June 07, 2025 @10:25AM (#44209852)
FWIW Zig has error handling that is nearly semantically identical to Go (errors as return values, the big semantic difference being tagged unions instead of multiple return values for errors), but wraps the `if err != nil { return err}` pattern in a single `try` keyword. That's the verbosity that I see people usually complaining about in Go, and Zig addresses it.
Re:Low-Level Optimization with Zig by kbolino on Saturday June 07, 2025 @10:56AM (#44210071)
The way Zig addresses it also discards all of the runtime variability too. In Go, an error can say something like

    unmarshaling struct type Foo: in field Bar int: failed to parse value "abc" as integer
Whereas in Zig, an error can only say something that's known at compile time, like IntParse, and you will have to use another mechanism (e.g. logging) to actually trace the error.
Re:Low-Level Optimization with Zig by metaltyphoon on Saturday June 07, 2025 @09:36PM (#44213945)
Yep. Errors carry no context whatsoever and you have no idea where they came from.
Re:Low-Level Optimization with Zig by Zambyte on Saturday June 07, 2025 @10:58PM (#44214237)
Re:Low-Level Optimization with Zig by gf000 on Monday June 09, 2025 @03:25AM (#44222166)
I mean, this is definitely not a strong suit of go either. In Zig you can just pass in a pointer though to add additional context.