[erlang-questions] Proper way to run C code without crashing the VM
Roger Lipscombe
roger@REDACTED
Wed Aug 16 17:05:41 CEST 2017
On 16 August 2017 at 14:53, code wiget <codewiget95@REDACTED> wrote:
> I have been reading about NIF’s here:
> http://erlang.org/doc/tutorial/nif.html but it seems like they are
> incredibly unsafe: “it is also the least safe, because a crash in a NIF
> brings the emulator down too”.
They're not "incredibly unsafe". There's nothing inherently unstable
about a NIF. It's precisely as stable (or unstable) as the underlying
implementation. It's just that it's running inside the BEAM, which
means that *if* it crashes, it's going to crash the whole Erlang node.
So: if you think you can write reliable C, go for it. If not, then you
need to look at other options. See Dmytro's email. He skipped "C Node"
as an option, incidentally. Another option is to host the NIF in
another Erlang node, and use Erlang distribution to talk to it.
More information about the erlang-questions
mailing list