Danielle McLean (2017-02-24T05:28:07.000Z)
On 24 February 2017 at 16:19:03, Šime Vidas (sime.vidas at gmail.com) wrote:
> To clarify, the idea is to declare and kick off all the concurrent tasks upfront

Well, that's what promises *already* do, even without using the
`async` and `await` keywords. You kick off all concurrent tasks
up-front - it's only tasks that depend on a previous task's result
that need wait around for that task to finish. Without `async`
functions, you'd probably do something like this:

    function makePizza(sauceType = 'red') {
      const dough = makeDough(), sauce = makeSauce(sauceType);
      const cheese = sauce.then(s => grateCheese(s.determineCheese()));
      return Promise.all([dough, sauce, cheese]).then(function([dough,
sauce, cheese]) {
        dough.add(sauce);
        dough.add(cheese);
        return dough;
      }
    }

With `async` functions, you can avoid all those lambdas and the code's
a little bit cleaner - either way, you don't need new JS magic to do
things concurrently!
tj.crowder at farsightsoftware.com (2017-02-24T05:31:39.648Z)
On 24 February 2017 at 16:19:03, Šime Vidas (sime.vidas at gmail.com) wrote:
> To clarify, the idea is to declare and kick off all the concurrent tasks upfront

Well, that's what promises *already* do, even without using the
`async` and `await` keywords. You kick off all concurrent tasks
up-front - it's only tasks that depend on a previous task's result
that need wait around for that task to finish. Without `async`
functions, you'd probably do something like this:

```js
function makePizza(sauceType = 'red') {
  const dough = makeDough(), sauce = makeSauce(sauceType);
  const cheese = sauce.then(s => grateCheese(s.determineCheese()));
  return Promise.all([dough, sauce, cheese]).then(function([dough, sauce, cheese]) {
    dough.add(sauce);
    dough.add(cheese);
    return dough;
  }
}
```

With `async` functions, you can avoid all those lambdas and the code's
a little bit cleaner - either way, you don't need new JS magic to do
things concurrently!