Improving Performance with NIFs

Learn about NIFS and how it can be implemented and integrated into our defined framework.

What are NIFS?

Native Implemented Functions (NIFs) are a great way to inject speed into our Elixir/Erlang programs. NIFs are programs implemented in compiled languages like Rust or C/C++ that are then linked and loaded into our Elixir module at runtime.

NIFs were designed to be a simpler and more efficient way of interfacing with native code than ports. Ports interact with external programs and offer a mechanism for implementing program features in a different language.

NIFs are often used in places where Elixir/Erlang alone isn’t enough to efficiently get the job done. For example, the Matrex library uses NIFs to perform fast matrix operations because Elixir/Erlang isn’t optimized to perform these operations alone.

Get hands-on with 1200+ tech skills courses.