News for hackers. Stuff that matters.
Re:Go 2.0 Error Handling Requirements by codr4 on Sunday October 14, 2018 @05:27PM (#18215471)
Go's resistance to exceptions looks like Steve Jobs and his one button mouse from here. It's not like renaming them to panic/recover fooled anyone outside of the Pike reality distortion field. Sometimes unwinding the stack is exactly what you want. Optional types are nice too, but that's more for things that are intentionally missing. I have yet to see anything here that's an improvement over just doing the obvious thing.
Re:Go 2.0 Error Handling Requirements by nicoburns on Sunday October 14, 2018 @05:44PM (#18215597)
I'm not sure about that. Rust's use of a Result type instead of exceptions is one of my favourite things about Rust. Before I'd used it, I'd not realised how many reliability issues in other languages were caused by overlooked exception cases.

Exceptions are great when you don't want to handle errors properly, but when you do want robust error handling I find the "return a value" pattern much better. Notably even C++ is looking into implementing this!

Re:Go 2.0 Error Handling Requirements by aikah on Sunday October 14, 2018 @06:09PM (#18215765)
> I'm not sure about that. Rust's use of a Result type instead of exceptions is one of my favourite things about Rust.

It works because Rust has pattern matching and generics as well. Just having a Result type isn't going to help with error handling much, and Go is not getting generics Rust style nor pattern matching any time soon.

Let us be reminded that Go errors as values are purely a convention, nothing in the language mandates their use. On the other hand panic/defer/recover are language constructs.

Re:Go 2.0 Error Handling Requirements by threeseed on Sunday October 14, 2018 @06:13PM (#18215797)
Exactly the same with Scala.

Option types demand pattern matching and similar techniques for working with those types. Otherwise you just have "if (x.isDefined) a else b" blocks of code everywhere.

Re:Go 2.0 Error Handling Requirements by codr4 on Sunday October 14, 2018 @05:56PM (#18215682)
They are not overlooked, they are better handled further up the call stack. And not having the option to forward them implicitly is a step back, not forward. There's no way to make a programming language better by forcing users to do anything, in many cases the user will have more experience than the person implementing the language. A programming language is a tool, predicting and dictating how the tool is to be used is missing the point.
Re:Go 2.0 Error Handling Requirements by qz_ on Sunday October 14, 2018 @06:12PM (#18215791)
I don't think forcing is the right word.. I've noticed that languages where the "right way" is the path of least resistance the code quality stays high even if a lot of people with varying levels of expertise contribute
Re:Go 2.0 Error Handling Requirements by maxscam on Sunday October 14, 2018 @08:33PM (#18216515)
Well in my experience golang Is a long ways from this anyway ... It's a very prescriptive language
Re:Go 2.0 Error Handling Requirements by TheCoelacanth on Monday October 15, 2018 @12:29PM (#18221117)
Forwarding errors upwards is one character in Rust (?). IMO that is pretty much the perfect balance between forwarding errors easily and explicitness.
Re:Go 2.0 Error Handling Requirements by cle on Sunday October 14, 2018 @06:15PM (#18215812)
> There's no way to make a programming language better by forcing users to do anything

Sure there is, many important language features boil down to forcing users to do the right thing (not necessarily the easy thing).

In highly concurrent languages like Go, there’s not always a meaningful stack to unwind, and you end up having to pass error values around anyway. So I can easily sympathize with the decision to stick with one mechanism for error handling.

Re:Go 2.0 Error Handling Requirements by jcelerier on Sunday October 14, 2018 @07:06PM (#18216102)
> many important language features boil down to forcing users to do the right thing

this just causes the users to use another language for their projects instead

Re:Go 2.0 Error Handling Requirements by mixedCase on Sunday October 14, 2018 @08:15PM (#18216433)
And fixing the output of that is where the rest of us often profit from.

A language that provides a lot of freedom when it comes to expressiveness without offering much in the way of constraints (to truly convey the purpose of a given piece of code with the least amount of ambiguity possible) will almost definitely turn into utter crap in contact with junior developers, and will often be a source of pain for more experienced ones once the project is nontrivial, whether they realize it or not.

Re:Go 2.0 Error Handling Requirements by codr4 on Sunday October 14, 2018 @11:25PM (#18217206)
Do you see any problems with optimizing everything we do for junior developers? I mean, most of us aren't, and it would be really nice if someone gave a crap about wasting our lives as well.
Re:Go 2.0 Error Handling Requirements by chousuke on Monday October 15, 2018 @01:30AM (#18217552)
It's not necessary optimizing for junior developers. When properly implemented, language hand-holding is a tool for "better" programmers as well. I find that my brain capacity is limited, and the more I can focus it on issues that are productive rather than eg. tracking the liveness status of my data or potential system-wide effects messing with it, the more useful work I can perform.

Not to mention working together with more junior people, in which case it will be you doing the hand-holding instead, because the tools don't

Re:Go 2.0 Error Handling Requirements by vbezhenar on Sunday October 14, 2018 @07:14PM (#18216139)
I don't think that Go will move to exceptions. Sure, panic/recover are renamed exceptions (very similar to Rust panics, btw), but standard library and community libraries uses errors, so you'll use them anyway (unless you want to rewrite or wrap the world which is possible, I guess, in automated way and that's a provoking thought!).
Re:Go 2.0 Error Handling Requirements by codr4 on Sunday October 14, 2018 @11:27PM (#18217213)
The standard library uses panic/recover to sort of implement exceptions here and there. It's a pretty serious case of do as I say, not as I do.
Re:Go 2.0 Error Handling Requirements by networkimprov on Sunday October 14, 2018 @11:39PM (#18217253)
Those instances are being fixed.
Re:Go 2.0 Error Handling Requirements by the_clarence on Sunday October 14, 2018 @07:47PM (#18216322)
Exceptions are like cancer. You never know when you're going to get one, you have no idea how to handle them or if you should handle them, and they produce fatal bugs at unexpected places.
Re:Go 2.0 Error Handling Requirements by codr4 on Sunday October 14, 2018 @11:30PM (#18217221)
They are used for exceptional problems, expecting one doesn't really make any sense.

Of course you do, that's the point; to unwind the stack until you reach code that knows how to handle the error.

Cancer, really; is that you Gordon?

Re:Go 2.0 Error Handling Requirements by dpc_pw on Monday October 15, 2018 @12:17AM (#18217354)
Errors are not exceptional problems.
Re:Go 2.0 Error Handling Requirements by codr4 on Monday October 15, 2018 @02:16PM (#18222164)
I didn't say that, I said that exceptions are used for exceptional problems. Expected errors like missing values are better handled using optional types. I find the one ring to rule them all attitude less than constructive.
Re:Go 2.0 Error Handling Requirements by derblitzmann on Sunday October 14, 2018 @10:05PM (#18216924)
I'll annonance my bias towards go. But from what I understand, allowing exceptions allow for more complex code parhs. Whereas explicit error handling forces you to handle it in the moment.
Re:Go 2.0 Error Handling Requirements by codr4 on Sunday October 14, 2018 @11:32PM (#18217228)
Yep yep, sounds good.

Problem is you're not handling errors, you're wasting precious energy shuffling errors to code that knows how to handle it; which is exactly what exceptions could do for you. The end result is the same, except it takes more effort and the code looks like crap.

Re:Go 2.0 Error Handling Requirements by api on Sunday October 14, 2018 @06:51PM (#18216019)
Exceptions are really no less complex than return values, and they do not (easily) play nice with asynchronous and lambda/functional programming models. Witness their near abandonment in JavaScript for example.

I like Go mostly the way it is. Its simplicity is genius. Anything added should be considered with great care.