elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.51k stars 656 forks source link

Run Elm application inside webworker #1203

Closed masklinn closed 8 years ago

masklinn commented 8 years ago

I'm not quite sure where to put long-term/architectural suggestions, elm-lang/elm-plans seems to be winding down, so here it is, I can put it somewhere else if that's the wrong place.

The usage of webworkers in http://www.pocketjavascript.com/blog/2015/11/23/introducing-pokedex-org (aside from the serviceworker thing) looks like it could be used very naturally and nearly seamlessly in Elm applications with the application itself running in a worker and ports' "native" endpoint being on the other side of postMessage, increasing the isolation between elm applications and the native environment and improving performances, not to mention the long-term possibilities of shared workers and service workers.

Are there any plans on that front already?

evancz commented 8 years ago

I have thought about this a lot. There are a bunch of problems with web workers that make it worse than it sounds at first:

So it does not give us a great concurrency model, and even if we start to make sacrifices, we can't even communicate all Elm values (anything with functions). So I don't have any plans for the compiler connected to this, but I do think you could get Elm running on separate workers totally independently. I am sure there are scenarios where that makes sense, and I don't think it's blocked on any compiler or core tools stuff.