4 ms·
Ask HN: Am I the only one that doesn't really like async/await syntax?
I actually prefer `.map`-able or `.then`-able constructs (i.e. Promise/Future/Deferred/Optional/Either though they're all slightly different), and don't often mind putting all my error handling in one place.
As long as whatever language it is has an ergonomic errors-as-values, and you return the proper types, catching all the errors in one place is actually not so bad, you just match (if the language supports it) or `switch` on the error you got and do what's necessary... async/await on the other hand just seems like a fancy way to put litter my code with try/catch and the nested-and-to-the-right logic that comes with it in trivial cases (where it doesn't make immediate sense to factor out into another function).
I think `.then`-able/`.map`-able code also encourages you to factor out lengthy chained functions into composable pieces, since a `.then(... lots of code ...)` looks pretty bad very quickly.
To help make my biases a bit clearer, I am the kind of person that prefers `>>=` (pronounced "bind") to `do` notation in Haskell, for similar reasons, and rust's ? operator is one of the best syntactic innovations I've seen, because it strikes a nice middle ground IMO.
- steveklabnik 8y agoYou’re not the only one. In Rust, it’s more significant than in GC’d languages, or ones that don’t validate pointers. You cannot borrow across these kinds of method chains, but you can across await points. That’s the major reason we’re introducing it: http://aturon.github.io/2018/04/24/async-borrowing/ http://aturon.github.io/2018/04/24/async-borrowing/