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

Elixir: Ruby flavored Erlang

Elixir: Ruby flavored Erlang

Danilo R. Gonçalves

March 04, 2015
Tweet

Transcript

  1. Who am I? • Danilo Roberto Gonçalves • Developer at

    • https://github.com/danxexe • Rubyist since 2006
  2. –Yukihiro 'Matz' Matsumoto “I don't consider myself as the threading

    guy” “Matz is nice and so we are nice” “Matz is not a threading guy so we are not a threading guy”
  3. Concurrency in Ruby • Native threads since 1.9 (MRI) •

    Global Interpreter (VM) Lock • JRuby and Rubinius • No good Ruby spec
  4. Threads suck • Race conditions • Deadlocks • Locks are

    hard to use correctly • Hard to debug • Shared resources are the core most problems
  5. Actor Model • Message passing • Share nothing • Inherently

    concurrent, easily distributed • "Object oriented" as Alan Kay intended
  6. Erlang • THE Actor Model implementation • Lightweight VM processes

    • Functional language • Immutable data • Pattern matching • Hot code swapping • OTP - Open Telecom Platform • Battle tested by telecom industry (99.9999999% availability)
  7. Erlang annoyances • Weird, inconsistent syntax • Terrible string handling

    • Immutable variables + Lisp-like inside-out expressions • Crappy code organisation • Hard to get started
  8. Metaprogramming • Done via “hygienic macros” • Run code at

    compile time • Transform and generate code • Erlang compatible AST • Features implemented in Elixir via macros • if / unless, using, quote / unquote, assert, … • Even defmacro and def are implemented via macros
  9. Consistent standard library • Organize functions inside modules • String,

    Process, Node, System, … • Normalize param order • Remove boilerplate • GenServer, Agent, Taks, … • Polymorphism via protocols • Enum, Dict, Stream, …
  10. All the power of OTP • Supervisor chains • GenServer

    • ETS • Mnesia • Hot code swapping
  11. How do I get started? • http://learnxinyminutes.com/docs/elixir/ • http://elixir-lang.org •

    https://pragprog.com/book/elixir/programming-elixir • http://learnyousomeerlang.com/content
  12. –Damien Katz, CouchDB creator “There are the languages everyone complains

    about, and there are the languages no one uses.”