Hacker News new | ask | show | jobs
by qooleot 3215 days ago
Promises made some very valuable improvements to code patterns relative to callback-based implementations, but as a broader "nodejs vs synchronous style code" its still much harder. You sound pretty versed, but other folks might struggle. Here is an example explanation:

https://pouchdb.com/2015/05/18/we-have-a-problem-with-promis...

If we're trying to show the simplicity of modern nodejs code with non-blocking I/O, I would suggest we lead with examples like:

const foo = await queryFooObject(id); await writeToFile(foo);

True, there's still plenty of value in promises, especially for things like:

await Promise.all(severalParallelQueries);