Hacker News new | past | comments | ask | show | jobs | submit login

Sadly async/await, like so many ES6/ES7 features, adds needless complexity.

You can already achieve the exact same thing with generators. Check out the popular `co` module.

Before:

  function getLikes () {
    getUsers((err, users) => {
      if (err) return fn(err);
      filterUsersWithFriends((err, usersWithFriends) => {
        if (err) return fn(err);
        getUsersLikes(usersWithFriends, (err, likes) => {
          if (err) return fn (err);
          fn(null, likes);
        });
      });
    });
  }
After, with generators (already available today):

  getLikes = co(function*() {
    const users = yield getUsers();
    const filtered = yield filterUsersWithFriends(users);
    return getUsersLikes(filtered);
  })
After, with async/await (ES7, coming soon):

  function getLikes () {
    const users = await getUsers();
    const filtered = await filterUsersWithFriends(users);
    return getUsersLikes(filtered);
  }
---

The first example is terrible and the second two are good. Is that last one really worth adding yet another language feature and two more keywords?

This is the sad thing about big committees with lots of corporations on them: everyone "representative" wants to report back to HQ that they had "impact" on the future standard, they want their fingerprints in there in some way.

That's how standards grow warts and features and keywords and competing module systems until they're a hairball.

Here's what John Resig, creator of JQuery had to say about it. It's short and funny and sad

https://twitter.com/jeresig/status/707015494956621824




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: