Hacker News new | ask | show | jobs
by zoips 5144 days ago
In the short term:

https://github.com/laverdet/node-fibers

In the long term:

http://wiki.ecmascript.org/doku.php?id=harmony:generators

2 comments

No, and no, respectively. Hacked together libraries to sort of support rewrite it at the wrong level of the stack (the compiler should be doing the continuation transform, anything else will lack performance due to having to jump through a lot more hoops) and merely having generators is not the same thing. And neither solution you propose will give you true preemptive multitasking. Do you know how you fire off a long computation in Go or Erlang? You just do it. No marshalling, no blocking, no dealing with OS processes, no fuss.

Neither of those two things are new ideas. Python has had generators forever. If it solved the underlying problems, Go would never have been written.

Both look useful, but aren't exactly well-supported by the library ecosystem. In Go, faux-blocking I/O is standard, and all the libraries support it; it's not something bolted on as a handy afterthought.