Hacker News new | ask | show | jobs
by mdc2161 466 days ago
It is very much not being turned into synchronous code. There are a lot of reasons to use async code, and they're all still valid with this pattern.

For example:

- the event loop is still not being blocked

- the calling code can still be flat instead of nested callbacks (truly synchronous) or chained `.then` calls

Is it a little bit more boilerplate? Yes, definitely, and it's certainly less nice to look at. But it's linter-enforceable consistency that removes the cognitive overhead of an annoying to debug footgun.

Note: My favorite style is typed error returns instead of thrown exceptions. In that world, you only need try/catches at the boundaries of your code and for application crashing exceptions. Unfortunately most codebases aren't written like that and I'm often working in inherited code instead of greenfield.

1 comments

I think my point is that awaits are often used because the coder can't work out or can't be bothered to work out how to treat promises more intelligently.