elixir
play

Elixir the only sane choice in an insane world Brian Cardarella - PowerPoint PPT Presentation

Elixir the only sane choice in an insane world Brian Cardarella CEO of DockYard why the insanity? What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a non-scary syntax,


  1. Elixir the only sane choice in an insane world

  2. Brian Cardarella CEO of DockYard

  3. why the insanity?

  4. “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary” syntax, and a load of extra goodies.” — Joe Armstrong http://joearms.github.io/2013/05/31/a-week-with-elixir.html

  5. Inherited From Erlang leveraging a battle-tested 30 year old technology easily and manage distributed data via GenServer self-healing through Supervisors quickly scale to meet tomorrow’s demands pattern matching

  6. New for Elixir clean, familiar syntax mature tooling built-in unit testing meta-programming built-in documentation pipes Phoenix

  7. Pattern Matching a = 1

  8. Pattern Matching a = 1 1 = a

  9. Pattern Matching [1] = [1]

  10. Pattern Matching [a] = [1] a = 1

  11. Pattern Matching [a, b, c] = [1, 2, 3] a = 1 b = 2 c = 3

  12. Pattern Matching [a, b, [c]] = [1, 2, [3]] a = 1 b = 2 c = 3

  13. Pattern Matching def foo(1) do 
 … def foo(2) do 
 … foo(2)

  14. Pipes foo(bar(baz(“hello world”))

  15. Pipes result = baz(“hello world”) result = bar(result) result = foo(result)

  16. Pipes “hello world” |> baz() |> bar() |> foo()

  17. Scalability

  18. Erlang VM 
 (BEAM) Monitors and Schedules its own processes Can distribute processes across all available CPU cores Each process only about 1kb Each process has its own GC

  19. Can Elixir Scale?

  20. Case Study - Bleacher Report 8 year old Rails app 150 AWS Instances Servers jammed up with requests Large engineering teams / app Multiple complex caching strategies

  21. Case Study - Bleacher Report Elixir / Phoenix rewrite 1/5th the AWS instances 10ms - 30ms average response times Largest average spike: 400ms Largest outlier spike: 800ms About one engineer / app No caching

  22. Other Examples • What’s App • Ejabberd • Riot Games

  23. GenServer

  24. defmodule GotoConf.Chicago.Stack do use GenServer def start_link(state, opts \\ []) do GenServer.start_link(__MODULE__, state, opts) end def handle_call(:pop, _from, [h | t]) do {:reply, h, t} end def handle_cast({:push, h}, t) do {:noreply, [h | t]} end end

  25. {:ok, pid} = GotoConf.Chicago.Stack.start_link([]) => #PID<N.NNN.N> GenServer.cast(pid, {:push, “hello”}) => :ok GenServer.call(pid, :pop) => “hello”

  26. Supervisors

  27. {:ok, pid} = GotoConf.Chicago.Stack.start_link([]) => #PID<N.NNN.N> GenServer.cast(pid, {:push, “hello”}) => :ok GenServer.cast(pid, {:foo, “uh oh!”}) 15:06:35.157 [error] GenServer #PID<0.165.0> terminating ** (FunctionClauseError) no function clause matching in GotoConf.Chicago.Stack.handle_cast/2 iex:13: GotoConf.Chicago.Stack.handle_cast({:foo, 5}, []) Last message: {:"$gen_cast", {:foo, 5}} State: [] GenServer.cast(pid, {:push, “hello”}) ** (CompileError) iex:1: undefined function pid/0

  28. credit: http://learnyousomeerlang.com/supervisors

  29. defmodule GotoConf.Chicago.Supervisor do use Supervisor def start_link do Supervisor.start_link(__MODULE__, []) end def init([]) do children = [ worker(GotoConf.Chicago.Stack, [[], [name: MyStack]]) ] supervise(children, strategy: :one_for_one) end end

  30. {:ok, pid} = GotoConf.Chicago.Supervisor.start_link() => #PID<N.NNN.N> GenServer.cast(MyStack, {:push, “hello”}) => :ok GenServer.call(pid, :pop) => “hello” GenServer.cast(pid, {:foo, “uh oh!”}) 15:06:35.157 [error] GenServer #PID<0.165.0> terminating ** (FunctionClauseError) no function clause matching in GotoConf.Chicago.Stack.handle_cast/2 iex:13: GotoConf.Chicago.Stack.handle_cast({:foo, 5}, []) Last message: {:"$gen_cast", {:foo, 5}} State: []

  31. GenServer.cast(pid, {:foo, “uh oh!”}) 15:06:35.157 [error] GenServer #PID<0.165.0> terminating ** (FunctionClauseError) no function clause matching in GotoConf.Chicago.Stack.handle_cast/2 iex:13: GotoConf.Chicago.Stack.handle_cast({:foo, 5}, []) Last message: {:"$gen_cast", {:foo, 5}} State: [] GenServer.cast(pid, {:push, “hello”}) => :ok

  32. Can a language make you happy? (opinions!)

  33. Elixir is a functional programming language

  34. Go learn you some Elixir!

  35. Brian Cardarella CEO of DockYard dockyard.com

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend