3 ms·
I think that even with generators, you don't quite get Go style concurrency due to lack of concurrency for non-IO bound tasks. For a real world use case, suppos
by slaymaker1907 9y ago
I think that even with generators, you don't quite get Go style concurrency due to lack of concurrency for non-IO bound tasks. For a real world use case, suppose you are compiling TypeScript. Without web workers or running in a separate process, the compilation will block because it is CPU bound. You can get around this with generators by explicitly putting in pause points through yielding, but that is assuming that one can break up the task and that it doesn't depend on some external blocking library.
- mayank 9y agoYou may possibly be conflating concurrency and parallelism. JS has concurrency due to its event-based programming model, but not parallelism due to its single-threaded nature. The TypeScript compilation you mention likely has many concurrently running tasks, just not in parallel (modulo the I/O thread pool as you mention).