Next project in my BEAM series, and this one has my favorite demo so far: a simulation that heals its own wounds. Gray-Scott reaction-diffusion: I've written it before in Swift + Metal, where the GPU updates the whole grid in lockstep. This time the backend is Elixir, and the grid is domain-decomposed across processes: 8 horizontal strips, each strip a supervised GenServer owning its rows. Every step the strips exchange their edge rows through messages. If you've ever written MPI stencil code - it's exactly that, except the "nodes" are actors and the supervisor watches all of them.
A macOS client (Swift + Metal) renders the field over TCP: one byte per cell, straight into an r8Unorm texture, colormap in the fragment shader.
Press K: one strip process gets killed, its part of the pattern vanishes - the supervisor restarts the process, but in a blank state. And then the reaction-diffusion dynamics grow the pattern back into the dead zone from the neighboring strips. Over a few seconds the wound closes and the labyrinth is continuous again.
Honest engineering note: pure-BEAM float math is slow. The hot loop is a hand-rolled 10-list recursion instead of Enum.zip, which bought a 3x speedup (~180 sim steps/s on 128x128). A compute shader would do this five orders of magnitude faster. But throughput was never the point - the coordination was. And along the way I hit the same race as in the Erlang project: a process died between "found it" and "called it". On the BEAM that's not a bug to eliminate, it's a case to handle. That lesson keeps repeating.
Erlang boids in the terminal, then Erlang + Metal, now Elixir + Metal. Same scene in every act: kill a process, watch the system not care.
