> What are your thoughts on aync/await then (available in Python/JavaScript etc.)?
Not the OP, but I find it hard to have an absolute opinion on this - IMO some recent additions to javascript significantly decrease cognitive load.
async/await is a great example of this (vs then/catch/finally chains), and also:
* spreading of arrays, props, and more arguably args
* shortcutting prop/value pairs, e.g. { x:x } as { x }
Some stuff it seems are more confusing, e.g.
* similar but subtly different things like for/of vs for/in vs forEach vs iterating Object.keys(), Object.values(), Object.entries()
* what are generators and the yield keyword for?
Generators are great for memory intensive data structures (ie. large lists), as they provide lazy evaluation to languages that are designed to evaluate eagerly. Generators can be considered to be a first step towards coroutines if you will, as the subroutines are the ones yield-ing control back to the event loop - David Beazley has a great talk[0] on it, coding an event loop live from scratch.
> similar but subtly different things like for/of vs for/in vs forEach vs iterating Object.keys(), Object.values(), Object.entries()
Array.forEach[1] is the oldest of that bunch, Object.keys[2] came later, for...in[3]/for...of[4] after that, and Object.values[5]/Object.entries[6] are the newest addition. I personally prefer the new way here.
EDIT: for...in[3], then Array.forEach[1], then Object.keys[2], then the rest it seems.
Not the OP, but I find it hard to have an absolute opinion on this - IMO some recent additions to javascript significantly decrease cognitive load.
async/await is a great example of this (vs then/catch/finally chains), and also:
* spreading of arrays, props, and more arguably args * shortcutting prop/value pairs, e.g. { x:x } as { x }
Some stuff it seems are more confusing, e.g.
* similar but subtly different things like for/of vs for/in vs forEach vs iterating Object.keys(), Object.values(), Object.entries() * what are generators and the yield keyword for?