model • Network transparency • Good at slicing and dicing network protocols • "For free" SMP scaling (up to about 8 cores) • Fault tolerance mechanisms help avoid "defensive coding" • Replace/upgrade running code without downtime • Makes hard things easy
message format and data opaque move(Who, Where) -> case whereis(Where) of undefined -> error_logger:error_msg("There is no port named ~p", [Where]); _Pid -> gen_server:call(Who, {move, Where}) end. Example: move(Who, Where)
= #state{ port = undefined }) -> parque_port:arrive(Where, self()), {reply, ok, State#state{ port = Where }}; handle_call({move, Where}, _From, State = #state{ port = Port }) -> parque_port:leave(Port, self()), parque_port:arrive(Where, self()), {reply, ok, State#state{ port = Where }};
2. Send 'Jane' process a message to buy fish for 10. 3. 'Jane' is in a port? 4. 'Jane' has sufficient capacity? 5. 'Jane' can afford price * qty? 6. Send port process buy message (updates port state if request successful; port also notifies other player processes of buy activity) 7. If successful reply from port process, update 'Jane' state
require concurrency and (soft) real-time performance. Erlang is not (too) scary. Try it; you might like it. Writing games as a side project is very fun.