Erlang Developments 
Enrique Paz @quiquepaz 
1/22
Introduction About me 
 Erlang Developer since 2008 
 Developing voteraise.com in Ocaml 
 Trying tech leadership @KPN 
2/22
Introduction Disclaimer 
sort_for_talk([Good,Bad,Ugly])- 
[Bad,Ugly,Good]. 
All comments to come are personal opinions. 
Read others’ in the WWW before making up your own 
3/22
The Bad 
4/22
The Bad (Un)Suitability 
Erlang is not a silver bullet 
 Number Crunching 
 Text/String Processing 
 XML and SOAP based Web Services 
“All can be done given time and money” - Ferenc Holzhauser 
5/22
The Bad Learning Curve 
 Design: Processes VS Objects 
I Technical knowledge required 
I Domain knowledge is harder to map 
 Functional Programming 
I Awesome (if you’ve felt the imperative pain) 
I Risk of callback hell 
6/22
The Bad What has improved 
 Learn You Some Erlang 
 Erlang Solutions Webinars 
 Erlang OTP in Action 
 Designing for Scalability with 
Erlang OTP 
7/22
The Ugly 
8/22
The Ugly Syntax 
 Erlang 
myfun(Opts) - 
What = proplists:get_value(what,Opts,some), 
io:format(Doing ~s~n, [What]), 
L = [1, 2, 3], 
lists:foldl(fun(X, Acc) - 
X + Acc 
end, 0, L). 
9/22
The Ugly Syntax 
 Erlang 
myfun(Opts) - 
What = proplists:get_value(what,Opts,some), 
io:format(Doing ~s~n, [What]), 
L = [1, 2, 3], 
lists:foldl(fun(X, Acc) - 
X + Acc 
end, 0, L). 
 Python 
myfun(what=some): 
print (Doing {thing}.format(thing=what) 
l = [1, 2, 3,], 
return reduce(lambda x, y: x + y, l, 0) 
9/22
The Ugly (lack of) Typesystem 
 Erlang 
myfold(F, Acc, []) - Acc; 
myfold(F, Acc, [H|T]) - myfold(F, F(H,Acc), T). 
myfold(fun(X) - X + 1 end, 0, [1, 2, 3]). 
% Error on runtime!! 
10/22
The Ugly (lack of) Typesystem 
 Erlang 
myfold(F, Acc, []) - Acc; 
myfold(F, Acc, [H|T]) - myfold(F, F(H,Acc), T). 
myfold(fun(X) - X + 1 end, 0, [1, 2, 3]). 
% Error on runtime!! 
 Ocaml 
let rec myfold f acc = function 
| [] - Acc 
| h::t - myfold f (f h acc) t 
# val myfold:(’a -’b-’b)-’b-’a list-’b=fun 
myfold (fun x - x+1) 0 [1;2;3] 
# Compilation error!! (could have used (+)) 
10/22
The Ugly What has improved 
 Elixir: a new language for the Erlang VM 
def myfun(what  ’some’) do 
IO.puts Doing #{what} 
l = [1, 2, 3] 
List.foldl l, 0, (1 + 2) 
end 
11/22
The Ugly What has improved 
 Elixir: a new language for the Erlang VM 
def myfun(what  ’some’) do 
IO.puts Doing #{what} 
l = [1, 2, 3] 
List.foldl l, 0, (1 + 2) 
end 
I Direct mixing of Erlang and Elixir code 
I Ruby-like syntax 
I Adoption? 
11/22
The Ugly What has improved 
 Dialyzer: Static type analyzer for Erlang code 
-type opt()::{what, string()}. 
-spec my_fun([opt()]) - pos_integer(). 
12/22
The Ugly What has improved 
 Dialyzer: Static type analyzer for Erlang code 
-type opt()::{what, string()}. 
-spec my_fun([opt()]) - pos_integer(). 
I Improved error catching 
I Improved error reporting 
I Ideally, all the code you use should be typed 
I Still no support for ETS and debugger match_specs 
I Dialyxir for Elixir projects 
12/22
The Good 
13/22
The Good Less Code 
 Functional = re-usability 
 OTP framework: structure and patterns 
 In code assertions / Let it crash 
ok = file:write_file(MyFile, Hello!) 
 Bit syntax 
?IP_VERSION:4, HLen:4, SrvcType:8, 
TotLen:16, ID:16, Flgs:3, FragOff:13, 
TTL:8, Proto:8, HdrChkSum:16, SrcIP:32, 
DestIP:32, RestDgram/binary = IpPkg 
14/22
The Good Less Engineers 
 High engineering level 
I Not trivial to learn 
I Usually not the 1st language 
 The WhatsApp example: 
I 450M users 
I  25 Engineers building client Apps 
I  6 Erlang Engineers building the server 
I  75M users / Erlang Engineer 
15/22
The Good Highly Available 
Availability1 of Erlang based telephone switches in late 
1980s 
 AXD301 reported 9.99999999% 
(nine nines) availability 
 0.6 seconds per 20 years 
1Joe Armstrong: http://pragprog.com/articles/erlang 
16/22
The Good Highly Available 
 Supervision trees provide automatic recovery 
 No downtime system upgrades 
1. Create appup 
2. Generate relup 
3. Deploy relup 
4. Instruct target system to upgrade itself 
17/22
The Good Scalable 
 Light Parallel processes 
I Quick to create: 660K processes/sec 
I  300 words / standard process (2.4KB) 
I No shared memory 2 
I 1 process per: user session, HTTP call. . . 
 Well known bottlenecks 
I gen_server serialization 
I Long lived NIFs 
I Disk I/O 
2almost 
18/22
The Good The community 
 Erlang Mailing List 
 Erlang Central LIVE chat 
 Erlang Camp 
 Erlang Factory (San Francisco) 
 Erlang User Conference (Stockholm) 
 Erlang Factory Lite: Berlin, Moscow, 
NY, Paris, Chicago. . . 
19/22
The Good What has improved 
 Forced wake up (+sfwi) for schedulers 
 ETS concurrency 
 enif_schedule_nif/0 for partitioned NIF invocation 
 Scalability on multicore (RELEASE) 
 And a ton of awesome applications: 
I Nifty 
I Cowboy 
I Concuerror 
I Piqi 
I . . . and, of course. . . 
20/22
The Good What has improved 
21/22
Wrapping up Questions 
22/22

Erlang Developments: The Good, The Bad and The Ugly

  • 1.
    Erlang Developments EnriquePaz @quiquepaz 1/22
  • 2.
    Introduction About me Erlang Developer since 2008 Developing voteraise.com in Ocaml Trying tech leadership @KPN 2/22
  • 3.
    Introduction Disclaimer sort_for_talk([Good,Bad,Ugly])- [Bad,Ugly,Good]. All comments to come are personal opinions. Read others’ in the WWW before making up your own 3/22
  • 4.
  • 5.
    The Bad (Un)Suitability Erlang is not a silver bullet Number Crunching Text/String Processing XML and SOAP based Web Services “All can be done given time and money” - Ferenc Holzhauser 5/22
  • 6.
    The Bad LearningCurve Design: Processes VS Objects I Technical knowledge required I Domain knowledge is harder to map Functional Programming I Awesome (if you’ve felt the imperative pain) I Risk of callback hell 6/22
  • 7.
    The Bad Whathas improved Learn You Some Erlang Erlang Solutions Webinars Erlang OTP in Action Designing for Scalability with Erlang OTP 7/22
  • 8.
  • 9.
    The Ugly Syntax Erlang myfun(Opts) - What = proplists:get_value(what,Opts,some), io:format(Doing ~s~n, [What]), L = [1, 2, 3], lists:foldl(fun(X, Acc) - X + Acc end, 0, L). 9/22
  • 10.
    The Ugly Syntax Erlang myfun(Opts) - What = proplists:get_value(what,Opts,some), io:format(Doing ~s~n, [What]), L = [1, 2, 3], lists:foldl(fun(X, Acc) - X + Acc end, 0, L). Python myfun(what=some): print (Doing {thing}.format(thing=what) l = [1, 2, 3,], return reduce(lambda x, y: x + y, l, 0) 9/22
  • 11.
    The Ugly (lackof) Typesystem Erlang myfold(F, Acc, []) - Acc; myfold(F, Acc, [H|T]) - myfold(F, F(H,Acc), T). myfold(fun(X) - X + 1 end, 0, [1, 2, 3]). % Error on runtime!! 10/22
  • 12.
    The Ugly (lackof) Typesystem Erlang myfold(F, Acc, []) - Acc; myfold(F, Acc, [H|T]) - myfold(F, F(H,Acc), T). myfold(fun(X) - X + 1 end, 0, [1, 2, 3]). % Error on runtime!! Ocaml let rec myfold f acc = function | [] - Acc | h::t - myfold f (f h acc) t # val myfold:(’a -’b-’b)-’b-’a list-’b=fun myfold (fun x - x+1) 0 [1;2;3] # Compilation error!! (could have used (+)) 10/22
  • 13.
    The Ugly Whathas improved Elixir: a new language for the Erlang VM def myfun(what ’some’) do IO.puts Doing #{what} l = [1, 2, 3] List.foldl l, 0, (1 + 2) end 11/22
  • 14.
    The Ugly Whathas improved Elixir: a new language for the Erlang VM def myfun(what ’some’) do IO.puts Doing #{what} l = [1, 2, 3] List.foldl l, 0, (1 + 2) end I Direct mixing of Erlang and Elixir code I Ruby-like syntax I Adoption? 11/22
  • 15.
    The Ugly Whathas improved Dialyzer: Static type analyzer for Erlang code -type opt()::{what, string()}. -spec my_fun([opt()]) - pos_integer(). 12/22
  • 16.
    The Ugly Whathas improved Dialyzer: Static type analyzer for Erlang code -type opt()::{what, string()}. -spec my_fun([opt()]) - pos_integer(). I Improved error catching I Improved error reporting I Ideally, all the code you use should be typed I Still no support for ETS and debugger match_specs I Dialyxir for Elixir projects 12/22
  • 17.
  • 18.
    The Good LessCode Functional = re-usability OTP framework: structure and patterns In code assertions / Let it crash ok = file:write_file(MyFile, Hello!) Bit syntax ?IP_VERSION:4, HLen:4, SrvcType:8, TotLen:16, ID:16, Flgs:3, FragOff:13, TTL:8, Proto:8, HdrChkSum:16, SrcIP:32, DestIP:32, RestDgram/binary = IpPkg 14/22
  • 19.
    The Good LessEngineers High engineering level I Not trivial to learn I Usually not the 1st language The WhatsApp example: I 450M users I 25 Engineers building client Apps I 6 Erlang Engineers building the server I 75M users / Erlang Engineer 15/22
  • 20.
    The Good HighlyAvailable Availability1 of Erlang based telephone switches in late 1980s AXD301 reported 9.99999999% (nine nines) availability 0.6 seconds per 20 years 1Joe Armstrong: http://pragprog.com/articles/erlang 16/22
  • 21.
    The Good HighlyAvailable Supervision trees provide automatic recovery No downtime system upgrades 1. Create appup 2. Generate relup 3. Deploy relup 4. Instruct target system to upgrade itself 17/22
  • 22.
    The Good Scalable Light Parallel processes I Quick to create: 660K processes/sec I 300 words / standard process (2.4KB) I No shared memory 2 I 1 process per: user session, HTTP call. . . Well known bottlenecks I gen_server serialization I Long lived NIFs I Disk I/O 2almost 18/22
  • 23.
    The Good Thecommunity Erlang Mailing List Erlang Central LIVE chat Erlang Camp Erlang Factory (San Francisco) Erlang User Conference (Stockholm) Erlang Factory Lite: Berlin, Moscow, NY, Paris, Chicago. . . 19/22
  • 24.
    The Good Whathas improved Forced wake up (+sfwi) for schedulers ETS concurrency enif_schedule_nif/0 for partitioned NIF invocation Scalability on multicore (RELEASE) And a ton of awesome applications: I Nifty I Cowboy I Concuerror I Piqi I . . . and, of course. . . 20/22
  • 25.
    The Good Whathas improved 21/22
  • 26.