Date post: | 16-Jun-2015 |
Category: |
Engineering |
Upload: | enriquepazperez |
View: | 535 times |
Download: | 3 times |
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 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
The Bad What has improved
• Learn You Some Erlang
• Erlang Solutions Webinars
• Erlang OTP in Action
• Designing for Scalability withErlang OTP
7/22
The Ugly
8/22
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
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
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
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
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
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
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
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
The Good
13/22
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
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
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
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
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
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 NiftyI CowboyI ConcuerrorI PiqiI . . . and, of course. . .
20/22
The Good What has improved
21/22
Wrapping up Questions
22/22