EMS: Shared Memory Parallelism for Node.js
github.com
github.com
Just remember that there is no big conceptual difference between blocking and locking, which is what you end up doing when having shared mutable state.
Recommending anyone to check out CSP (like in Go & Clojure/script (the latter also with immutable data)) or Actors (like in Erlang, Elixir).
Conceptually, yes, but the incredibly low overhead of CPU atomics compared to message passing (especially on x86) mean that theory and practice are very different.
And the classic KiranDave/Aphyr vs Ryah thread on "NodeJs Concurrency" https://news.ycombinator.com/item?id=4306241
NodeJS works nicely with nonblocking IO, except what most people seem to forget is that the CPU is a resource too, which is still being blocked by NodeJS when handling any event. Multithreading would help alleviate this.
("Structural sharing" is a technique to make immutable data structures more efficient in time and space).
Mutexes though have a special property in that when a thread waits for a mutex to be unlocked, the processor can idle (this is all Intel knowledge).
It seems to me that engineering has become very cargo-cultish. "Lets use node cause we already know javascript" seems to be an argument that people who never learned Java or C/C++/Objective-C or Go or even Python or Ruby would make. Ok, there's a lot of those people... now they are stuck in a monolithic (eg non-distributed) system and dealign with scaling problems.
I'n not saying Erlang is always the right answer (I'm a fan of Go at the moment)... just that there's too much hopping-on-the-bandwagon based on seemingly a lack of awareness of the technology that's out there.
Imagine if all the effort making node work had been put into existing choices.
Some people want to write once, run anywhere. Hence JS and Node.js. ( or a compile-to-js language )