Slide 1

Slide 1 text

Iuri Fernandes A Brief Introduction to Elixir

Slide 2

Slide 2 text

Elixir! • Runs on Erlang VM • Cool language • But before…

Slide 3

Slide 3 text

The problem • Telecommunications • Fast • Fault tolerant • Distributed

Slide 4

Slide 4 text

Erlang and Telecom • Designed for telecom problems • OTP(Open Telecom Platform)

Slide 5

Slide 5 text

Slide from José Valim’s presentations

Slide 6

Slide 6 text

Slide from José Valim’s presentations

Slide 7

Slide 7 text

BEAM • Erlang VM • Processes are units of computation • Message passing FTW

Slide 8

Slide 8 text

Image from “Learn you some Erlang for great good” licensed under Creative Commons Messages

Slide 9

Slide 9 text

OTP • Framework • Concurrent and distributed applications • Models behaviors for processes • And much more …

Slide 10

Slide 10 text

OTP Examples Image from “Learn you some Erlang for great good” licensed under Creative Commons

Slide 11

Slide 11 text

Image from “Learn you some Erlang for great good” licensed under Creative Commons OTP Examples

Slide 12

Slide 12 text

Image from “Learn you some Erlang for great good” licensed under Creative Commons OTP Examples

Slide 13

Slide 13 text

Elixir • Created in 2012 by José Valim • Functional (Immutability) • Dynamically typed • Metaprogramming • Fresh life to Erlang ecosystem • BEAM VM

Slide 14

Slide 14 text

Drops of Elixir defmodule MyModule do def increment(argument) do argument + 1 end end defmodule PatternMatching do def head([]), do: nil def head([head | _]), do: head end

Slide 15

Slide 15 text

Drops of Elixir defmodule MyModule do def increment(x) when is_integer(x) do x + 1 end end defmodule PatternMatching do def head([]), do: nil def head([head | _]), do: head end

Slide 16

Slide 16 text

Drops of Elixir parent = self() # Spawns an Elixir process (not an operating system one!) spawn_link(fn -> send parent, {:msg, "hello world"} end) # Block until the message is received receive do {:msg, contents} -> IO.puts contents end

Slide 17

Slide 17 text

Drops of Elixir defmodule Stack do use GenServer # Callbacks def handle_call(:pop, _from, [h|t]) do {:reply, h, t} end def handle_cast({:push, item}, state) do {:noreply, [item|state]} end end

Slide 18

Slide 18 text

Drops of Elixir # Start the server {:ok, pid} = GenServer.start_link(Stack, [:hello]) # This is the client GenServer.call(pid, :pop) #=> :hello GenServer.cast(pid, {:push, :world}) #=> :ok GenServer.call(pid, :pop) #=> :world

Slide 19

Slide 19 text

Applications • Chat web app with Phoenix • Embedded systems with Nerves • Pusher app replacement with Poxa

Slide 20

Slide 20 text

https://github.com/doomspork/elixir-companies Who uses it

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Questions?