3 ms·
> Node utilizes as much of what's already available from the operating system's kernel as possible. And yet we've seen a proliferation of fibre/coroutine/green
by cluenerf 11y ago
> Node utilizes as much of what's already available from the operating system's kernel as possible.
And yet we've seen a proliferation of fibre/coroutine/green thread libraries for Node which all reinvent the concept of threading poorly.
- quarterto 11y agoNode's event loop is inherently cooperative multitasking. It's not trivial to simulate preemptive multitasking without writing/compiling your code to giant state machines. There are different use cases for the two, especially since any CPU-bound task performed in the event loop will cause stuttering in your app.
- aikah 11y agoIn a node process you can't run 2 things at the same time without forking an external process. That's why these libraries exist. A complex synchronous computation will block the only thread available in nodejs. Sure you can spawn workers, but your node workers will have the exact same issue. > all reinvent the concept of threading poorly because "user scripts" in node have no concept of threading to begin with. There is no concurrency in a node process, only non blocking I/O.