News for hackers. Stuff that matters.
Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by daveidol on Thursday October 01, 2015 @05:53PM (#10315042)
The first time I heard of async/await was actually with Microsoft C#; so I'm not too surprised to see them prioritize this feature in JS land.

...which is cool, because using async/await in C# made me realize how much simpler dealing with async code could be (compared to my experience with JS callbacks or Java threads).

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by apaprocki on Thursday October 01, 2015 @09:47PM (#10316122)
It was the first interaction we (at Bloomberg) had with async/await as well. We really wanted to see it come to JS and as the spec was evolving it was clear that the path to getting there (if TC-39 ultimately agreed async/await was a desired thing) was going to be via generators. That is how we wound up getting involved with Igalia back in Feb 2013. I kicked off a multi-year project with Andy Wingo / Igalia to direct his mighty keyboard at generators and get them landed in v8. We weren't quite sure TC-39 would agree async/await was a good thing in the end, but it seems now all the pieces are finally coming together. It is satisfying to see the endgame within reach right now and I hope it is worth it once it starts to become more widely available! Companies -- help get spec features implemented! We essentially acted as the bank when it came to the generators work. You don't need to land the code yourself to help move the needle. Thank you Igalia for being awesome.
Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by stupidcar on Friday October 02, 2015 @05:47AM (#10317556)
I know you guys at Bloomberg have also sponsored Igalia to work on implementing CSS Grid Layout as well. Most web devs seem to be unaware, but I assure you those of us who are definitely appreciate it!
Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by eco on Thursday October 01, 2015 @10:20PM (#10316272)
Microsoft is also pushing for async/await in C++ in the form of stackless resumable functions complete with an implementation before C++17 has been standardized.

http://blogs.msdn.com/b/vcblog/archive/2014/11/12/resumable-...

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by PopsiclePete on Thursday October 01, 2015 @11:20PM (#10316546)
I'm a little sad the async/await model is winning over. I really prefer Go's CSP. It can do everything the async/await model can, plus "streaming" API's. I dig (sorta) C#'s async/await, but I still don't see why it's "winning" over other, better models...
Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by bklimt on Friday October 02, 2015 @01:05AM (#10316818)
The one advantage of C#'s async/await over Go's CSP is that by exposing the underlying Tasks, you can take more control over how the continuations get executed. The result of this is that it's easy to have async code that all runs on the same thread (usually the UI thread) even while it calls a function makes a network request that gets scheduled to a background thread.

Go's model doesn't give you as much control over which thread a particular operation gets assigned to. It's not theoretically impossible, I suppose, but it's hard to imagine what a simple API for it would look like.

But yes, if this particular problem were solved in an elegant way, I would also prefer the CSP model. It makes it so you don't have to worry about which operations are async or not.

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by novaleaf on Friday October 02, 2015 @09:17AM (#10318277)
A huge problem with C#'s Async feature that I hope gets resolved (and, obviously that this failure pattern is not ported to Javascript): Explicitly blocking during a function that uses async somewhere inside (a sub-function) will cause your application to deadlock. It is extremely surprising that .NET does not handle this (abet novice) design mistake in a graceful way. (For example, checking if a thread is blocked before attempting to schedule tasks to it)
Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by _wmd on Friday October 02, 2015 @02:07AM (#10316971)
This was one of my main worries about Go when I evaluated it back in 2010. Most green threads implementations have an explicit determinism model, and it's typically straightforward to reason about and depend on execution order and suchlike, much as you can with plain asynchronous code, but with Go there didn't appear to be any guarantee when or how your code ran.

In any case I suppose many styles of Go program will exhibit accidental determinism, but it still seems too difficult to depend on as randomness can be introduced simply by invoking the wrong function, or by using a different runtime version, which to me feels comparable to the hazards of raw multithreading.

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by pjmlp on Friday October 02, 2015 @04:02AM (#10317277)
Because the only thing Go did was bake CSP into the language, it is nice, but not a solution for every concurrency problem.

While async/await allows for an abstraction over the lower level tasks, that are still exposed, in case one needs more control over the threading runtime.

For example, in JS's case you can still dig into the Promise world if needed.

Similarly in C#, Tasks / Dataflow and SignalR can also be used.

Whereas in Go, correct me if I am wrong, outside CSP one needs to reach out to threads/mutex/semaphore directly.

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by aikah on Friday October 02, 2015 @04:53AM (#10317397)
> Because the only thing Go did was bake CSP into the language, it is nice, but not a solution for every concurrency problem.

I'm not sure I understand your sentence. Are you saying that communicating sequential process only works because it is first class in Go or that CSP is not a solution to every concurrency problem ?

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by pjmlp on Friday October 02, 2015 @05:15AM (#10317468)
It is not a solution to every concurrency problem.

I tend to use languages that give library writers (almost) the same control as the language itself has.

EDIT: To expand a little more into what I mean. In most languages that offer async/await, that is mostly syntactic sugar (with some compiler help) to the blessed task pool library.

A good way to explore that is to see the parallel libraries available in C++, JVM, .NET, Haskell and OCaml worlds.

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by idibidiart on Thursday October 01, 2015 @11:26PM (#10316563)
CSP can be implemented on top of async/await, which itself is implemented on top of promise and generators.

What does streaming APIs have to do with CSP per se?

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by findjashua on Thursday October 01, 2015 @11:47PM (#10316623)
for consuming 'streaming APIs', why not just use observables (rx.js etc)?
Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by bklimt on Friday October 02, 2015 @01:08AM (#10316825)
Observables are great, and are indeed the stream equivalent to Tasks. But the await/async keyword compilation doesn't support them. I think that's the parent post's point.
Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by josteink on Friday October 02, 2015 @02:37AM (#10317044)
I've seen stream-like constructs done with c# async and await and to me it even looked elegant.

Could you expand on in what way you think async and await is insufficient with regards to streams? I'm genuinely curious.

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by colin_jack on Friday October 02, 2015 @03:25AM (#10317162)
Would you have a link to an example of a streaming API done elegantly with async?

I'm interested to see what it looks like.

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by josteink on Friday October 02, 2015 @03:57AM (#10317262)
It was during a presentation on the NDC developer conference a few years back, when the feature was new to C#. I remember thinking it was one of the best presentations that year, but right now I don't remember what year it was, and I can't find any past agendas to search either.

NDC posts their videos online after each conference, and I did a quick skim. I think it may be this session here, but I haven't double-checked:

https://vimeo.com/43808831

Edit: It was a 2-part session and it may also have been in second half. Link here:

https://vimeo.com/43808833

Re:Microsoft Edge gets native ECMAScript 7 async/await suppo... by colin_jack on Friday October 02, 2015 @04:37AM (#10317360)
Much appreciated ta, will give it a look.