2 ms·
> For one, if your C code crashes, it's not the calling Erlang process that crashes, but the entire VM [1]. NIF's are one of several ways of linking C and Erla
by davidw 11y ago
> For one, if your C code crashes, it's not the calling Erlang process that crashes, but the entire VM [1].
NIF's are one of several ways of linking C and Erlang, and the one most similar to how Tcl/Python/Ruby/etc... link in C code. In those runtimes, if your C code segfaults, you will also crash the interpreter. You're correct that they're a bit trickier to integrate because you have to consider the scheduler, whereas Tcl/Python/Ruby don't care if you call out into the C code and it takes a minute to complete.
Erlang offers you other means of working with C code, like ports, and C nodes, which can comunicate at a distance, and run in separate Unix processes. This is a compromise in that comunication is more expensive, but the system as a whole is more robust.