+ All Categories
Home > Engineering > Erlang Developments: The Good, The Bad and The Ugly

Erlang Developments: The Good, The Bad and The Ugly

Date post: 16-Jun-2015
Category:
Upload: enriquepazperez
View: 535 times
Download: 3 times
Share this document with a friend
Description:
A bunch of personal views about the main characteristics of Erlang, including myths and rumors. A quick overview about what has lately been improved in the three areas.
Popular Tags:
26
Erlang Developments Enrique Paz @quiquepaz 1/22
Transcript
Page 1: Erlang Developments: The Good, The Bad and The Ugly

Erlang Developments

Enrique Paz @quiquepaz

1/22

Page 2: Erlang Developments: The Good, The Bad and The Ugly

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

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

The Bad

4/22

Page 5: Erlang Developments: The Good, The Bad and The Ugly

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

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

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

The Ugly

8/22

Page 9: Erlang Developments: The Good, The Bad and The Ugly

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

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

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

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

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

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

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

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

The Good

13/22

Page 18: Erlang Developments: The Good, The Bad and The Ugly

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

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

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

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

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

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

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

The Good What has improved

21/22

Page 26: Erlang Developments: The Good, The Bad and The Ugly

Wrapping up Questions

22/22


Recommended