Erlang is a powerful functional programming language designed for building scalable, fault-tolerant, distributed systems. Originally developed by Ericsson for telecommunications applications, Erlang now powers critical systems at WhatsApp, RabbitMQ, and Discord.
If you’re preparing for an Erlang developer interview, this comprehensive guide covers 50+ essential Erlang interview questions ranging from basic syntax to advanced OTP concepts. Let’s dive in!
Basic Erlang Interview Questions
1. What is Erlang and what are its key features?
Erlang is a concurrent, functional programming language known for:
- Lightweight process model
- Fault tolerance through supervision trees
- Hot code swapping
- Distributed computing capabilities
- Built-in support for concurrency
2. Explain Erlang’s “Let It Crash” philosophy
Unlike traditional error handling, Erlang follows:
- Processes should crash when errors occur
- Supervisors restart failed processes
- Leads to more reliable systems through isolation
3. How do you start the Erlang shell?
erlang
$ erl Erlang/OTP 25 [erts-13.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] Eshell V13.0 (abort with ^G) 1>
4. What are atoms in Erlang?
Atoms are literal constants where their name is their value:
erlang
hello. 'Hello World'.
5. How do you define a function in Erlang?
erlang
-module(math). -export([add/2]). add(X, Y) -> X + Y.
6. Explain pattern matching in Erlang
Erlang uses pattern matching for:
- Variable assignment:
X = 10.
- Function clause selection
- Message processing
erlang
case {X, Y} of {1, 2} -> one_two; {2, 1} -> two_one end.
Intermediate Erlang Interview Questions
7. What are Erlang processes?
Lightweight units of execution:
- Isolated memory spaces
- Communicate via message passing
- Extremely lightweight (~300 bytes)
8. How do you spawn a process?
erlang
Pid = spawn(fun() -> do_something() end).
9. Explain message passing in Erlang
erlang
% Sending Pid ! {self(), hello}. % Receiving receive {From, Message} -> io:format("Got ~p from ~p~n", [Message, From]); Other -> io:format("Unexpected: ~p~n", [Other]) after 5000 -> timeout end.
10. What is an Erlang supervisor?
Supervisors:
- Monitor worker processes
- Implement restart strategies
- Maintain system reliability
11. Explain OTP behaviors
Common patterns implemented as behaviors:
- gen_server – Client/server
- gen_fsm – Finite state machine
- gen_event – Event handler
- supervisor – Process supervision
Advanced Erlang Interview Questions
12. What is hot code swapping?
Ability to update code without stopping the system:
erlang
c(math, [{outdir, "./ebin"}]). code:load_file(math).
13. How does Erlang handle distributed computing?
Key features:
- Transparent process communication across nodes
spawn(Node, Fun)
to create remote processes- Built-in distribution protocols
14. What is ETS and DETS?
- ETS (Erlang Term Storage): In-memory tables
- DETS: Disk-based ETS alternative
15. Explain Mnesia database
Distributed, soft real-time database:
- Can store Erlang terms directly
- Supports transactions
- Multiple storage backends
16. What are binary comprehensions?
Efficient binary processing:
erlang
<< <<X:8>> || <<X:8>> <= <<1,2,3,4>>, X rem 2 == 0 >>. % Returns <<2,4>>
People Also Ask (FAQs)
Q1. Is Erlang still relevant in 2024?
Absolutely! Erlang powers:
- WhatsApp (billions of messages daily)
- RabbitMQ (popular message broker)
- Financial trading systems
- Telecom infrastructure
Q2. How difficult is Erlang to learn?
For developers new to functional programming, Erlang has a learning curve due to:
- Functional paradigm
- Actor model concurrency
- OTP framework concepts
Q3. What companies use Erlang?
Major users include:
- WhatsApp (Meta)
- Ericsson
- Goldman Sachs
- RabbitMQ
- Heroku
Q4. How does Erlang compare to Elixir?
- Erlang: Original language, mature ecosystem
- Elixir: Modern syntax, runs on BEAM, compatible with Erlang
Q5. What makes Erlang good for distributed systems?
Key advantages:
- Lightweight processes
- Built-in distribution
- Fault tolerance
- Soft real-time capabilities
Conclusion
Mastering these Erlang interview questions will prepare you for technical interviews at companies building high-availability, distributed systems. Focus on understanding:
- Core Erlang syntax and functional concepts
- Concurrency model and process communication
- OTP framework and supervision trees
- Distributed computing capabilities
🚀 Pro Tip: Build a small project using gen_server and supervisor behaviors to demonstrate practical OTP knowledge.