Earlier quoted context omitted.
I share your concerns about the usefulness and implementation of this concurrency strategy. In my opinion, concurrency isn't necessary for JS. If web developers want high-performance, concurrent computing, they should push for adding concurrency to WASM. I doubt concurrency could hurt JS, but I just don't see any reason for it that concurrent WASM doesn't fulfill.
And what about server developers using Node.js?
Concurrent JavaScript: It can work
41–50 of 189 posts
Re: Concurrent JavaScript: It can work
#42JS already has a proper concurrency model which is the event loop. What it doesn't have is a model for parallelism. It's important to understand the difference! It can be hard to grasp at first, because few people make the proper distinction. If you're new to the subject, don't take my word on it, but watch the talk "Concurrency is not parallelism" by Rob Pike[0]. It's highly recommended. Learning a language that mak…
Re: Concurrent JavaScript: It can work
#43JS already has a proper concurrency model which is the event loop. What it doesn't have is a model for parallelism. It's important to understand the difference! It can be hard to grasp at first, because few people make the proper distinction. If you're new to the subject, don't take my word on it, but watch the talk "Concurrency is not parallelism" by Rob Pike[0]. It's highly recommended. Learning a language that mak…
Even loop is not concurrency. Just because concurrency and parallelism are different does not meant that concurrency and event loops are the same.
Re: Concurrent JavaScript: It can work
#44Earlier quoted context omitted.
Event loops are great for handling work that can be handed off occasionally to worker threads (like how Node works with libuv), but are awful when doing consistent CPU-bound work, such as with games, 2D/3D visualizations, finance, and the like. SharedArrayBuffer is a nice primitive that allows multiple Threads (or WebWorkers) to work on data in parallel. The additional primitives they're proposing offer quite a bit o…
I think that kind of stuff it much more relevant in the land of WebAssembly. It certainly makes sense there, but in normal JS, I doubt the usefulness.
Re: Concurrent JavaScript: It can work
#45Earlier quoted context omitted.
You can build concurrency on the event-loop, though, which is what the OP was probably referring to.
Not quite. Consider a component in your code that does this: for (let blah of things) foo(blah); In an event loop, if things has a lot of stuff in it, this can block the event loop. Other things in the event loop won't be able to run until this completes. With threads, this just works.
Concurrency: two functions can run one after the other while they are non blocking for the callers (e.g. hyperthreading).
Parallelism: two functions can run at the same time (e.g. multiple processors).
Re: Concurrent JavaScript: It can work
#46JS already has a proper concurrency model which is the event loop. What it doesn't have is a model for parallelism. It's important to understand the difference! It can be hard to grasp at first, because few people make the proper distinction. If you're new to the subject, don't take my word on it, but watch the talk "Concurrency is not parallelism" by Rob Pike[0]. It's highly recommended. Learning a language that mak…
The event loop doesn't allow you to do a computation concurrently with handling user events, so it's not at all a proper concurrency model.
Concurrency has (at least) two components: design concurrency, execution concurrency. The event loop mechanism in JavaScript allows you to do effective concurrent design. It does not provide for concurrent execution. This is the primary distinction in academic CS between concurrency and parallelism.
Re: Concurrent JavaScript: It can work
#47Re: Concurrent JavaScript: It can work
#48Earlier quoted context omitted.
And what about server developers using Node.js?
Is there any limitation or reason for not implementing WASM on nodejs?
When people say "JS shouldn't support feature X", when feature X is supported in every other serious language, I can't help but guess that their real problem is with JS itself, and they just don't think people should be using it at all. Fine, if that's their opinion, but they should come right out and say it.
Re: Concurrent JavaScript: It can work
#49JS already has a proper concurrency model which is the event loop. What it doesn't have is a model for parallelism. It's important to understand the difference! It can be hard to grasp at first, because few people make the proper distinction. If you're new to the subject, don't take my word on it, but watch the talk "Concurrency is not parallelism" by Rob Pike[0]. It's highly recommended. Learning a language that mak…
The event loop doesn't allow you to do a computation concurrently with handling user events, so it's not at all a proper concurrency model.
What you describe is parallelism.
Re: Concurrent JavaScript: It can work
#50Earlier quoted context omitted.
Not quite. Consider a component in your code that does this: for (let blah of things) foo(blah); In an event loop, if things has a lot of stuff in it, this can block the event loop. Other things in the event loop won't be able to run until this completes. With threads, this just works.
That is parallelism, not concurrency. Concurrency: two functions can run one after the other while they are non blocking for the callers (e.g. hyperthreading). Parallelism: two functions can run at the same time (e.g. multiple processors).
The term "concurrency" subsumes both event loop style concurrency and two-cores-running-code-at-the-same time concurrency.