Bridging Elixir and Go Backends with a Crystal Wrapper
2025-06-19

The Mozi team needed to connect a new Elixir Phoenix LiveView app to an existing Go backend. They explored NIFs and Ports, but ultimately chose Erlang's C Node approach, using Crystal to write a C wrapper for improved maintainability. This decouples the codebases at compile and runtime, leveraging `Node.list` in Elixir to detect C node connectivity and S6 for in-container restarts. While there's a performance penalty crossing the C/Go boundary, it's acceptable for their use case. The result is a slick three-language (Elixir, Crystal, Go) mashup that enhances maintainability.
Development