Libraries 2026
C3NIF
Erlang and Elixir NIFs written in C3, without the boilerplate.
C3NIF is a library for writing Erlang and Elixir Native Implemented Functions in C3. It keeps the performance of a native NIF and removes most of the ceremony: wrapper types, helpers for terms and environments, and C3’s optional types (int?) so error paths are visible in the signature instead of hidden in a return code.
Why C3
If you know C, you can read C3, and the NIF compiles to native code the same way. C3 adds safer defaults around the edges — slices, optionals, explicit casts — without Rust’s borrow checker or its guarantees. The trade is stated plainly: less boilerplate and no memory safety net; the NIF is still native code and still has to be correct.
The shape of a NIF
A module declares the C3 source inline with ~n""", imports c3nif, c3nif::erl_nif, and c3nif::env, and exposes functions through the generated NIF table. Arguments arrive as terms; results go back as terms; the helpers handle the conversion that raw NIF code repeats for every function.
Where it is used
C3NIF is how bisha, a movable-tree CRDT written in C3, can run inside the BEAM without a separate C wrapper. The same source compiles into a native library or a NIF, depending on the target.
Status
Published on Hex as c3nif. The library covers the NIF surface an application needs in practice; the README documents the supported erl_nif API.