Native Implemented Functions (NIFs) let you significantly speed up code or make system calls that would otherwise be unavailable. However, they come with a significant cost in that when they go wrong, they can take down the entire Erlang VM. This is particularly challenging when using NIFs with Nerves when crashes happen at boot time.
[Read More]Using NIFs With Nerves
While working on a Nerves project, you will likely do most hard work in the
host
environment. This means you get to develop features quickly, and when
are ready, you simply deploy your known working firmware to your embedded
devices. This however can lead to a situation where the code runs really well
on your i7 powered beast computer, but when deployed on a less
powerful Raspberry Pi 0, for example. Nothing will be broken, but things are just
too slow. There are a number of solutions to this problem and in this post,
I will walk you through a simplified real world example of one possible solution
of using an Erlang NIF to speed
up one particular functionality.