News for hackers. Stuff that matters.
Re:Evolution of the Heroku CLI: 2008-2017 by Rapzid on Sunday September 03, 2017 @02:23AM (#15159982)
I predict they will come to the conclusion that they backed the wrong horse with Flow over TypeScript; v7 will be written in Scala or Scala.js .

There is the odd sense of randomness to the choices in all these CLI upgrades. Can't quite put my finger on it. It brings to mind the saga of Wasabi.

Re:Evolution of the Heroku CLI: 2008-2017 by z3t4 on Sunday September 03, 2017 @03:52AM (#15160201)
I think the idea with Flow is you just have JSDoc type annotations, so you get strong typing without transpiration.
Re:Evolution of the Heroku CLI: 2008-2017 by frou_dh on Sunday September 03, 2017 @05:52AM (#15160571)
There is a comment convention where you can add Flow type annotations and definitions to vanilla JS:

    x /*: T*/
    
    /*::
    type T = {
      ...
    }
    */
But in practice I don't think it's pushed as being preferable to the invasive syntax.
Re:Evolution of the Heroku CLI: 2008-2017 by styfle on Sunday September 03, 2017 @09:42AM (#15161368)
I believe TypeScript has the JSDoc feature as well, although it's much more recent.
Re:Evolution of the Heroku CLI: 2008-2017 by styfle on Thursday September 07, 2017 @10:21PM (#15197445)
Re:Evolution of the Heroku CLI: 2008-2017 by petepete on Sunday September 03, 2017 @05:20AM (#15160467)
Instead of using Promise.all, wouldn't an approach like this work?

    const a = taskA();
    const b = taskB();
    const c = taskC();

    const result = [await a, await b, await c];
Re:Evolution of the Heroku CLI: 2008-2017 by itwy on Sunday September 03, 2017 @11:42AM (#15161999)
These are not the same. Promise.all guarantees a is executed then b then c.

Your version guarantees the three are executed before moving forward. The order may differ on each run.

Re:Evolution of the Heroku CLI: 2008-2017 by exogen on Sunday September 03, 2017 @02:04PM (#15162843)
FYI, Promise.all does not guarantee that. It doesn't orchestrate actually running the Promises at all (this is impossible the way Promises work), just that they're all resolved at the end, with results in the same order they were passed in.
Re:Evolution of the Heroku CLI: 2008-2017 by itwy on Sunday September 03, 2017 @02:42PM (#15163063)
What is the difference then?
Re:Evolution of the Heroku CLI: 2008-2017 by hdhzy on Sunday September 03, 2017 @03:37PM (#15163394)
None from the perspective of the consumer.

The implementation of Promise.all could use one array for results and fill it in any order as soon as any promise resolves while awaits will always proceed in strict order (like a generator). But that's an implementation detail that a JS programmer doesn't need to think about.

Re:Evolution of the Heroku CLI: 2008-2017 by itwy on Sunday September 03, 2017 @04:14PM (#15163603)
Thanks for the clarification.
Re:Evolution of the Heroku CLI: 2008-2017 by cropsieboss on Sunday September 03, 2017 @05:22AM (#15160472)
I believe `await` is sequential in the scope. `Promise.all` would be truly parallel.

edit: just checked and your version is indeed parallel. Interesting.

Re:Evolution of the Heroku CLI: 2008-2017 by dvlsg on Sunday September 03, 2017 @05:37AM (#15160521)
Yup - all promises are "started" before you await them.

I still typically prefer Promise.all though. It's a bit more obvious what's going on (IMO) and you can skip the additional lines for assigning the promises to variables.

Re:Evolution of the Heroku CLI: 2008-2017 by styfle on Sunday September 03, 2017 @09:41AM (#15161364)
Very cool, I never thought about doing it this way!
Re:Evolution of the Heroku CLI: 2008-2017 by z3t4 on Sunday September 03, 2017 @03:40AM (#15160162)
Instead of awaiting IO in CLI tools I just use the sync version