News for hackers. Stuff that matters.
Re:JavaScript async/await implemented in V8 by foota on Monday May 16, 2016 @09:33PM (#11710814)
Is using async/await through babel a good idea? When I last looked at it I thought it was using a busy loop which didn't seem like such a great idea to use in shipping code.
Re:JavaScript async/await implemented in V8 by nostrademons on Monday May 16, 2016 @09:56PM (#11710890)
It's okay but clumsy. It's a state machine, not a busy loop, but the compiled code is a lot more verbose than the input code (and so you pay a latency penalty on the client). The developer experience is also sub-par: you'll get regenerator stack frames in any of your stack traces, and it interacts poorly with babel-watch.

You can do it, it's not insane, but native async/await will be much, much nicer.

Re:JavaScript async/await implemented in V8 by tlrobinson on Tuesday May 17, 2016 @12:57AM (#11711428)
Can you elaborate on "it interacts poorly with babel-watch."?
Re:JavaScript async/await implemented in V8 by nostrademons on Tuesday May 17, 2016 @12:51PM (#11715138)
IIRC under babel-watch it required me to include babel-polyfill at the top of my main script, but under babel-node it prevented me from including babel-polyfill at the top of my main script. (babel-polyfill has a check so that it can only be required once, and errors out otherwise.) That meant I needed to keep commenting/uncommenting that line when I wanted to debug things.

There were also cases where I wasn't sure if babel-watch was reloading dependencies properly if I used async code in a file, which is why I had to keep switching to babel-node or running the code through babel and inspecting the generated code to debug. Overall, it just felt very new and unpolished (which I guess it was...I was working with it around March, so babel-watch was < 1 month old and babel async/await was about 2-3 months at the time) to be relying on all the time.

Re:JavaScript async/await implemented in V8 by hzoo on Monday May 16, 2016 @10:38PM (#11711056)
If you don't want to use regenerator and your environment supports generators already you can use the async-to-generator transform https://gist.github.com/rauchg/8199de60db48026a6670620a1c33b...
Re:JavaScript async/await implemented in V8 by tlrobinson on Monday May 16, 2016 @09:39PM (#11710841)
It's fine. It transforms async functions into a state machine.
Re:JavaScript async/await implemented in V8 by AgentME on Monday May 16, 2016 @10:38PM (#11711061)
Async/await is just syntax-sugar around Promises. No busy loops involved. (Those generally don't work in Javascript anyway.)
Re:JavaScript async/await implemented in V8 by BinaryIdiot on Tuesday May 17, 2016 @12:31AM (#11711354)
This overlooks Promises needing to be polyfilled. Though that's certainly not using busy loops either (though most of what I've seen overlooks more performant setTimeout(fn, 0) alternatives which is unfortunate).
Re:JavaScript async/await implemented in V8 by AgentME on Tuesday May 17, 2016 @05:35PM (#11717670)
Async/await already needs to be transpiled in for most browsers, so Promises needing to be polyfilled seems like the least of your problems.