Erlang / Erlang Basics Interview questions
What is a NIF (Native Implemented Function)?
A NIF is a function implemented in C (or another native language) and loaded directly into the BEAM, callable from Erlang exactly like an ordinary function. It's used when pure Erlang is too slow for a specific hot path, such as heavy numeric or cryptographic work.
-module(math_nif). -export([fast_add/2]). -on_load(init/0). init() -> erlang:load_nif("./math_nif", 0). fast_add(_A, _B) -> erlang:nif_error(not_loaded).
The catch: a NIF runs inside the scheduler thread, not as a separate lightweight process, so a slow or crashing NIF can stall that scheduler or even bring down the entire node — it doesn't get the isolation a regular Erlang process gets. Because of that risk, NIFs are meant for short, fast operations, with long-running native work usually handed off to a port or a dirty scheduler instead.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
