←back to thread

3 points wkyleg | 2 comments | | HN request time: 0.483s | 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.

Show context
idontwantthis ◴[] No.42177030[source]
I think if you want that, JavaScript isn’t the right tool. The single threaded simplicity is a big part of why it is a useful tool. You can always spin up external processes from within your app, or use a load balancer or queue to share work with multiple identical processes.

The idea of just horizontally scaling up a node process wouldn’t make a lot of sense. How would you share scope between the different processes for example? You would need a whole new construct, at which point you’re really throwing away the advantages you had and you should probably be using a different language.

replies(1): >>42177210 #
wkyleg ◴[] No.42177210[source]
Agreed, I realize it would need to be effectively another language, or at least a very different implementation.

This isn't to far off from what new projects like Deno and Bun are doing though, apart from also needing to spread the event loop implementation horizontally

replies(1): >>42177254 #
idontwantthis ◴[] No.42177254[source]
Can you point me to what you’re talking about in Deno? That’s really interesting.
replies(1): >>42177322 #
1. wkyleg ◴[] No.42177322[source]
Deno doesn't implements this differently, it's just an alternative server side run time. It has some better defaults compared to node though
replies(1): >>42177377 #
2. idontwantthis ◴[] No.42177377[source]
Oh I thought you meant they were working on horizontal scaling. I think this is very far off from what they are doing. It’s still Javascript, and you can take for granted that it follows the Ecmascript spec even if its runtime is different.