|
|
|
|
|
by sasa555
3435 days ago
|
|
Precisely, which is why I always advise to consider ports first :-) However, in some situations the overhead of communicating with a port might be too large, so then you have two options: 1. Move more code to another language which you run as a port.
2. Use a NIF
It's hard to generalize, but I'd likely consider option 1 first.If you go for a NIF, you can try to keep its code as simple as possible which should reduce the chances of crashing. You can also consider extracting out the minimum BEAM part which uses the NIF into a separate BEAM node which runs on the same machine. That will reduce the failure surface if the NIF crashes. I've also seen people implementing NIFs in Rust for better safety, so that's another option to consider. So there are a lot of options, but as I said, NIF would usually be my last choice precisely for the reason you mention :-) |
|