News for hackers. Stuff that matters.
Re:Thirteen Years of Go by kaba0 on Friday November 11, 2022 @04:48PM (#33567325)
I don’t see any automatic bubble up with Go.
Re:Thirteen Years of Go by smasher164 on Friday November 11, 2022 @09:06PM (#33569285)
I don’t think the original commenter said anything about “automatic”. That’s more of a subjective decision—whether or not you manually bubble up an error, or it just floats up because of the exception handler.

Empirically, java code has had terrible error handling, because people just stick one catch statement at the root of their program. Go atleast confronts you with the error at every step.

Re:Thirteen Years of Go by kaba0 on Saturday November 12, 2022 @04:21AM (#33571511)
And that is exactly the wrong approach. You really can’t do anything with the error case at most places. If I write a web server, which parts could knowingly handle a db connection error? Either the db driver internally, or going 10 deep higher and the request handler returning an 500 error.

In go you would just verbosely (and error pronely!!) have to manually bubble it up, while this is automatically happening in Java with an informative stack trace, with no option to forget about it. Java is the one that handles error cases properly (and that’s why you might see exceptions more there — because they weren’t silenced somewhere wrongly!) here.

Re:Thirteen Years of Go by smasher164 on Saturday November 12, 2022 @06:39PM (#33578373)
I agree that a stack trace is useful, but I disagree that automatic bubbling is universally good. If you look at well-written Go, context is added to every site where you bubble up an error.