4 ms·
I talk about FLAME outside elixir in one one of the sections in the blog. The tldr; is it's a generally applicable pattern for languages with a reasonable concu
by chrismccord 3y ago
I talk about FLAME outside elixir in one one of the sections in the blog. The tldr; is it's a generally applicable pattern for languages with a reasonable concurrency model. You likely won't get all the ergonomics that we get for free like functions with captured variable serialization, but you can probably get 90% of the way there in something like js, where you can move your modular execution to a new file rather than wrapping it in a closure. Someone implementing a flame library will also need to write the pooling, monitoring, and remote communication bits. We get a lot for free in Elixir on the distributed messaging and monitoring side. The process placement stuff is also really only applicable to Elixir. Hope that helps!
- jrmiii 3y ago> functions with captured variable serialization Can't wait for the deep dive on how that works
- azurelake 3y agoProbably not too much to say that’s specific to FLAME. Closures are serializable and can be sent as messages to actors on the BEAM with a few caveats. From a quick look at the code, this looks the magic line: https://github.com/phoenixframework/flame/blob/main/lib/flame/runner.ex#L407-L408 https://github.com/phoenixframework/flame/blob/main/lib/flam...
- quaunaut 3y agoThat's just standard erlang/elixir- because all values are immutable, when a new anonymous function is defined it copies the current value of the external variables into it. You can do it right now even without Flame, just by opening two Elixir nodes, then it's as simple as ```elixir iex(first_node@localhost)> name = "Santa" iex(first_node@localhost)> Node.spawn_link(:other_node@localhost, fn -> IO.puts "Hello #{name}" end) Hello Santa #PID<1337.42.0> ``` Note that while the string interpolation and `IO.puts` was run on `other_node@localhost`, it still did stdout from the first node- this is because it was the one that called `Node.spawn_link`, making it the 'group leader'. Outside of which stdout it went to, all the work was done in the other node.
- crabmusket 3y agoJS kind of has inter process built in with Web Workers and the channel messaging API- I wonder whether it'd be possible to essentially create a "FLAME Worker" with the same API as a web worker but backed by distributed execution!