28 ms·
There's also a usability problem. Handling results with map, map_err and .ok is way easier to follow that the minimum 4 lines you have to add in Java to do any
by LelouBil 2y ago
There's also a usability problem.
Handling results with map, map_err and .ok is way easier to follow that the minimum 4 lines you have to add in Java to do anything about a checked exception (try {} catch {}).
Explicit error handling/ignoring/passing is way better than implicit, so the direction of checked exception is good.
The debate is not really checked exceptions vs Result, it's try/catch vs map_err (and friends). And will always chose the latter.
- ragnese 2y agoBut, this isn't you complaining about checked exceptions vs Result. This is you complaining about Java's overall syntax style vs Rust's. Phrased another way, Java's syntax is fairly verbose for everything, not just for try-catching to handle exceptions.
- LelouBil 2y agoI don't know any language that has exceptions and also has no try/catch type syntax. > But, this isn't you complaining about checked exceptions vs Result Yes, I said so exactly > The debate is not really checked exceptions vs Result, it's try/catch vs map_err (and friends) The fundamentals are the same, you are forced to handle/discard/Buble up any error, but in my mind (and I assume a lot of other developers), the word "exception" means try/catch, even though like I said the fundamentals are the same.
- jen20 2y agoA simple usability improvement for try..catch in Java would be to make it an expression, so initializing a variable with a fallible operation no longer requires declaring it outside, which is ugly.