SlideShare a Scribd company logo
Elixir
Robert Brown
@robby_brown
@robert_brown
@rob-brown
What is Elixir?
A Ruby-inspired language built on the Erlang Virtual
Machine
Extends Erlang with macros, pipelines, and sigils
Your next programming language
What is Erlang?
Created in 1986 by Ericsson
Open sourced in 1998
Functional, concurrent language
Based on Prolog, Smalltalk, CSP, and functional
programming
Advantages of Erlang
Fault tolerant
Lightweight processes
Hot code swapping
“Let it crash” philosophy
Advantages of Erlang
Battle-tested libraries
Soft real time
Trivial parallel processing
Trivial network protocol processing
Advantages of Erlang
Pattern matching
Tail recursion
Garbage Collected
Advantages of Erlang
http://www.slideshare.net/JanHenryNystrom/productivity-gains-in-erlang
Who Uses Erlang?
Amazon
Yahoo!
Facebook
T-Mobile
Motorola
Ericsson
WhatsApp
Huffington Post
CouchDB
GitHub
Basho
RabbitMQ
Call of Duty
League of
Legends
Goldman Sachs
http://en.wikipedia.org/wiki/Erlang_(programming_language)
Why Learn Functional
Programming?
The future is in parallel processing
Easier to debug
Many languages are adopting FP techniques
Actor Model
Actors can be created/destroyed and send/receive
messages
All state is encapsulated
In Elixir, each actor is its own process
Elixir Syntax: Numbers
!
42
123.456
1_000_000
!
0b101010 (binary)
0xdeadc0de (hex)
034 (octal)
Elixir Syntax: Tuples
{ 1, 2, 3 }
{ 3.14, :hello, “world” }
Elixir Syntax: List
[ ]
[ 1, 2, 3 ]
[ head | tail ]
[ first, second | tail ]
Elixir Syntax: Atom
:atom
:“with spaces”
Elixir Syntax: Binary
“Elixir”
<<“Elixir”>>
<< 69, 108, 105, 120, 105, 114 >>
Elixir Syntax: Character List
‘Elixir’
[ ?E, ?l, ?i, ?x, ?i, ?r ]
[ 69, 108, 105, 120, 105, 114 ]
Elixir Syntax: Range
1..100
10..0
-10..10
Elixir Syntax: Pipeline
IO.puts(“Hello world!”)
“Hello world!” |> IO.puts()
!
IO.puts(String.upcase(“Elixir”))
“Elixir” |> String.upcase() |> IO.puts()
Elixir Syntax: Regex
~r“^[A-Z]$”
“101010” =~ ~r“^[01]+$”
Elixir Syntax: Operators
+ - * / ! = == === != !== > >= < <=
and or xor not
&& ||
[ 1, 2, 3 ] ++ [ 4, 5, 6 ]
[ 1, 2, 3 ] -- [ 2 ]
“Hello ” <> “World!”
Elixir Syntax: Fn
fn (x) -> x * x end
&(&1 * &1)
!
fn (x, y) -> x + y * 2 end
&(&1 + &2 * 2)
Elixir Syntax:
Modules and Functions
defmodule Demo do
def say_hello() do
IO.puts(“Hello”)
end
def say_goodbye(), do: IO.puts(“Goodbye”)
defp private_function(), do: “Top Secret”
end
Pattern Matching
“=” operator does not mean “assign”
It’s the matching operator
Think of “=” in terms of math
Pattern Matching
x = 42
[ a, b, c ] = [ 1, 2, 3 ]
[ d, d, e ] = [ 4, 4, 5 ]
{ ^x, y } = { 42, 99 }
Pattern Matching
{ :ok, data } = File.read(“Demo.txt”)
{ :error, reason } = File.read(“Bogus.txt”)
{ a, b, _ } = Demo.do_something()
Pattern Matching
def sum(list), do: _sum(list, 0)
defp _sum([], total), do: total
defp _sum([ head | tail ], total) do
_sum(tail, head + total)
end
Pattern Matching
fn (x) when rem(x, 15) == 0 -> “FizzBuzz”
(x) when rem(x, 3) == 0 -> “Fizz”
(x) when rem(x, 5) == 0 -> “Buzz”
(x) -> x
end
Pattern Matching
<< number::[ bitstring, size(16) ],
“ ”,
word::[ bitstring, size(48) ] >> =
“42 Elixir”
PID
Process ID
Returned from spawn and spawn_link
Transfer messages with send and receive
PID: spawn
pid = spawn(fn -> do_something() end)
pid = spawn(Demo, :do_something, [])
pid = spawn(&Demo.do_something/0)
pid = spawn_link(fn -> 1 / 0 end)
PID: send
send(pid, 42)
send(pid, { self, :something })
send(pid, { self, fn (x) -> x * x end })
PID: receive
receive do
{ from, :something } ->
send(from, { self, do_something() }
{ :EXIT, from, reason } ->

IO.puts(“#{from} died by #{reason}”)
after 60 * 1000 ->
:timeout
end
Questions?
Demo
Want to Learn More?
Elixir Lang
Elixir Cheat Sheet
Programming Elixir
Programming Erlang
Want to Learn More?
!
Productivity Gains In Erlang
Joe Armstrong
Evan Miller
Russel Dillin

More Related Content

PDF
Elixir Programming Language 101
PPTX
PROLOG: Database Manipulation In Prolog
PDF
cmake.pdf
PPTX
Homomorphic encryption
PDF
String Matching with Finite Automata and Knuth Morris Pratt Algorithm
PDF
Python testing using mock and pytest
PPTX
UNIX_Process Control_Module3.pptx
PDF
jQuery Effects
Elixir Programming Language 101
PROLOG: Database Manipulation In Prolog
cmake.pdf
Homomorphic encryption
String Matching with Finite Automata and Knuth Morris Pratt Algorithm
Python testing using mock and pytest
UNIX_Process Control_Module3.pptx
jQuery Effects

Viewers also liked (20)

PPT
Elixir Consulting Profile
PPTX
Growing ELIXIR-UK
PPTX
Enfermedades raras
PPTX
Enfermedades RARAS
PDF
Functional Programming With Elixir
PPT
Las Enfermedades Raras
PDF
The ELIXIR UK training portal (TeSS) by Carole Goble
PDF
Introducción a las Enfermedades Raras - 27.03.2015
PDF
Coordinating European training and ELIXIR UK by Rita Hendricusdottir
PPTX
TeSS: ELIXIR Training Portal (Eubic Winter School 2017)
PDF
An introduction to Erlang and Elixir
PPT
Enfermedades raras II
PDF
PPT
La Estrategia en Enfermedades Raras del SNS
PDF
Enfermedades Raras y Crónicas
PDF
¿Qué son las Enfermedades Raras?
PPTX
Medición en salud
PPTX
Validacion de escalas de medicion en salud
PPT
Enfermedades raras i
PPT
Medicamentos huérfanos
Elixir Consulting Profile
Growing ELIXIR-UK
Enfermedades raras
Enfermedades RARAS
Functional Programming With Elixir
Las Enfermedades Raras
The ELIXIR UK training portal (TeSS) by Carole Goble
Introducción a las Enfermedades Raras - 27.03.2015
Coordinating European training and ELIXIR UK by Rita Hendricusdottir
TeSS: ELIXIR Training Portal (Eubic Winter School 2017)
An introduction to Erlang and Elixir
Enfermedades raras II
La Estrategia en Enfermedades Raras del SNS
Enfermedades Raras y Crónicas
¿Qué son las Enfermedades Raras?
Medición en salud
Validacion de escalas de medicion en salud
Enfermedades raras i
Medicamentos huérfanos
Ad

Similar to Elixir (20)

PDF
Introduction to Elixir
PPTX
PDF
What is the deal with Elixir?
PDF
Learning Elixir as a Rubyist
PDF
Elixir for aspiring Erlang developers
PDF
Elixir and OTP Apps introduction
ODP
Elixir basics
PDF
Elixir talk
PDF
My elixir helWo lorld
PPTX
Introduction to functional programming, with Elixir
PPTX
Elixir and OTP
PDF
外傷的Elixir
PPTX
Repeating History...On Purpose...with Elixir
ODP
Elixir otp-basics
PDF
Introduction to Elixir
PDF
Programming Elixir 13 Functional Concurrent Pragmatic Fun Dave Thomas
PDF
Elixir cheatsheet
PDF
Introducing Elixir and OTP at the Erlang BASH
PDF
Elixir and elm
PDF
Elixir for Rubyists
Introduction to Elixir
What is the deal with Elixir?
Learning Elixir as a Rubyist
Elixir for aspiring Erlang developers
Elixir and OTP Apps introduction
Elixir basics
Elixir talk
My elixir helWo lorld
Introduction to functional programming, with Elixir
Elixir and OTP
外傷的Elixir
Repeating History...On Purpose...with Elixir
Elixir otp-basics
Introduction to Elixir
Programming Elixir 13 Functional Concurrent Pragmatic Fun Dave Thomas
Elixir cheatsheet
Introducing Elixir and OTP at the Erlang BASH
Elixir and elm
Elixir for Rubyists
Ad

More from Robert Brown (14)

PDF
High level concurrency
PDF
Data Source Combinators
PDF
PDF
Reactive Cocoa
PDF
UIKit Dynamics
PDF
iOS State Preservation and Restoration
KEY
Anti-Patterns
KEY
Pragmatic blocks
KEY
Automatic Reference Counting
KEY
Grand Central Dispatch Design Patterns
KEY
Grand Central Dispatch
KEY
Mac/iOS Design Patterns
KEY
Core Data
KEY
Quick Look for iOS
High level concurrency
Data Source Combinators
Reactive Cocoa
UIKit Dynamics
iOS State Preservation and Restoration
Anti-Patterns
Pragmatic blocks
Automatic Reference Counting
Grand Central Dispatch Design Patterns
Grand Central Dispatch
Mac/iOS Design Patterns
Core Data
Quick Look for iOS

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation theory and applications.pdf
PPTX
Cloud computing and distributed systems.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Weekly Chronicles - August'25 Week I
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Spectral efficient network and resource selection model in 5G networks
Mobile App Security Testing_ A Comprehensive Guide.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
20250228 LYD VKU AI Blended-Learning.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
sap open course for s4hana steps from ECC to s4
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation theory and applications.pdf
Cloud computing and distributed systems.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Big Data Technologies - Introduction.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Programs and apps: productivity, graphics, security and other tools
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Weekly Chronicles - August'25 Week I

Elixir