Strategy 1: Native Implemented Functions (NIFs)

Native implemented functions, or NIFs, allow developers to load external code into the same memory address space as the Erlang VM. Your code can integrate quite closely with functions implemented in other languages. While such tight integration may seem appealing because of the obvious performance benefits, you need to be careful. This power comes at a price. If you’ve ever had a bad experience with a roommate, you know exactly what we mean. NIFs may be clean, but they do not necessarily share the same founding principles we do in ElixirLand. We must think of NIFs as unsafe. In particular:

  • A crash in a native function will crash the whole VM, not just one process.

  • A native function can cause internal ...

Get Adopting Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.