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

I tend to agree with the post, but I find the one-language-to-rule-them-all thing too compelling to fret too much over asynchronicity. Although it'd probably lead to lots of synchronous code, it would be nice for it to to be easier in nodejs to be synchronous sometimes and asynchronous sometims.

I would refactor the code to something like (still not as simple as synchronous):

    asynchronousCache.get("id:3244", function(err, myThing) {
      var useResult = function(err,_myThing){
          // We now have a thing from DB, do something with result
          // ...
      if (myThing)
         useResult(null, myThing);
         asynchronousDB.query("SELECT * from something WHERE id = 3244",useResult);

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact