Erlang / Erlang Basics Interview questions
Why doesn't Erlang have mutable variables?
Erlang was designed around concurrent, isolated processes from day one, and mutable shared variables are exactly what makes concurrent programming dangerous in most other languages — race conditions, torn reads, and the need for locks all stem from two threads touching the same mutable cell.
By making every binding permanent once set, Erlang removes that entire hazard class at the language level: there's no mutable cell for two processes to race over, so there's nothing to protect with a mutex. It also makes reasoning about a function's behavior simpler, since a variable's value can't have silently changed between two lines that reference it.
The design does shift work elsewhere: "updating" a value means creating a new binding (often via recursion carrying an accumulator, or storing the "current" version in ETS/process state), rather than assigning in place. That's a deliberate trade of some ergonomic convenience for much simpler concurrent reasoning.
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...
