Reputation: 88367
Recently in school, I've been taught C++/OpenMPI in a parallel computing class. I don't really like to program in C++ as its low level and harder to program, easier to make mistakes etc.
So I've been thinking, is JavaScript/NodeJS (something I've started to like) actually truly parallel? Or is it simply using non-blocking operations to simulate parallel execution (which I think it is)? There are libraries like async
which gives similar functions to what I've used in OpenMPI: gather, scatter even "parallel". But I've got a feeling its just simulating parallelism using non-blocking IO?
Perhaps only node-webcl
is truly parallel?
UPDATE: Seems possible via web workers (~31 min): watching http://www.infoq.com/presentations/Parallel-Programming-with-Nodejs
Upvotes: 1
Views: 869
Reputation: 633
In deed, JavaScript is single-threaded by it's design. But you're not the first person who wants some parallelism in it, so there're some things that can work truly parallel:
That's pretty much it. There's also the WebAssembly threads proposal, but, firstly, it is a proposal and, secondly, WebAssembly is not JavaScript.
In general, JavaScript is by far not the best tool for low level parallel computing. There're a lot of other tools that suit better for this: Java, C#, Go...
Upvotes: 1
Reputation: 159145
With Node.js, your JavaScript runs in a single thread. IO is non blocking.
Upvotes: 0