News for hackers. Stuff that matters.
Re:Down the Golang Nil Rabbit Hole by tptacek on Tuesday March 30, 2021 @03:38AM (#26632063)
Errors in Go have been queryable chains since 1.13; it's pretty seamless with `%w`. Rust has the `?` shorthand, which is very convenient, but also the annoyance of type matching errors, particularly across different libraries, to the point where third-party error handling libraries like `anyhow` are pretty important. Leaving nil itself out of the picture (obviously, I'd rather Go had Option types), I don't know that either language has a definitive edge here.

Errors in modern Go are definitely not just strings.

Before wrapped errors in Go, this would have been an easier case to make against the language.

Re:Down the Golang Nil Rabbit Hole by iudqnolq on Tuesday March 30, 2021 @04:05PM (#26639697)
Anyhow's tagline is literally "a better Box<dyn Error>", which gets you nearly the same result modulo some pretty printing.
Re:Down the Golang Nil Rabbit Hole by tptacek on Tuesday March 30, 2021 @05:05PM (#26640493)
Yes, Anyhow is almost as easy to use as Go's current error handling.
Re:Down the Golang Nil Rabbit Hole by iudqnolq on Tuesday March 30, 2021 @05:10PM (#26640562)
You're significantly more experienced than me, so I'll defer to you here. What you're saying doesn't make sense to me though.
Re:Down the Golang Nil Rabbit Hole by tptacek on Wednesday March 31, 2021 @03:29AM (#26644434)
You're probably more experienced than I am with Rust!
Re:Down the Golang Nil Rabbit Hole by iudqnolq on Wednesday March 31, 2021 @06:14AM (#26645446)
I might be misunderstanding go, but I think the big difference is you use anyhow to get looses error handling at the edges of binaries. It'd be weird to see in a published library, and unusual to see deep in an internal library that supports a binary. Whereas in go you do that sort of error handling everywhere.
Re:Down the Golang Nil Rabbit Hole by tptacek on Wednesday March 31, 2021 @02:18PM (#26650932)
I think %w makes sense in libraries, too. They're structured errors that behave like strings. It's a neat trick.
Re:Down the Golang Nil Rabbit Hole by tsimionescu on Tuesday March 30, 2021 @05:30AM (#26632640)
Most errors in Go are still just strings, potentially with some comparison possible witht sentinel values like in the "io" package. As and Is give some nice tools, but its still up to documentation to decide which one to use, and different packages have different conventions for returning error types vs error values.
Re:Down the Golang Nil Rabbit Hole by saturn_vk on Tuesday March 30, 2021 @06:36AM (#26633008)
Most errors are probably strings since there probably is nothing you can customize as a handling for such particular error types. Now, if one could do something with a certain error class, then such error are usually not strings.