Industrial Use of a Functional Language - PowerPoint PPT Presentation

About This Presentation
Title:

Industrial Use of a Functional Language

Description:

Eigth times faster internet access in mobile phones. always connected ... active: download Erlang for free. www.erlang.org. over. 300 downloads. per month. Thomas Arts ... – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 36
Provided by: thoma121
Category:

less

Transcript and Presenter's Notes

Title: Industrial Use of a Functional Language


1
Industrial Use of a Functional Language
  • Thomas Arts
  • Ericsson
  • Computer Science Laboratory
  • Stockholm, Sweden

thomas_at_cslab.ericsson.se http//www.ericsson.se/cs
lab/thomas
2
Telecom industry
  • Switches, routers,
  • base-stations
  • Networks
  • Mobile telephones

3
Computer ScienceLaboratory
  • Founded 1983
  • Research on implementation tools, methods and
    techniques for telecommunication applications
  • Intermediate between universities and Ericsson
    product units

4
Telecom requirements
  • Requirements of telecom software
  • Concurrency
  • Distribution
  • Soft real-time
  • Robust
  • Non-stop system
  • External interfaces

5
A good language?
  • Experiments in the 80s with Ada, C, ML, CML,
    Prolog...
  • large programs (million lines)
  • change code in running system
  • fast message passing
  • low memory overhead
  • no memory fragmentation/leaks
  • recover from errors

6
Erlang/OTP
  • A functional language successfully used for
    programming large real-time control systems.
  • OTP is the set of libraries that is used with
    Erlang for product development

7
Erlang/OTP
  • Erlang/OTP develop/maintenance
  • Erlang consultancy courses
  • Erlang used many systems, e.g. ATM switch and
    new GSM network (GPRS)
  • Erlang Open Source

www.erlang.org
8
Erlangsequential program
  • -module(math).
  • -export(fac/1).
  • fac(N) when Ngt0 -gt
  • Nfac(N-1)
  • fac(N)-gt
  • 1.

9
Erlangdatatypes
  • atoms (true,foo,Hello)
  • numbers (1212864187154)
  • floats (3.141592)
  • tuples (a,123)
  • lists (1,123,2,56)
  • process identifiers
  • ...

10
Erlangdatatypes
  • dynamically typed language
  • poor mechanism to build your own datatypes

11
Erlangcontrol structures
  • Matching
  • case X of
  • ok,List -gt hd(List)
  • resend,Data -gt submit
  • error -gt exit(error)
  • _ -gt retry(X)
  • end

12
Erlangcontrol structures
  • Guards
  • f(....) when guard -gt ...
  • If
  • f(X) -gt
  • if guard1 -gt ...
  • guard2 -gt ...
  • end

13
Erlangcontrol structures
  • Higher order functions
  • f(F,X) -gt F(X)
  • map(F,1,2,3,4).
  • List comprehensions
  • X X,Ylt-Set, guard(X)

14
Erlangcontrol structures
  • Naming of objects/data
  • f(X) -gt
  • Dev update_device(X),
  • Date,Time now(),
  • h(Dev,Date).

15
Erlangcontrol structures
  • Sequence
  • f(X) -gt
  • action1(X),
  • action2(X)
  • update(X) -gt
  • log(X,myfile), new(X).

side-effects
16
Erlangcontrol - concurrency/distribution
  • Creating a process
  • Pid spawn(F,Arg1,...,ArgN)

B spawn(F,Args)
P2
P1
P2
F(Arg1,...,ArgN)
17
Erlangcontrol - concurrency/distribution
  • Sending messages
  • Pid ! Message

B!self(),hej
P1
P2
P1,hej
18
Erlangcontrol - concurrency/distribution
  • Receiving messages
  • receive
  • Pattern -gt ...
  • end

P1
P2
P1,hej

receive From,Msg -gt From !
ok,Msg end
P1 ! ok,hej
19
Erlangchanging code in running system
P0
loop(F) -gt receive change,G -gt
loop(G) exec,Pid,Arg -gt
Pid!F(Arg), loop(F) end
loop(F) -gt receive exec,Pid,Arg -gt
Pid!F(Arg), loop(F) end
P1
P0 ! exec,self(),15, N receive Answer
-gt Answer end,
N F(15),
20
Erlangfault tolerance
Processes can be linked to each other
PidA
PidB
  • Links are created by using either
  • link(Pid), or
  • spawn_link(Module, Function, Args)
  • Links are bi-directional.
  • They can be removed using unlink(Pid).

21
Erlangfault tolerance
When a process terminates, an exit signal is sent
to all processes the process is linked to
PidA
PidB
PidA
A process can terminate normally, due to a
run-time error, or when explicitly ordered to do
so.
22
Erlangfault tolerance
If a process terminates abnormally, the emitted
exit signal will (by default) cause the recipient
to terminate
The termination reason in the transmitted exit
signals will be the same as in the received one
(the exit signal is propagated).
PidC
PidD
PidE
PidA
PidB
PidB
PidD
23
Erlangfault tolerance
A process can terminate itself using
exit(Reason). This will cause exit signals with
termination reason Reason to be emitted.
24
Erlangfault tolerance
A process can explicitly send an exit signal to
another process using exit(Pid, Reason)
  • The calling process is not affected.
  • The processes do not need to be linked.

25
Erlangfault tolerance
A process can trap exit signals
using process_flag(trap_exit, true). Incoming
exit signals will be transformed into messages of
the form 'EXIT', Pid, Reason These exit
messages are delivered to the process mailbox in
the normal way.
26
Erlangfault tolerance
PidC terminates with reason error, PidD is
trapping exits
PidB terminates, propagating the exit signal.
PidD will receive an exit message
'EXIT', PidC, error.
error
error
PidC
PidD
PidE
PidA
PidB
PidB
PidA
27
Erlangfault tolerance
Robust systems can be made by layering.
28
Erlangfault tolerance
supervision trees and restart strategies
P4
P3
P1
P2
P3
P1
P6
P5
P1
P2
P3
P4
29
Erlangcomponent based development
  • recognize frequently occurring
  • patterns and transfer them into
  • standard components.
  • faster development
  • uniform code (maintenance)
  • less errors

30
Erlang
  • Developed with the application of the language
    constantly in mind
  • Practical usability more priority than purity

31
Erlang is used
  • AXD 301, scalable ATM switch (up to 160 GB/sec)
  • four years work
  • more than 500,000 lines of Erlang
  • several hundreds of programmers

32
Erlang is used
GPRS next generation GSM network.
  • Eigth times faster internet access in mobile
    phones
  • always connected
  • development in three countries, hundreds of
    people

33
Erlang is used
  • The success of the language in industry is due to
  • Language features
  • Support and libraries
  • Design patterns / architectures

34
Erlang is used
over 300 downloads per month
  • Become a user yourself!
  • passive make a phonecall
  • active download Erlang for free

www.erlang.org
35
Erlang
  • The functional language
  • for industry
Write a Comment
User Comments (0)
About PowerShow.com