Erlang / Erlang Basics Interview questions
How do you spawn a process in Erlang?
The base function is spawn/1 (or spawn/3 for a module/function/args form), which
starts a new process running the given function and immediately returns its PID to the caller — there's
no waiting for it to finish.
Pid1 = spawn(fun() -> loop(0) end), Pid2 = spawn(counter, loop, [0]).
In practice, raw spawn/1 is rarely used directly in production code. Instead, teams reach for
spawn_link/1 (to tie the new process's failure to the caller's), or more commonly
gen_server:start_link/3, so the new process is registered with a supervisor and follows OTP's
standard startup contract instead of being an unsupervised, untracked process.
More Related questions...