Slide 1

Slide 1 text

Elixir Stefan Wintermeyer @wintermeyer

Slide 2

Slide 2 text

Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang virtual machine (BEAM). https://en.wikipedia.org/wiki/Elixir_(programming_language)

Slide 3

Slide 3 text

defmodule ModuleName do def hello do IO.puts "Hello World" end end http://elixir-lang.org/crash-course.html

Slide 4

Slide 4 text

IEx Elixir’s interactive shell

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Why would I want to learn Elixir? Why invest the time and effort? I’m happy with Ruby and OO.

Slide 7

Slide 7 text

Three Main Reasons Spoiler Alert: Concurrency is not one of them.

Slide 8

Slide 8 text

1. Speed Elixir runs circles around Ruby and Python.

Slide 9

Slide 9 text

2. Stability Speed is nothing without stability.

Slide 10

Slide 10 text

3. Hot-Code Upgrades Zero Downtime!

Slide 11

Slide 11 text

Some Code Examples

Slide 12

Slide 12 text

Assigning Values to Variables

Slide 13

Slide 13 text

iex(1)> a = 1 1 iex(2)>

Slide 14

Slide 14 text

iex(1)> a = 1 1 iex(2)> a = 2 2 iex(3)>

Slide 15

Slide 15 text

iex(1)> a = 1 1 iex(2)> a = 2 2 iex(3)> ^a = 3 ** (MatchError) no match of right hand side value: 3

Slide 16

Slide 16 text

Tuples

Slide 17

Slide 17 text

iex(1)> {a, b, c} = {10, 20, 30} {10, 20, 30} iex(2)>

Slide 18

Slide 18 text

iex(1)> {a, b, c} = {10, 20, 30} {10, 20, 30} iex(2)> a 10 iex(3)>

Slide 19

Slide 19 text

Pattern Matching

Slide 20

Slide 20 text

iex(1)> {a, b, c} = {10, 20, 30} {10, 20, 30} iex(2)>

Slide 21

Slide 21 text

iex(1)> {a, b, c} = {10, 20, 30} {10, 20, 30} iex(2)> {a, 20, c} = {10, 20, 30} {10, 20, 30} iex(3)>

Slide 22

Slide 22 text

iex(1)> {a, b, c} = {10, 20, 30} {10, 20, 30} iex(2)> {a, 20, c} = {10, 20, 30} {10, 20, 30} iex(3)> {a, 1, c} = {10, 20, 30} ** (MatchError) no match of right hand side value: {10, 20, 30}

Slide 23

Slide 23 text

If you want to get your feed wet with Elixir I recommend two projects.

Slide 24

Slide 24 text

If you like hardware try http://nerves-project.org

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

If you like the web try www.phoenixframework.org

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Phoenix Framework Productive. Reliable. Fast. Phoenix != Rails

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

mix phoenix.new blog Y cd blog vim config/dev.exs brew install postgres brew services start postgres createuser -W --createdb blog demo mix ecto.create mix phoenix.gen.html Post posts subject body vim web/router.ex resources "/posts", PostController mix ecto.migrate mix phoenix.server Blog Example

Slide 31

Slide 31 text

Thank you! @wintermeyer