Hacker News new | ask | show | jobs
by gioazzi 599 days ago
And then there are port drivers which are the worst of both worlds! Can crash the BEAM and need much more ceremony than NIF to set up but they’re pretty nice to do in Zig[1] as well

[1]: https://github.com/borgoat/er_zig_driver

1 comments

That's true. Haha!

There's another option and that's setting up an Erlang node in the other language. The Erlang term format is relatively straightforward. But I'm honestly not sure of the benefit of a node versus just using a port.

Node:

- can "easily" send beam terms back and forth

- if you want it to be os-supervised separately (systemd, kubernetes, e.g.)

- pain in the ass

Port:

- easy

- usually the only choice if you're not the software author

- really only communicates via stdio bytestreams

- risk of zombies if... Iirc the stdout is not closed properly?

- kind of crazy how it works, Erlang VM spawns a separate process as a middleman

The Erlang term format is straightforward, but if you want to set up another node in another language you need to correctly implement/emulate process linking, binaries, and some other stuff too, it's not just a matter of writing a socket to accept and emit Erlang terms.

It's not impossibly large but it's not something one does on a lark either; if there isn't support in your language already it's hard to justify this over any of the many, many message busses supported by both Erlang and other languages that don't have so many requirements.