Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Erlang

C20f7f4a8aa455aa6e0c2a0092883cd0?s=47 Roberto Aloi
November 19, 2013

Introduction to Erlang

Presented at the Stockholm Erlang User Group.

C20f7f4a8aa455aa6e0c2a0092883cd0?s=128

Roberto Aloi

November 19, 2013
Tweet

Transcript

  1. TEXT WHY YOU SHOULD BUILD your next application IN ERLANG

  2. TEXT WHEN YOU SHOULD BUILD your next application IN ERLANG

  3. ERLANG IS NOT A MAGIC LANGUAGE.

  4. USE THE RIGHT TOOL FOR THE RIGHT JOB

  5. ERLANG WAS DESIGNED TO HELP YOU WRITING SYSTEMS DISTRIBUTED

  6. ERLANG WAS DESIGNED TO HELP YOU WRITING SYSTEMS SCALABLE

  7. ERLANG WAS DESIGNED TO HELP YOU WRITING SYSTEMS RELIABLE

  8. ERLANG WAS DESIGNED TO HELP YOU WRITING SYSTEMS ROBUST

  9. ERLANG WAS DESIGNED TO HELP YOU WRITING SYSTEMS FAULT TOLERANT

  10. ERLANG WAS DESIGNED TO HELP YOU WRITING SYSTEMS MASSIVELY CONCURRENT

  11. Do you need a distributed system? Do you need a

    scalable system? Do you need a reliable system? Do you need a fault-tolerant system? Do you need a massively concurrent system? Do you need a distributed system? Do you need a scalable system? Do you need a reliable system? Do you need a fault-tolerant system? Do distributed system? Do you need a scalable system? Do you need a reliable system? Do you need a fault-tolerant system? Do you need a massively NEED ERLANG? DO YOU
  12. THEN USE ERLANG.

  13. ERLANG IS NOT DIFFICULT TO LEARN - O N C

    E Y O U G E T PA S T T H E I N I T I A L H E A D A C H E - YOU WON’T BE ABLE TO LIVE WITHOUT IT
  14. ERLANG MAKES YOUR LIFE EASIER - N O T T

    H E O T H E R WAY A R O U N D - HAVE A LOOK TO OTP
  15. ERLANG IS ALSO FUN - B U T D O

    N ’ T T E L L Y O U R B O S S - OR YOU’LL GET PAID LESS
  16. WHERE TO START @ r o b e r t

    o a l o i
  17. None
  18. WHERE TO START LET’S TALK ABOUT ERLANG

  19. ... But in Practice? NICE WORDS SCALABILITY ROBUSTNESS FAULT TOLERANCE

    MASSIVE CONCURRENCY DISTRIBUTION
  20. WHERE TO START PROCESSES AND MESSAGE PASSING

  21. CREATE (SPAWN) A PROCESS spawn(math, fact, [5]) Pid1 Processes

  22. CREATE (SPAWN) A PROCESS spawn(math, fact, [5]) math:fact(5) Pid2 Pid1

    Processes
  23. AND SEND A MESSAGE TO IT Pid2 Pid1 Pid2 !

    {self(),msg} Message Passing
  24. AND SEND A MESSAGE TO IT Pid2 Pid1 Pid2 !

    {self(),msg} {Pid1,msg} Message Passing
  25. LINKS AND EXIT SIGNALS

  26. CREATE A BI-DIRECTIONAL LINK BETWEEN PROCESSES Links PidB PidA link(PidB)

  27. CREATE A BI-DIRECTIONAL LINK BETWEEN PROCESSES Links PidB PidA link(PidB)

  28. PROPAGATING EXIT SIGNALS Exit Signals PidA PidB PidC

  29. PROPAGATING EXIT SIGNALS Exit Signals PidA PidB PidC

  30. PROPAGATING EXIT SIGNALS Exit Signals PidB {'EXIT', PidA, Reason} PidC

  31. PROPAGATING EXIT SIGNALS Exit Signals PidB PidC

  32. PROPAGATING EXIT SIGNALS Exit Signals PidC {'EXIT', PidB, Reason}

  33. PROPAGATING EXIT SIGNALS Exit Signals

  34. Trap Exit TRAPPING AN EXIT SIGNAL PidA PidC PidB

  35. Trap Exit TRAPPING AN EXIT SIGNAL PidA PidC PidB

  36. Trap Exit TRAPPING AN EXIT SIGNAL {'EXIT', PidA, Reason} PidC

    PidB
  37. Trap Exit TRAPPING AN EXIT SIGNAL PidC PidB

  38. SUPERVISORS

  39. Supervisors PidA PidC PidB

  40. Supervisors PidA PidC PidB

  41. Supervisors PidA PidC PidB Supervisor

  42. Supervisors PidA PidC PidB Supervisor Workers

  43. LET IT CRASH (OR FAIL)

  44. Let It Crash convert(Day) -> case Day of monday ->

    1; tuesday -> 2; wednesday -> 3; thursday -> 4; friday -> 5; saturday -> 6; sunday -> 7; Other -> {error, unknown_day} end.
  45. DISTRIBUTED ERLANG

  46. Distributed Erlang erl -sname london erl -sname krakow erl -sname

    stockholm
  47. BEHAVIOURS

  48. Behaviours Servers Finite State Machines Event Handlers Supervisors Applications Less

    Code Less Bugs More Solid Code More Tested Code More Free Time
  49. Y U NO SHOW ME CODE!?

  50. WHERE TO START DEMO TIME (if it can go wrong,

    it will)
  51. WHO USES ERLANG?

  52. None
  53. None
  54. WHERE TO START

  55. erlang.org github.com/erlang/otp erlang-solutions.com www.learnyousomeerlang.org elearning.erlang-solutions.com Erlang Programming Erlang and OTP

    in Action Official Home Page Sources Binary Packages, News, Events Best Online Tutorial Commercial e-learning solution Best book about basics Best book about OTP
  56. QUESTIONS? @robertoaloi