logoalt Hacker News

iaaan • yesterday at 6:05 PM • 3 replies • view on HN

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.


Replies

sn9 • yesterday at 7:29 PM

Returning Result/Options that the compiler forces you to check so you can't forget.

Common in ML-family languages and Rust. They've been brought into most mainstream languages like Java by now because of how useful they are.

➕ show 2 replies
vips7L • yesterday at 6:45 PM

Personally I think Go style is worse, because the runtime and compiler don't force you to handle the error. I just had to fix a critical issue because a dev forgot to check the result coming from a function, exceptions would have forced it to happen.

Tadpole9181 • yesterday at 8:45 PM

> I kinda like JS's promise syntax with the `.then()` and `.catch()`, but it doesn't appear that different to Go's approach.

These days async/await is first-class and the function-based callback form of promises is largely discouraged. And for, at least in part, the same reason: it's harder to enforce correctness.