It's abount (run)time: Elixir beyond the hype

4569aec00cb223b3fbf484f9e7ba1256?s=47 Renan Ranelli
September 22, 2018

It's abount (run)time: Elixir beyond the hype


Renan Ranelli

September 22, 2018


  1. @renanranelli It's about (run)time: Elixir Beyond the Hype 2018-09-22 Renan

  2. @renanranelli

  3. Elixir Engineer @ Telnyx Chicago, IL Based in São Paulo

    @ Brasil Elixir since 2015 Organizer of Elixir SãoPaulo meetup Before Elixir, lot’s of Ruby, Python, C#, etc
  4. None
  5. None
  6. (We're hiring !!!)

  7. None
  8. It's about (run)time: Elixir Beyond the Hype


  10. Language vs Platform

  11. Definitions: 1. Erlang is a language 2. Erlang/OTP is a

    platform 3. Elixir is a language on top of the Erlang platform
  12. Erlang/OTP

  13. - Is a functional programming language - "Solves" concurrency for

    you - Is the "secret" behind Whatsapp - Half the world's telephony is built with it (citation needed) - Nine-nines of availability Things we hear about it:
  14. The Erlang/OTP Runtime

  15. - "Soft real time" - Preemptive scheduling (responsive, fair &

    low latency variance) - Vertically scalable - Distribution & Concurrency as a first class thing - Runtime guarantees for process execution (fault tolerance) - "High Performance" Characteristics of the Erlang VM
  16. What about Elixir?

  17. - Elixir compiles to the Erlang's bytecode - Created by

    a Brazilian! José Valim - The semantics of Elixir and Erlang are *absolutely the same*. There is no impedance mismatch - From the point of view of the platform, it makes absolutely no difference whether the source code is written in Erlang or Elixir (and this is HUGE) Elixir is just a small drop (pun intended)
  18. "When designing the Erlang language and the Erlang VM, Joe,Mike

    and Robert did not aim to implement a functional programming language, they wanted a runtime where they could build distributed, fault-tolerant applications. It just happened that the foundation for writing such systems share many of the functional programming principles. And it reflects in both Erlang and Elixir. Therefore, the discussion becomes much more interesting when you ask about their end-goals and how functional programming helped them achieve them. The further we explore those goals,we realize how they tie in with immutability and the control of shared state, for example: ..." -- Valim, José Elixir Beyond Functional Programming

  20. Fault-tolerance requires hardware redundancy Hardware redundancy requires Concurrency is a

    special case of distribution
  21. So… why Elixir exists then?

  22. - Erlang's syntax and ecosystem are Alien to modern software

    developers. - There are many barriers to its adoption: Lack of tooling, hard to read docs, mostly 0 data-polymorphism - Elixir brings the "21st century" to Erlang-land, via metaprogramming, tooling, excellent documentation and a very welcoming and vibrant community Why Elixir exists:
  23. Erlang -> Hard Skills Elixir -> Soft Skills

  24. Runtime logical organization

  25. pid1 pid2 pid3 Erlang Node Scheduler 1 Scheduler Scheduler OS

    Thread Scheduler 2 OS Thread Scheduler 3 OS Thread pid1 pid1 OS PROCESS msg queue HEAP message
  26. Preemptive Scheduling

  27. Suppose we've got 6 tasks: T1 T2 T3 T4 T5

  28. With *cooperative scheduling*: T1 T2 T3 T4 T5 T1 T2

    T3 T4 T5 T1 T2 T3 T4 T5 1) Or 2) Or 3)
  29. With *preemptive scheduling*: T1 T2 T3 T4 T5 1) Or

    2) And so on and so on... T4 T5 T1 T2 T3 T4 T5 T4 T5 T5
  30. Runtime guarantees: Process Monitoring

  31. Process1 Pid0 (Monitors) Process Monitoring DEAD Msg queue GUARANTEED MSG

  32. Supervision Trees

  33. Supervision Trees DEAD


  35. - You can query & manipulate processes, the basic unit

    of execution in Erlang. - That means, you can handle it as *data* and manipulate, create, destroy, halt, garbage-collect them. - You can see what a process is doing now, what it has done before, who it talks to, who it monitors… pretty much *everything*. Activities as first-class citizens:
  36. `:observer.start()`

  37. Beyond the marketing

  38. - Scalability, both horizontal and vertical - Using all cores

    for development - Elixir is crazy fast! (not really) - I don't need to care about GC at all! (not really) - Productivity!!! These are all *consequences* of the well defined fundamentals we just saw! The main selling points we see:
  39. Because of that, the things we build with Elixir are,

    in general, very well engineered!
  40. Example: Ecto's Connection Pool

  41. Process Connection Pool 2) Set-up a monitor (!) Ecto Connection

    Pool Msg queue 5) Pool checks-in The connection ! 1) Check-out connection 4) message is sent telling the pool that the process died 2) Hand over connection 3) DIE

  43. Actually… there is a lot more

  44. - Clustering - Embedded data stores - Very powerful and

    lightweight tracing of pretty much anything - Logging and error reporting built in - Hot-code-deployments Other incredible things we did not cover
  45. All of this is made possible because we've got good

    abstractions !
  46. Wrapping up

  47. - The greatest asset of Elixir is access to Erlang's

    Runtime & Platform. - Elixir is not magic. It won't solve all your problems in the blink of an eye, but it will give you a very powerful toolset and a vocabulary shared by *the whole community* on how to deal with failures & distribution. - Developer friendliness, metaprogramming and syntax are cool, but they are not the whole picture. - The "erlang-way" is present in all aspects of the platform and its community. This, IMHO, is something unattainable in other platform and is Elixir's trumph Wrapping up
  48. Elixir is not (only) a hype.

  49. Elixir is a well-engineered platform By engineers, for engineers.

  50. Renan Ranelli Obrigado! Check us out! @renanranelli

    We're hiring!!