Erlang Developments: The Good, The Bad and The Ugly
-
Upload
enriquepazperez -
Category
Engineering
-
view
536 -
download
3
description
Transcript of Erlang Developments: The Good, The Bad and The Ugly
![Page 2: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/2.jpg)
Introduction About me
• Erlang Developer since 2008
• Developing voteraise.com in Ocaml
• Trying tech leadership @KPN
2/22
![Page 3: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/3.jpg)
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
![Page 4: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/4.jpg)
The Bad
4/22
![Page 5: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/5.jpg)
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
![Page 6: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/6.jpg)
The Bad Learning Curve
• Design: Processes VS ObjectsI Technical knowledge requiredI Domain knowledge is harder to map
• Functional ProgrammingI Awesome (if you’ve felt the imperative pain)I Risk of callback hell
6/22
![Page 7: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/7.jpg)
The Bad What has improved
• Learn You Some Erlang
• Erlang Solutions Webinars
• Erlang OTP in Action
• Designing for Scalability withErlang OTP
7/22
![Page 8: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/8.jpg)
The Ugly
8/22
![Page 9: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/9.jpg)
The Ugly Syntax• Erlangmyfun(Opts) ->
What = proplists:get_value(what,Opts,"some"),io:format("Doing ~s~n", [What]),L = [1, 2, 3],lists:foldl(fun(X, Acc) ->
X + Accend, 0, L).
• Pythonmyfun(what="some"):
print ("Doing {thing}".format(thing=what)l = [1, 2, 3,],return reduce(lambda x, y: x + y, l, 0)
9/22
![Page 10: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/10.jpg)
The Ugly Syntax• Erlangmyfun(Opts) ->
What = proplists:get_value(what,Opts,"some"),io:format("Doing ~s~n", [What]),L = [1, 2, 3],lists:foldl(fun(X, Acc) ->
X + Accend, 0, L).
• Pythonmyfun(what="some"):
print ("Doing {thing}".format(thing=what)l = [1, 2, 3,],return reduce(lambda x, y: x + y, l, 0)
9/22
![Page 11: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/11.jpg)
The Ugly (lack of) Typesystem• Erlangmyfold(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!!
• Ocamllet 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
![Page 12: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/12.jpg)
The Ugly (lack of) Typesystem• Erlangmyfold(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!!
• Ocamllet 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
![Page 13: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/13.jpg)
The Ugly What has improved
• Elixir: a new language for the Erlang VMdef 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 codeI Ruby-like syntaxI Adoption?
11/22
![Page 14: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/14.jpg)
The Ugly What has improved
• Elixir: a new language for the Erlang VMdef 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 codeI Ruby-like syntaxI Adoption?
11/22
![Page 15: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/15.jpg)
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 catchingI Improved error reportingI Ideally, all the code you use should be typedI Still no support for ETS and debugger match_specsI Dialyxir for Elixir projects
12/22
![Page 16: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/16.jpg)
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 catchingI Improved error reportingI Ideally, all the code you use should be typedI Still no support for ETS and debugger match_specsI Dialyxir for Elixir projects
12/22
![Page 17: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/17.jpg)
The Good
13/22
![Page 18: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/18.jpg)
The Good Less Code
• Functional => re-usability• OTP framework: structure and patterns• In code assertions / Let it crashok = 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
![Page 19: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/19.jpg)
The Good Less Engineers
• High engineering levelI Not trivial to learnI Usually not the 1st language
• The WhatsApp example:I 450M usersI ∼ 25 Engineers building client AppsI ∼ 6 Erlang Engineers building the serverI ∼ 75M users / Erlang Engineer
15/22
![Page 20: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/20.jpg)
The Good Highly Available
Availability1 of Erlang based telephone switches in late1980s
• AXD301 reported 9.99999999%(nine nines) availability
• 0.6 seconds per 20 years
1Joe Armstrong: http://pragprog.com/articles/erlang16/22
![Page 21: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/21.jpg)
The Good Highly Available
• Supervision trees provide automatic recovery
• No downtime system upgrades1. Create appup2. Generate relup3. Deploy relup4. Instruct target system to upgrade itself
17/22
![Page 22: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/22.jpg)
The Good Scalable
• Light Parallel processesI Quick to create: 660K processes/secI ∼ 300 words / standard process (2.4KB)I No shared memory 2
I 1 process per: user session, HTTP call. . .
• Well known bottlenecksI gen_server serializationI Long lived NIFsI Disk I/O
2almost18/22
![Page 23: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/23.jpg)
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
![Page 24: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/24.jpg)
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 NiftyI CowboyI ConcuerrorI PiqiI . . . and, of course. . .
20/22
![Page 25: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/25.jpg)
The Good What has improved
21/22
![Page 26: Erlang Developments: The Good, The Bad and The Ugly](https://reader033.fdocuments.us/reader033/viewer/2022060116/55804799d8b42ae32c8b4c22/html5/thumbnails/26.jpg)
Wrapping up Questions
22/22