Hacker News new | ask | show | jobs
by LePetitDev 4041 days ago
+1 for generators. As a former PHP developer, I jumped into using generators that return promises in io.js (as well as es6 classes), and the code reads very much like PHP code, except all of the i/o is now asynchronous.
1 comments

There is no benefit of io being async in itself until you have many users. The immediate and more accessible benefit is speeding up individual requests due to the ease at which you can perfom io in parallel. But if you just sprinkle await/yield everywhere (which everyone unfortunately does), you don't even get this benefit.
Sure you can.

  let [a, b] = await Promise.all([asyncA(), asyncB()])
I am referring to usage of generators without promises (or rather code that uses generators in a way that it wouldnt matter if promises or thunks were used). And even then I didn't say that you couldn't, even when using promises and generators together most people make their code unneceasarily sequential.