3 ms·
What do you mean by "no callbacks"?
by lachenmayer 14y ago
What do you mean by "no callbacks"?
- cageface 14y agoYou can do non-blocking I/O without the nested callbacks you have to use for everything in Node. You just fire off a block to a goroutine and then code sequentially there.
- zoips 14y agoIn the short term: https://github.com/laverdet/node-fibers https://github.com/laverdet/node-fibers In the long term: http://wiki.ecmascript.org/doku.php?id=harmony:generators http://wiki.ecmascript.org/doku.php?id=harmony:generators
- pjscott 14y agoBoth 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.
- jerf 14y agoNo, 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.