Erlang / Erlang Advanced Interview questions
What is the difference between a behavior callback module and a plain library module?
A plain library module (like lists or string) exposes stateless functions you
call directly whenever you want — there's no framework driving it, no lifecycle, no expected shape beyond
whatever arguments and return value each function defines on its own.
A behavior callback module instead plugs into a generic, already-running process skeleton (gen_server,
gen_statem, a custom behavior, etc.) that calls your functions at specific points in its own lifecycle
— you don't call init/1 yourself, the behavior's generic engine does, at the moment it
starts a new process. The contract (which functions must exist, with what signatures) is enforced by the
-behaviour/-callback mechanism rather than being purely a documentation convention.
| Plain library module | Behavior callback module |
| You call its functions directly, whenever you choose. | A generic engine calls your functions at defined lifecycle points. |
| No enforced contract beyond documentation. | Enforced by -callback declarations, checked by the compiler/Dialyzer. |
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...
