News for hackers. Stuff that matters.
Re:Working with Errors in Go 1.13 by sfifs on Sunday October 20, 2019 @12:29AM (#21302289)
While Go has issues with lack of functionality in error handling, I think the biggest win has been treating error as value and returning error via multiple return values paradigm. It forces the programmer to be aware of the possibilities of errors when using functions and explicitly handle them.

When working in other programming languages, this is something I sorely miss and have to resort to ugly and non intuitive try catch constructs which feel like "bolt-on magic" rather than a natural part if the program.

IMO this feature makes up for most of the stuff that's lacking.

I'm not sure where you're going with the stack traces complainr. It is pretty trivial to get it in Go.

Re:Working with Errors in Go 1.13 by groestl on Sunday October 20, 2019 @04:18AM (#21302855)
When you start thinking about every function having multiple return values, one of which is an error optional, treat every one of those function as failable, and then build that functionality into the compiler - then you soon arrive at proper exceptions. Granted, forcing the error machinery syntax upon the programmer makes it more explicit and requires less discipline, but it also gets old pretty fast.
Re:Working with Errors in Go 1.13 by hechang1997 on Monday October 21, 2019 @01:00PM (#21314550)
Yes. Exception is generally a decent solution to error handling unless you're using RAII languages like C++/Rust where unwinding the stack doesn't work well with destructors.
Re:Working with Errors in Go 1.13 by tonyedgecombe on Sunday October 20, 2019 @06:22AM (#21303290)
Except it doesn't force you to be aware of them or explicitly handle them. It relies on a programmer having the discipline to handle them, or even just the inclination to do so. Fine in a perfect world but most of us work in an environment with unreasonable deadlines, we are tired and eager to get home on Friday afternoon, mistakes happen.
Re:Working with Errors in Go 1.13 by littlestymaar on Sunday October 20, 2019 @03:55AM (#21302775)
> I think the biggest win has been treating error as value and returning error via multiple return values paradigm.

Treating errors as value is cool (no exception!) but using multiple values not so much, the proper way to do so is with product types, but Go's type system don't have them unfortunately…

Re:Working with Errors in Go 1.13 by atroche on Sunday October 20, 2019 @04:18AM (#21302856)
Do you mean sum types? Like Haskell's Maybe and Rust's Result?
Re:Working with Errors in Go 1.13 by littlestymaar on Sunday October 20, 2019 @06:55AM (#21303385)
Sum types indeed, thanks. That's why I shouldn't post before breakfast.
Re:Working with Errors in Go 1.13 by weberc2 on Sunday October 20, 2019 @08:37AM (#21303749)
It would be great if Go had sum types for error handling, but errors-as-values is great. And the conventions around error handling are pretty easy to work with—the biggest issue is still the anemic error interface (no standard for stack traces, just a string error message, etc).