Re:Rust vs. Go in 2023
by xyproto on Sunday August 13, 2023 @04:34AM
(#37107866)
You can look at "if err == nil" and tell what is going on, but who knows which layer of exception handling will catch that "throws".
[ Parent
| on HN ]
In JVM languages it is easy to know what is catching what.
The method type signatures clearly specify what exceptions will be thrown.
And the compiler requires you to deliberately handle those exceptions.
But I wouldn't consider Java to be the best approach for error handling anyway.
Which is the only sane thing in most cases. What can you do inside the helper function of a helper function with an incorrect user data? The only sane place to handle it is n levels up, so bubbling up is the correct default. At least rust has a handy macro for it, but go’s error handling is catastrophic, not a proper sum type, nor some form of propagation… it is literally the bad errno from C burned into the language.
Re:Rust vs. Go in 2023
by Aditya_Garg on Sunday August 13, 2023 @12:41PM
(#37111551)
In go, you should manually propagate the errors up by returning them. At the n levels up, you handle the error. It's a bit cumbersome during write time but a life saver during read/debug time.