Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's consistent use of Result and Option in std, community agreement to do things that way, and it's pretty easy to use them.

Tons of stuff in std and many other crates don't use async. A lot of stuff is harder and more code to do async. A lot of it is much harder to read.

That's the difference.



> There's consistent use of Result and Option in std,

Well, there are dozens[0] of incompatible error types in std, two of them being just called `Error`[1][2].

Everytime you create a function that use more one of the different error types from std (for instance, an I/O error and a TryFrom-related error) you have to create a custom Error enum to accommodate the different kinds of errors from std…

> community agreement to do things that way

And the community agreement is e̶r̶r̶o̶r̶-̶c̶h̶a̶i̶n̶, ̶f̶a̶i̶l̶u̶r̶e̶, ̶ s̶n̶a̶f̶u̶, this_error, unless it's for a binary crate and then it's ̶a̶n̶y̶h̶o̶w̶, ̶e̶y̶r̶e̶, color-eyre.

The error ecosystem is much more fragmented than the async one (even though I think this_error is here to last, so I don't have to migrate once again…). In the async world, there's pretty much tokio (but I think it would actually be better if it interoperated better with other runtimes so alternatives could emerge)

> A lot of it is much harder to read.

Ah yes, fut.await is fundamentally harder to read than res?, right?

Overall, you vastly underestimate the friction that the `Result`-based error handling adds. I still think it's worth it, and it's been slowly getting better (did I say I loved this_error?), but it remained one of the biggest point of friction in Rust over the 8 years (time flies) I've been using it. Async is comparatively less disrupting (mostly because it only appears in the call stacks where you're doing I/O, whereas errors are ubiquitous).

[0]: https://doc.rust-lang.org/std/error/trait.Error.html?search=...

[1]: https://doc.rust-lang.org/std/io/struct.Error.html

[2]: https://doc.rust-lang.org/std/fmt/struct.Error.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: