3. History of Erlang 1984-86: Experiments programming POTS with several languages 1998: Open Source Erlang 1987: Early Erlang Prototype projects 1991: First fast implementation 1993: Distributed Erlang 1995: Several new projects 1996: Open Telecom Platform AXD and GPRS started How to design SW for future telecoms systems?
15. Erlang Example Creating a new process using spawn -module(ex3). -export([activity/3]). activity(Name,Pos,Size) -> ………… Pid = spawn(ex3,activity,[Joe,75,1024]) activity(Joe,75,1024)
16. Erlang Example Processes communicate by asynchronous message passing Pid ! {data,12,13} receive {start} -> ……… {stop} -> ……… {data,X,Y} -> ……… end receive {start} -> ……… {stop} -> ……… {data,X,Y} -> ……… end
29. Transparent Distribution Erlang Run-Time System Erlang Run-Time System B ! Msg network C ! Msg Message passing between processes in different computer is just as easy as between processes in the same computer A B C
30. Simple RPC loop() -> receive {From, {apply, M, F, A}} -> Answer = (catch apply(M, F, A)), From ! {rex, node(), Answer} loop(); _Other -> loop() end. {rex, Node} ! {self(), {apply, M, F, A}}, receive {rex, Node, What} -> What end {rex, Node} ! {self(), {apply, M, F, A}}, receive {rex, Node, What} -> What end {rex, Node} ! {self(), {apply, M, F, A}}, receive {rex, Node, What} -> What end loop() -> receive {From, {apply, M, F, A}} -> Answer = (catch apply(M, F, A)), From ! {rex, node(), Answer} loop(); _Other -> loop() end. loop() -> receive {From, {apply, M, F, A}} -> Answer = (catch apply(M, F, A)), From ! {rex, node(), Answer} loop(); _Other -> loop() end. loop() -> receive {From, {apply, M, F, A}} -> Answer = (catch apply(M, F, A)), From ! {rex, node(), Answer} loop(); _Other -> loop() end.
35. Erlang Example Port External process receive {Port, {data, Info}} -> end A port can use e.g. a TCP, UDP, SSL socket, UNIX pipe, or custom transport (e.g. SAAL)
36.
37. Systems Overview OTP Components Standard Libraries Erlang Run-Time System Hardware and Operating System Applications written in Erlang Applications written in C, C++ or Java
2003-12-01 Rev PA1 This is the essential loop needed for an RPC server. The server receives requests from clients, uses apply to evaluate the requests and then returns the answer to the originator. This is a simplified solution where no error handling is done. The BIF node/0 returns the node name.