<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 4/5/2013 4:19 AM, Mike de Boer
      wrote:<br>
    </div>
    <blockquote
      cite="mid:94D0AD58-999C-4FF5-A2C2-8AA7496E472C@mozilla.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <div>In the case of JS, Iterators/ generators, first-class lambdas
        and arrow syntax (and more) all will greatly reduce the amount
        of code required for asynchronous flows. A simple convention to
        reserve the first argument to a callback for errors has the
        positive side-effect that errors are never discarded or
        'forgotten' and always bubble up to the callee.</div>
      <div><br>
      </div>
      <div>If it matters, my background is that of working on
        enterprise-scale NodeJS backends for over two years at Cloud9
        IDE and in-browser JS for over eight years. For some reason,
        Promise libraries never caught on in the NodeJS ecosystem, I
        hope you now understand why.</div>
      <br>
    </blockquote>
    <br>
    As I've said many times, I don't believe promises by themselves
    provide a *compelling* advantage over standard callbacks. About the
    only benefit they provide to consumers is the ability to chain a
    single error handler to a series of async function calls without
    "buy-in" from all the intermediate APIs. In my mind, the real
    benefit to promises is Task.jsm. e.g.
<a class="moz-txt-link-freetext" href="https://hg.mozilla.org/mozilla-central/file/55f9e3e3dae7/services/metrics/storage.jsm#l652">https://hg.mozilla.org/mozilla-central/file/55f9e3e3dae7/services/metrics/storage.jsm#l652</a>.
    If Task.jsm didn't exist, I likely wouldn't be using promises to the
    same liberal extent I now am.<br>
    <br>
    If others have the same opinion, then it's quite possible that
    promises never caught on in Node because V8 does not have the
    language support for generators required to support tasks! Only
    recently did they signal they are working on implementing generators
    (<a class="moz-txt-link-freetext" href="https://code.google.com/p/v8/issues/detail?id=2355">https://code.google.com/p/v8/issues/detail?id=2355</a>).<br>
    <br>
    Both a benefit and pitfall of working on JS inside Firefox is we
    often have access to JS language features before the broader JS
    developer community (because SpiderMonkey is often the first
    implementation of new language features). As such, I expect us to be
    at the forefront  of discovering new and exciting practices now
    possible with new language features. Tasks (via promises) are one
    such feature. I think we should capitalize on this opportunity
    (while exercising prudence over the use of bleeding-edge features,
    of course).<br>
  </body>
</html>