News for hackers. Stuff that matters.
Re:After a year of using Node.js in production by firasd on Monday May 02, 2016 @06:46PM (#11616367)
So in PHP, you would go (I haven't tested these snippets, just writing them out here):

  $username = get_username();
  echo "Hi, ".$username;
  do_other_things();
In Node, using promises, you have to write:

  get_username().then(function(username) {
    return res.send("Hi "+username");
  }).then(function() {
    do_other_things();
  })
And if you're using regular callbacks, forget it: you'd have to nest do_other_things in the callback of get_username(!). It just makes things very awkward.

I understand what you mean about sync vs async calls. I won't pretend I have a better solution. I don't mean to say callbacks are illogical, just a bad way to write programs. So maybe not 'wrong in concept', I can concede that. But I think async/await can make things more readable again, i.e.:

  var username = await get_username();
  /* carry on... */
Re:After a year of using Node.js in production by spion on Monday May 02, 2016 @07:27PM (#11616626)
If otherThings is unrelated, you could also do this:

    var username = getUsername();
    var resultSent = username.then(username => res.send("Hi "+username"))
    var otherThings = doOtherThings()
    return Promise.all([resultSent, otherThings])
Re:After a year of using Node.js in production by tomc1985 on Monday May 02, 2016 @11:24PM (#11617658)
It's not so much because of promises, its because sync IO blocks the GUI thread, so you have to write callbacks somehow. Pick your poison.