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

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

Renan Ranelli
September 22, 2018
75

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

Renan Ranelli

September 22, 2018
Tweet

Transcript

  1. 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
  2. Definitions: 1. Erlang is a language 2. Erlang/OTP is a

    platform 3. Elixir is a language on top of the Erlang platform
  3. - 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:
  4. - "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
  5. - 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)
  6. "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
  7. - 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:
  8. 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
  9. With *cooperative scheduling*: T1 T2 T3 T4 T5 T1 T2

    T3 T4 T5 T1 T2 T3 T4 T5 1) Or 2) Or 3)
  10. 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
  11. Process1 Pid0 (Monitors) Process Monitoring DEAD Msg queue GUARANTEED MSG

    DESCRIBING WHAT WENT ON THE PROCESS CAN HANDLE THIS MSG AND TAKE ACTION!!!
  12. - 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:
  13. - 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:
  14. Because of that, the things we build with Elixir are,

    in general, very well engineered!
  15. 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
  16. - 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
  17. - 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