elixir - the only sane choice in an insane world · “what elixir brings to the table is a...
TRANSCRIPT
![Page 1: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/1.jpg)
Elixir
the only sane choice in an insane world
![Page 2: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/2.jpg)
Brian Cardarella
CEO of DockYard
![Page 3: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/3.jpg)
why the insanity?
![Page 4: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/4.jpg)
![Page 5: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/5.jpg)
![Page 6: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/6.jpg)
“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
![Page 7: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/7.jpg)
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
Inherited From Erlang
![Page 8: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/8.jpg)
clean, familiar syntax
mature tooling
built-in unit testing
meta-programming
built-in documentation
pipes
Phoenix
New for Elixir
![Page 9: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/9.jpg)
Pattern Matching
a = 1
![Page 10: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/10.jpg)
Pattern Matching
a = 11 = a
![Page 11: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/11.jpg)
Pattern Matching
[1] = [1]
![Page 12: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/12.jpg)
Pattern Matching
[a] = [1]
a = 1
![Page 13: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/13.jpg)
Pattern Matching
[a, b, c] = [1, 2, 3]
a = 1b = 2c = 3
![Page 14: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/14.jpg)
Pattern Matching
[a, b, [c]] = [1, 2, [3]]
a = 1b = 2c = 3
![Page 15: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/15.jpg)
Pattern Matching
def foo(1) do …
def foo(2) do …
foo(2)
![Page 16: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/16.jpg)
Pipes
foo(bar(baz(“hello world”))
![Page 17: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/17.jpg)
Pipes
result = baz(“hello world”)result = bar(result)result = foo(result)
![Page 18: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/18.jpg)
Pipes
“hello world”|> baz()|> bar()|> foo()
![Page 19: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/19.jpg)
Scalability
![Page 20: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/20.jpg)
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
![Page 21: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/21.jpg)
Can Elixir Scale?
![Page 22: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/22.jpg)
Case Study - Bleacher Report
150 AWS Instances
Servers jammed up with requests
Large engineering teams / app
Multiple complex caching strategies
8 year old Rails app
![Page 23: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/23.jpg)
Case Study - Bleacher Report
1/5th the AWS instances
10ms - 30ms average response times
Largest average spike: 400ms
Largest outlier spike: 800ms
About one engineer / app
No caching
Elixir / Phoenix rewrite
![Page 24: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/24.jpg)
Other Examples
• What’s App
• Ejabberd
• Riot Games
![Page 25: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/25.jpg)
GenServer
![Page 26: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/26.jpg)
![Page 27: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/27.jpg)
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]} endend
![Page 28: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/28.jpg)
{:ok, pid} = GotoConf.Chicago.Stack.start_link([])=> #PID<N.NNN.N>
GenServer.cast(pid, {:push, “hello”})=> :ok
GenServer.call(pid, :pop)=> “hello”
![Page 29: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/29.jpg)
Supervisors
![Page 30: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/30.jpg)
{: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
![Page 32: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/32.jpg)
![Page 33: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/33.jpg)
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) endend
![Page 34: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/34.jpg)
{: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: []
![Page 35: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/35.jpg)
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
![Page 36: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/36.jpg)
Can a language make you happy?(opinions!)
![Page 37: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/37.jpg)
![Page 38: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/38.jpg)
![Page 39: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/39.jpg)
![Page 40: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/40.jpg)
Elixir is a functional programming language
![Page 41: Elixir - The only sane choice in an insane world · “What Elixir brings to the table is a complete different surface syntax, inspired by Ruby. What you might call a “non-scary”](https://reader033.vdocuments.net/reader033/viewer/2022050507/5f987bb71bf34c1e7d6fa2c8/html5/thumbnails/41.jpg)
Go learn you some Elixir!