←back to thread

3 points wkyleg | 1 comments | | HN request time: 0.212s | source

Right now, JavaScript scales well with a single-threaded event loop. Certainly not as fast as something like Go for async tasks, but enough to power much of the web and be easy to write.

Why hasn't anyone abstracted the event loop model to scale across multiple machines or utilize modern processors? Perhaps with something more like an Actor model or Erlang's BEAM?

It seems like just getting the JavaScript concurrency model as an abstraction over multicore or multi-machine concurrency would be one of the easiest ways to achieve this. I realize that this is still technically difficult, but programming tends towards "just porting things to JavaScript." I would love to have something like Phoenix framework, just built with JavaScript/TypeScript, and I can scale a back end by bumping size of a machine or scaling horizontally.

1. austin-cheney ◴[] No.42198080[source]
First, let's understand what the event model is. The event model allows for a single process to use multiple call stacks. This is an example of concurrency not parallelism.

Second, when people talk about multiple threads they are typically talking about SMP, or simultaneous multi-processing. JavaScript already does this. It uses WebWorkers in the browser and clusters in Node. Each of those technologies can then coordinate task execution through messaging, such as IPC. Detached-state execution allows for child processes to execute with process independence from the calling process which means killing the calling process will not terminal the child process.

Third, when people talk about multiple machine execution they are typically talking about task distribution, which is not the same as decentralization. Distribution is similar to detached-state SMP but reliant upon network access for task distribution and status.

You can achieve all this with JavaScript right now. I have done it in a personal application built around decentralization and remote file system management.