Elixir - functional, concurrent, distributed programming for the rest of us

Elixir - functional, concurrent, distributed programming for the rest of us

Faafc04d9e69b73b9f49995fd4c94d4d?s=128

Andrea Leopardi

October 26, 2018
Tweet

Transcript

  1. functional, concurrent, distributed programming for the rest of us ELIXIR

  2. @whatyouhide

  3. None
  4. None
  5. None
  6. None
  7. functional, concurrent, distributed programming for the rest of us ELIXIR

  8. LET'S BUILD A LANGUAGE

  9. Language for modern systems

  10. None
  11. concurrent distributed fault-tolerant extensible

  12. don't give to devs, enable devs

  13. VM

  14. NO TYPE SYSTEM

  15. CONCURRENCY

  16. threads are heavy

  17. schedulers VM processes

  18. memory memory

  19. IMMUTABLE DATA

  20. MESSAGE PASSING

  21. send(pid, message) receive do ... end +

  22. None
  23. pattern matching

  24. {1, _} = some_tuple

  25. receive do {1, _} -> ... {_, _} -> ...

    end
  26. None
  27. case expression do pattern1 -> ... pattern2 -> ... _

    -> ... end
  28. ISOLATED MEMORY MESSAGE PASSING +

  29. None
  30. def loop(state) do receive do new_state -> loop(new_state) end end

  31. DISTRIBUTION

  32. node 1 node 2

  33. FAULT TOLERANCE

  34. acceptor

  35. acceptor

  36. None
  37. None
  38. link

  39. link

  40. link

  41. link trap crash

  42. link trap crash trap crash

  43. None
  44. None
  45. SUPERVISORS

  46. None
  47. None
  48. None
  49. None
  50. SYNTAX

  51. github.com/josevalim/lego-lang

  52. def(double_sum(a, b), do: ( =(c, +(a, b)) *(c, 2) ))

  53. def(double_sum(a, b), do: ( =(c, +(a, b)) *(c, 2) ))

  54. def(double_sum(a, b), do: ( =(c, +(a, b)) *(c, 2) ))

  55. def(double_sum(a, b), do: ( =(c, +(a, b)) *(c, 2) ))

  56. if(>(a, b), do: a, else: b)

  57. macros functions +

  58. less parens?

  59. def(double_sum(a, b), do: ( =(c, +(a, b)) *(c, 2) ))

  60. def(double_sum(a, b), do: ( c = a + b c

    * 2 ))
  61. def double_sum(a, b), do: ( c = a + b

    c * 2 )
  62. def double_sum(a, b) do c = a + b c

    * 2 end
  63. if a > b do a else b end

  64. literals and containers

  65. [1, 2, 3] [](1, 2, 3)

  66. macros functions +

  67. def add(a, b), do: a + b

  68. defmacro def(call, keywords) add(a, b) do: (a + b)

  69. case expression do true -> branch1 else -> branch2 end

  70. defmacro if(condition, do: branch1, else: branch2) do quote do case

    unquote(condition) do true -> unquote(branch1) false -> unquote(branch2) end end end
  71. CONLCLUSION

  72. PLOT TWIST... we built ELIXIR

  73. concurrent distrubuted fault-tolerant extensible

  74. elixir-lang.org @whatyouhide