News for hackers. Stuff that matters.
Re:Twelve Years of Go by kbd on Wednesday November 10, 2021 @03:00PM (#29179835)
> No 'oops I forgot to put in a try/catch and now my code died with no explanation'.

This is so backwards. First, I want my program to immediately crash if I have a bug. Go is like shell in that it keeps going even if there's an error. Second, I'm used to getting stack traces, Go is the language that will give "no explanation" by comparison if there's a failure.

Re:Twelve Years of Go by grey-area on Wednesday November 10, 2021 @03:18PM (#29180105)
Your users typically don't want the program to crash, spare a thought for them.

Re stack traces, they're fine I guess, but I prefer a well-crafted error message to 200 lines of irrelevant file locations/functions.

Re:Twelve Years of Go by JoeyJoJoJr on Wednesday November 10, 2021 @03:53PM (#29180609)
I want my program to crash obviously during development so that I know of the existence of bugs, which can be ironed out before getting to production.
Re:Twelve Years of Go by grey-area on Wednesday November 10, 2021 @04:01PM (#29180724)
That's the theory.

In practice it's impossible to exercise all the inputs your programs may get, and then they crash in production when users do things you don't expect.

Re:Twelve Years of Go by kaba0 on Wednesday November 10, 2021 @04:50PM (#29181405)
Which is better than having a bug silently be in production for years to come due to a silent error.
Re:Twelve Years of Go by grey-area on Thursday November 11, 2021 @01:59AM (#29185223)
Which is worse than just handling the error where it occurs.
Re:Twelve Years of Go by kaba0 on Wednesday November 10, 2021 @04:49PM (#29181400)
That’s the point of exceptions. They bubble up! I can manage them at a place where it is appropriate.

Something had happened during the processing of this web request? Catch the exception and convert it to an appropriate status code.

You should only ever let exceptions fall through ”main” when the problem is really not something you can manage to handle.

Re:Twelve Years of Go by grey-area on Wednesday November 10, 2021 @05:02PM (#29181531)
That's the theory.

In practice often people let the exception eater in main handle it, and it either logs somewhere nobody looks or returns this sort of generic error and exits:

https://www.google.com/search?q=Microsoft+Word+has+encounter...

Re:Twelve Years of Go by vlunkr on Wednesday November 10, 2021 @03:40PM (#29180425)
> First, I want my program to immediately crash if I have a bug.

An error being returned doesn't always mean there's a bug.

> Go is like shell in that it keeps going even if there's an error.

With both Go and shell scripts it's up to you if you want the program to keep going when there's an error.

Re:Twelve Years of Go by kbd on Wednesday November 10, 2021 @08:01PM (#29183181)
> An error being returned doesn't always mean there's a bug.

The bug is not the error, the bug is the unhandled error.

Re:Twelve Years of Go by nineplay on Wednesday November 10, 2021 @03:36PM (#29180374)
I don't know what scale of projects you've worked on. When you're dealing 100K requests/second you very much do not want to immediately crash. It is absolutely the worst think your code can do.
Re:Twelve Years of Go by kaba0 on Wednesday November 10, 2021 @04:51PM (#29181415)
What framework, language crashes due to an exception, regardless of scale? That exception gets mapped to a http status code and that gets returned.