logoalt Hacker News

jazzypants • yesterday at 4:35 PM • 4 replies • view on HN

> - go style err!=nill style exception handling

Is this not widely considered to be the ugliest part of the language? Why do you prefer having to do this manually?


Replies

iaaan • yesterday at 6:05 PM

As someone who is primarily a Go dev, I never understood this criticism and have never seen a language do it any better (but I'm open to suggestions). I think try/catch is worse. I kinda like JS's promise syntax with the `.then()` and `.catch()`, but it doesn't appear that different to Go's approach.

➕ show 3 replies
ixwt • yesterday at 4:40 PM

It is, which is why the or_return[1] keyword was created.

[1]: https://odin-lang.org/docs/overview/#or_return-operator

wolttam • yesterday at 6:27 PM

Errors as values instead of some special language construct is generally a nice thing (IMO)

➕ show 1 reply
12345hn6789 • today at 12:14 AM

Yes it is and it's frankly odd we are still designing languages this way. It's a mess and a Result with typed errors is much more ergonomic and should be the standard. See either in scala for more.