News for hackers. Stuff that matters.
Re:Error Handling in Zig by wredue on Sunday August 06, 2023 @11:53AM (#37023225)
Inflexibility is an actual problem.

In rust, before anyhow and thiserror, you’d see some pretty shitty hacks for the inflexible error system, such as just making all errors just a string.

It is clear that having all the errors in a list is actually good now, but that doesn’t stop programmers from hating writing boilerplate.

Again, before anyhow, if you did error properly, your errors.rs had huge swathes of From implementations. Error.rs boilerplate often outstripped your actual code.

The complaints that it’s hard to change interfaces is bad, as it’s difficult to change interface methods regardless.

Re:Error Handling in Zig by pjmlp on Sunday August 06, 2023 @12:16PM (#37023482)
The fact that Rust requires third party crates for proper error handling ergonomics, proves the point it is only partially designed.
Re:Error Handling in Zig by wredue on Sunday August 06, 2023 @03:17PM (#37025534)
It’s not partially designed so much as the type system demands it for rust.

Very unfortunately for rust, making errors not just maddening boilerplate forces you to trade compile time for reasonable errors (although, honestly, anyhow “feels” hacks to me). Compile time is already a place rust struggles as it is.

I wouldn’t bank on rust style languages having any semblance of good ergonomics for errors. But at the same time “you can just ignore it” is really not great either.

Zig errors are actually pretty nice to work with, but as is pointed out, they struggle with producing really good messages, or giving more information back.although, I will say that I nearly never need to send more information back, and there are patterns to help with that.

Still, if there was a language concept for it, that would be nicer. It’s actually not an easy problem for zig and the core foundations of the language. Just like it’s not an easy problem for rust and its core foundations.

Errors are just really shitty and, as yet, I don’t think there exists good ergonomics. I personally haven’t seen a language that does them well.

Re:Error Handling in Zig by pjmlp on Monday August 07, 2023 @01:33AM (#37030532)
Not sure what Rust style languages are supposed to be, however ML derived languages, and Swift, do it much more ergonomically, without needing third party crates.