News for hackers. Stuff that matters.
Re:Node v8.1.2 by maxxxxx on Thursday June 15, 2017 @10:23AM (#14560641)
Agreed. Async is like a virus. Once you start somewhere pretty much everything else must be async too. In C# you can call async code from not async code and then call Task.Wait. Not sure if JS can do that.

But it still beats promises or callback hell.....

Re:Node v8.1.2 by WorldMaker on Thursday June 15, 2017 @11:06AM (#14561059)
A better term than virus is that async is a monad. Welcome to programming with monads. ;)

JS async produces Promises like C# produces Task, so you can call an async function and use the result as a Promise.

Re:Node v8.1.2 by maxxxxx on Thursday June 15, 2017 @11:28AM (#14561282)
Can you wait for a promise synchronously? I am pretty new to JS so please forgive if this is a stupid question.
Re:Node v8.1.2 by WorldMaker on Thursday June 15, 2017 @11:43AM (#14561434)
It's not something JS engines allow today. It's also not something that entirely makes sense from the perspective of a browser threading model or even the libuv-based NodeJS threading model.
Re:Node v8.1.2 by maxxxxx on Thursday June 15, 2017 @01:06PM (#14562207)
I know. We have some wacky use cases where it would make sense. The real answer would probably be to say "Don't use Node for this" but that's a different discussion above my pay grade.
Re:Node v8.1.2 by WorldMaker on Thursday June 15, 2017 @03:06PM (#14563437)
The real answer is probably "those places you think need to synchronous don't need to be synchronous" and you need a refactor or a rearchitecture.
Re:Node v8.1.2 by maxxxxx on Thursday June 15, 2017 @04:24PM (#14564049)
Trust me. We are not totally stupid. We need synchronous actions under some circumstances.
Re:Node v8.1.2 by pier25 on Thursday June 15, 2017 @11:40AM (#14561395)
> But it still beats promises or callback hell.....

And then() hell ...

Re:Node v8.1.2 by b34r on Thursday June 15, 2017 @10:47AM (#14560878)
You can't really transition between async and sync scopes, no.