SlideShare a Scribd company logo
elixir and OTP apps
introduction
content
● Elixir
– history
– iex
– types
– operators
– patter matching
– control flow structures
– functions
– modules
– recursion
– pipe operator
– comprehensions
– processeses
● OTP
– scalability
– fault tolerance
– concurrency
– history
– behaviours
– ets
– mix
● Workshop
– observer
● Resources
● Q&A
history
Elixir !!
I am your
Father !!
history
Joe designed erlang
in the 80s, when he
was an Ericsson
engineer, focusing on:
● Scalability
● Fault Tolerance
● Concurrency
history
● Moore’s law is almost
over, but it is too easy
to have multicore pc.
● Languages like
Python, Javascript or
Ruby can’t take
advantage of several
CPUs
history
Jose Valim tried to
improve Ruby on Rails
framework, but he could
not. Then, he discovered
how Erlang worked, but
he did not like the syntax,
therefore he decided to
create a new language
which will run in the
BEAM (Erlang Virtual
Machine).
iex
types
Elixir is a dynamic language, but of course it has types:
1 INTEGER
0X1F INTEGER
1.0 FLOAT
true BOOLEAN*
:atom ATOM
“string” STRING
[1, 2, 3] LIST
{1, 2, 3} TUPLE
%{id: 1, text: “example”} MAP
%{“id” => 1, “text”: “example”} MAP
pid(23, 32, 45) PID
nil *
operators
+ 2 + 2 = 4
- 3 – 2 = 1
* 2 * 2 = 4
/ 10 / 2 = 5
++ [1, 2, 3] ++ [4, 5, 6] = [1, 2, 3, 4, 5, 6]
<> "foo" <> "bar" = “foobar”
and true and false = false
or true or false = true
! !true = false
|| 1 || false = 1
&& nil && 13
== 1 == 1 = true
!= 1 != 1 = false
=== 1 === 1.0 = false
< 1 > 1 = false
> 1 < 1 = false
pattern matching
The pattern match operator is “=”
iex()> x = 1
1
iex()> {a, b, _} = {:ok, 2, 3}
{:ok, 2, 3}
iex()> [head | tail] = [1, 2, 3]
[1, 2, 3]
iex()> head
1
iex()> tail
[2, 3]
iex()> %{id: id} = %{id: 1, text: “example”}
%{id: 1, text: “example”}
iex()> id
1
iex()> x = 1
1
iex()> {a, b, _} = {:ok, 2, 3}
{:ok, 2, 3}
iex()> [head | tail] = [1, 2, 3]
[1, 2, 3]
iex()> head
1
iex()> tail
[2, 3]
iex()> %{id: id} = %{id: 1, text: “example”}
%{id: 1, text: “example”}
iex()> id
1
control flow structures
Case compares a value against many patterns until we find a matching one:
iex> x = {1, 2, 3}
{1, 2, 3}
iex> case x do
...> {2, 3, 4} → “First option”
...> {1, _, 3} → “Second Option”
...> _ → “It always matches”
...> end
“Second Option”
iex> x = {1, 7, 3}
{1, 2, 3}
iex()> case x do
...> {2, 3, 4} → “First option”
...> {1, _, 3} → “Second Option”
...> _ → “It always matches”
...> end
“Second Option”
iex> x = {1, 2, 3}
{1, 2, 3}
iex> case x do
...> {2, 3, 4} → “First option”
...> {1, _, 3} → “Second Option”
...> _ → “It always matches”
...> end
“Second Option”
iex> x = {1, 7, 3}
{1, 2, 3}
iex()> case x do
...> {2, 3, 4} → “First option”
...> {1, _, 3} → “Second Option”
...> _ → “It always matches”
...> end
“Second Option”
You can also use guards in your pattern matching: {1, z, 3} when z > 0 → “guards !!!”
control flow structures
Cond allows us to check different conditions until we find the first true.
iex> x = {1, 2, 3}
{1, 2, 3}
iex> cond do
...> x == {2, 3, 4} → “First option”
...> is_list(x) → “It is a list !!”
...> 2 + 5 == x → “ it is 7 !!”
...> true → “It always matches”
...> end
“It always matches”
iex> x = {1, 2, 3}
{1, 2, 3}
iex> cond do
...> x == {2, 3, 4} → “First option”
...> is_list(x) → “It is a list !!”
...> 2 + 5 == x → “ it is 7 !!”
...> true → “It always matches”
...> end
“It always matches”
control flow structures
If and unless are macros, but you can normally use them ;).
iex> x = {1, 2, 3}
{1, 2, 3}
iex> if {1, 2, 3} == x do
...> “Yes, it is”
...> else
...> “No, it is not”
...> end
“Yes, it is”
iex> unless {1, 2, 3} == x do
...> “No, it is not”
...> else
...> “Yes, it is”
...> end
“Yes, it is”
iex> x = {1, 2, 3}
{1, 2, 3}
iex> if {1, 2, 3} == x do
...> “Yes, it is”
...> else
...> “No, it is not”
...> end
“Yes, it is”
iex> unless {1, 2, 3} == x do
...> “No, it is not”
...> else
...> “Yes, it is”
...> end
“Yes, it is”
functions
Functions are first citizens in elixir. Don’t forget the “.” if it is an anonymous one.
iex> square = fn x → x*x end
Function<6.52032458/1 in :erl_eval.expr/5>
iex> square.(2)
4
iex>my_very_difficult_algo = fn x -> square.(x) end
#Function<6.52032458/1 in :erl_eval.expr/5>
iex> my_very_difficult_algo.(2)
4
iex> square = fn x → x*x end
Function<6.52032458/1 in :erl_eval.expr/5>
iex> square.(2)
4
iex>my_very_difficult_algo = fn x -> square.(x) end
#Function<6.52032458/1 in :erl_eval.expr/5>
iex> my_very_difficult_algo.(2)
4
modules
The functions are grouped in Modules.
iex> defmodule MyCalculator do
...> def square(x) do
...> x * x
...> end
...> end
{:module, MyCalculator,
<<70, 79, 82, 49, 0, 0, 4, 212, 66, 69, 65, 77, 69,
120, 68, 99, 0, 0, 0, 147,
131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105,
114, 95, 100, 111, 99, 115,
95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:square,
1}}
iex> MyCalculator.square(2)
4
iex> defmodule MyCalculator do
...> def square(x) do
...> x * x
...> end
...> end
{:module, MyCalculator,
<<70, 79, 82, 49, 0, 0, 4, 212, 66, 69, 65, 77, 69,
120, 68, 99, 0, 0, 0, 147,
131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105,
114, 95, 100, 111, 99, 115,
95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:square,
1}}
iex> MyCalculator.square(2)
4
modules
Elixir has a lot of standard modules that you will take advantage of them.
● Enum
● List
● Map
● Stream
● String
● Integer
● Process
● ...
modules
But Elixir works in the BEAM, so we can also use all the standard modules of Erlang.
● :os
● :calendar
● :rand
● :ets
● :crypto
● :global
● ...
recursion
How are we going to code my things if I don’t have loops?
iex> defmodule Fib do
...> def calculate(x), do: fib(x)
...> defp fib(1), do: 1
...> defp fib(2), do: 1
...> defp fib(x), do: fib(x - 1) + fib(x - 2)
...> end
{:module, Fib,
<<70, 79, 82, 49, 0, 0, 6, 20, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 163,
131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99,
115,
95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:fib, 4}}
iex> Fib.calculate(7)
13
iex> defmodule Fib do
...> def calculate(x), do: fib(x)
...> defp fib(1), do: 1
...> defp fib(2), do: 1
...> defp fib(x), do: fib(x - 1) + fib(x - 2)
...> end
{:module, Fib,
<<70, 79, 82, 49, 0, 0, 6, 20, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 163,
131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99,
115,
95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:fib, 4}}
iex> Fib.calculate(7)
13
Processes
Elixir (and Erlang)
follows the actor
model paradigm.
● Every process (Erlang
process) has his own
mailbox and it
communicates using
messages
Processes
Self communication !!
iex> Process.send(self(), “Hello from Process.send()”, [])
iex> send(self(), “Hello send()”)
iex> receive do
...> msg → msg
...> end
"Hello from Process.send()"
iex> receive do
...> msg → msg
...> end
"Hello from send()"
iex> Process.send(self(), “Hello from Process.send()”, [])
iex> send(self(), “Hello send()”)
iex> receive do
...> msg → msg
...> end
"Hello from Process.send()"
iex> receive do
...> msg → msg
...> end
"Hello from send()"
Processes
Communication from outside !!
iex> spawn(fn -> send(parent, {:hello, self()}) end)
#PID<0.48.0>
iex> receive do
...> {:hello, pid} -> "Got hello from #{inspect pid}"
...> end
Got hello from #PID<0.48.0>
iex> spawn(fn -> send(parent, {:hello, self()}) end)
#PID<0.48.0>
iex> receive do
...> {:hello, pid} -> "Got hello from #{inspect pid}"
...> end
Got hello from #PID<0.48.0>
Processes
I highly recommend to use Task !!
iex> Task.start(fn -> send(parent, {:hello, self()}) end)
{:ok, #PID<0.48.0>}
iex> receive do
...> {:hello, pid} -> "Got hello from #{inspect pid}"
...> end
Got hello from #PID<0.48.0>
iex> task = Task.async(fn -> 2 + 2 end)
%Task{owner: #PID<0.80.0>, pid: #PID<0.82.0>, ref:
#Reference<0.0.1.211>}
iex> middle_sum = 3 + 5
8
iex> result = middle_sum + Task.await(task)
12
iex> Task.start(fn -> send(parent, {:hello, self()}) end)
{:ok, #PID<0.48.0>}
iex> receive do
...> {:hello, pid} -> "Got hello from #{inspect pid}"
...> end
Got hello from #PID<0.48.0>
iex> task = Task.async(fn -> 2 + 2 end)
%Task{owner: #PID<0.80.0>, pid: #PID<0.82.0>, ref:
#Reference<0.0.1.211>}
iex> middle_sum = 3 + 5
8
iex> result = middle_sum + Task.await(task)
12
processes
● Linked Processes: If one process dies, the other dies as well
●
Monitored Process: If a monitored process dies, the monitor process will receive a
notification.
● Linking: You can start a process with the function start_link() instead of start or just use
Process.link(pid) from one process indicating the pid of the other process.
● Monitoring: Execute Process.monitor(pid) from one process indicating the pid of the other process.
scalability
We have already talk
about vertical
scalability, but I love
this gift
Vertical scalability
means: “If you have a
‘bigger’ server, your SW
will take advantage of
it.”
scalability
Vertical scalability can
reach some
limitations, but we
need to scale, the
solution can be
horizontal scalability,
or adding more
servers. It also
implies distribution.
fault tolerance
The only SW that has not bug is the SW that has
never been executed.
SWs which run indefinitely have to be fault tolerance.
The only SW that has no bug is the SW that has
never been executed.
SWs which run indefinitely have to be fault tolerance.
Really good
Exampe !!
concurrency
Although we are able
to scale in order to
use more CPU cores,
sure that you will
have more tasks than
cores, so you need
concurrency.
history
Having all this things in
mind, the Ericsson guys
developed OTP which
is a collection of useful
middle-ware, libraries,
and tools written in
Erlang programming
language.
Ericsson OTP Team
Twitter: @erlang_org
behaviours
Behaviours in Elixir (and Erlang) are a way to separate and abstract the generic part
of a component (which becomes the behaviour module) from the specific part (which
becomes the callback module).
The following are provided by OTP (and some new ones from Elixir):
● Supervisor
● GenServer
●
GenStage
● Agent
● GenEvent
behaviours
A Supervisor is a process which supervises other
processes, which are referred to as child processes. (Do
you remember the linking/monitoring actions?)
# Import helpers for defining supervisors
import Supervisor.Spec
# Supervise the Stack server which will be started with
# a single argument [:hello] and the default registered
# name of MyStack.
children = [
worker(MyProcess, [[:hello], [name: :my_process]])
]
# Start the supervisor with our child
{:ok, pid} = Supervisor.start_link(children, strategy:
:one_for_one)
# Import helpers for defining supervisors
import Supervisor.Spec
# Supervise the Stack server which will be started with
# a single argument [:hello] and the default registered
# name of MyStack.
children = [
worker(MyProcess, [[:hello], [name: :my_process]])
]
# Start the supervisor with our child
{:ok, pid} = Supervisor.start_link(children, strategy:
:one_for_one)
behaviours
A Supervisor can
supervises a worker
(Elixir Process) or
other supervisors.
behaviours
A GenServer is a process like any other Elixir process and it can be used to
keep state, execute code asynchronously and other interesting stuffs providing
a standard set of interface functions and include functionality for tracing and
error reporting. It will also fit into a supervision tree.
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
# 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
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
# 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
behaviours
● GenStage provides the interface to create a distributed set
of producer, producer-consumer and consumer processes
with back-pressure mechanism. It is based on GenServer.
Producer
Consumer
Consumer
Consumer
Consumer
Prod-ConsProd-Cons
Prod-Cons
ets
ETS is a cache system which allows us to
store any Elixir term in an in-memory table.
iex> table = :ets.new(:my_table, [:named_table])
:my_table
iex> :ets.insert(table, {"foo", self})
true
iex> :ets.lookup(table, "foo")
[{"foo", #PID<0.80.0>}]
iex> :ets.delete(table, "foo")
true
iex> table = :ets.new(:my_table, [:named_table])
:my_table
iex> :ets.insert(table, {"foo", self})
true
iex> :ets.lookup(table, "foo")
[{"foo", #PID<0.80.0>}]
iex> :ets.delete(table, "foo")
true
mix
Mix is a build
tool that ships
with Elixir that
provides tasks
for creating,
compiling,
testing your
application,
managing its
dependencies
and much more
$> mix new my_project --sup
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/my_project.ex
* creating test
* creating test/test_helper.exs
* creating test/my_project_test.exs
Your Mix project was created
successfully.
You can use "mix" to compile it, test
it, and more:
cd my_project
mix test
Run "mix help" for more commands.
$> mix new my_project --sup
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/my_project.ex
* creating test
* creating test/test_helper.exs
* creating test/my_project_test.exs
Your Mix project was created
successfully.
You can use "mix" to compile it, test
it, and more:
cd my_project
mix test
Run "mix help" for more commands.
$> cat my_project/mix.exs
defmodule MyProject.Mixfile do
use Mix.Project
def project do
[app: :my_project,
version: "0.1.0",
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps()]
end
# Configuration for the OTP application
#
# Type "mix help compile.app" for more information
def application do
[applications: [:logger],
mod: {MyProject, []}]
end
# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag:
"0.1.0"}
#
# Type "mix help deps" for more examples and options
defp deps do
[]
end
end
$> cat my_project/mix.exs
defmodule MyProject.Mixfile do
use Mix.Project
def project do
[app: :my_project,
version: "0.1.0",
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps()]
end
# Configuration for the OTP application
#
# Type "mix help compile.app" for more information
def application do
[applications: [:logger],
mod: {MyProject, []}]
end
# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag:
"0.1.0"}
#
# Type "mix help deps" for more examples and options
defp deps do
[]
end
end
Workshop
observer
Resources
resources
● http://elixir-lang.org/
● http://elixir-lang.org/docs/stable/elixir/
● http://erlang.org/doc/reference_manual/
● https://github.com/elixir-lang/elixir
● https://elixir-slackin.herokuapp.com/
● https://www.elixirforum.com/
resources
Q&A

More Related Content

What's hot

The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 29 of 185
The Ring programming language version 1.5.4 book - Part 29 of 185The Ring programming language version 1.5.4 book - Part 29 of 185
The Ring programming language version 1.5.4 book - Part 29 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189
Mahmoud Samir Fayed
 
Play image
Play imagePlay image
Play image
Fardian Syah
 
The Ring programming language version 1.4 book - Part 7 of 30
The Ring programming language version 1.4 book - Part 7 of 30The Ring programming language version 1.4 book - Part 7 of 30
The Ring programming language version 1.4 book - Part 7 of 30
Mahmoud Samir Fayed
 
Developing Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersDeveloping Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginners
Saeid Zebardast
 
The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84
Mahmoud Samir Fayed
 
The art of reverse engineering flash exploits
The art of reverse engineering flash exploitsThe art of reverse engineering flash exploits
The art of reverse engineering flash exploits
Priyanka Aash
 
The Ring programming language version 1.9 book - Part 36 of 210
The Ring programming language version 1.9 book - Part 36 of 210The Ring programming language version 1.9 book - Part 36 of 210
The Ring programming language version 1.9 book - Part 36 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 27 of 184
The Ring programming language version 1.5.3 book - Part 27 of 184The Ring programming language version 1.5.3 book - Part 27 of 184
The Ring programming language version 1.5.3 book - Part 27 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.4.1 book - Part 8 of 31
The Ring programming language version 1.4.1 book - Part 8 of 31The Ring programming language version 1.4.1 book - Part 8 of 31
The Ring programming language version 1.4.1 book - Part 8 of 31
Mahmoud Samir Fayed
 
The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31
Mahmoud Samir Fayed
 
Recentrer l'intelligence artificielle sur les connaissances
Recentrer l'intelligence artificielle sur les connaissancesRecentrer l'intelligence artificielle sur les connaissances
Recentrer l'intelligence artificielle sur les connaissances
Mathieu d'Aquin
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
UC San Diego
 
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
Matt Harrison
 
I regret nothing
I regret nothingI regret nothing
I regret nothing
Łukasz Langa
 
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
Matt Harrison
 
The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84
Mahmoud Samir Fayed
 

What's hot (19)

The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180
 
The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196
 
The Ring programming language version 1.5.4 book - Part 29 of 185
The Ring programming language version 1.5.4 book - Part 29 of 185The Ring programming language version 1.5.4 book - Part 29 of 185
The Ring programming language version 1.5.4 book - Part 29 of 185
 
The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189
 
Play image
Play imagePlay image
Play image
 
The Ring programming language version 1.4 book - Part 7 of 30
The Ring programming language version 1.4 book - Part 7 of 30The Ring programming language version 1.4 book - Part 7 of 30
The Ring programming language version 1.4 book - Part 7 of 30
 
Developing Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersDeveloping Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginners
 
The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84
 
The art of reverse engineering flash exploits
The art of reverse engineering flash exploitsThe art of reverse engineering flash exploits
The art of reverse engineering flash exploits
 
The Ring programming language version 1.9 book - Part 36 of 210
The Ring programming language version 1.9 book - Part 36 of 210The Ring programming language version 1.9 book - Part 36 of 210
The Ring programming language version 1.9 book - Part 36 of 210
 
The Ring programming language version 1.5.3 book - Part 27 of 184
The Ring programming language version 1.5.3 book - Part 27 of 184The Ring programming language version 1.5.3 book - Part 27 of 184
The Ring programming language version 1.5.3 book - Part 27 of 184
 
The Ring programming language version 1.4.1 book - Part 8 of 31
The Ring programming language version 1.4.1 book - Part 8 of 31The Ring programming language version 1.4.1 book - Part 8 of 31
The Ring programming language version 1.4.1 book - Part 8 of 31
 
The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31
 
Recentrer l'intelligence artificielle sur les connaissances
Recentrer l'intelligence artificielle sur les connaissancesRecentrer l'intelligence artificielle sur les connaissances
Recentrer l'intelligence artificielle sur les connaissances
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
 
I regret nothing
I regret nothingI regret nothing
I regret nothing
 
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
 
The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84
 

Viewers also liked

Manchester Social Media Surgery Events: an Introduction
Manchester Social Media Surgery Events: an IntroductionManchester Social Media Surgery Events: an Introduction
Manchester Social Media Surgery Events: an Introduction
Chi-chi Ekweozor
 
The Web Is Your Oyster
The Web Is Your OysterThe Web Is Your Oyster
The Web Is Your Oyster
Chi-chi Ekweozor
 
otp-sms-two-factor-authentication
otp-sms-two-factor-authenticationotp-sms-two-factor-authentication
otp-sms-two-factor-authentication
Nikos Ioannou 123RF.com
 
Bootstrap |> Elixir - Easy fun for busy developers
Bootstrap |> Elixir - Easy fun for busy developersBootstrap |> Elixir - Easy fun for busy developers
Bootstrap |> Elixir - Easy fun for busy developers
David Schmitz
 
Flowex: Flow-Based Programming with Elixir GenStage - Anton Mishchuk
Flowex: Flow-Based Programming with Elixir GenStage - Anton MishchukFlowex: Flow-Based Programming with Elixir GenStage - Anton Mishchuk
Flowex: Flow-Based Programming with Elixir GenStage - Anton Mishchuk
Elixir Club
 
Bottleneck in Elixir Application - Alexey Osipenko
 Bottleneck in Elixir Application - Alexey Osipenko  Bottleneck in Elixir Application - Alexey Osipenko
Bottleneck in Elixir Application - Alexey Osipenko
Elixir Club
 
Concurrency in Elixir with OTP
Concurrency in Elixir with OTPConcurrency in Elixir with OTP
Concurrency in Elixir with OTP
Justin Reese
 
Phoenix Framework
Phoenix FrameworkPhoenix Framework
Phoenix Framework
Shigeru Kondoh
 
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
Greg Vaughn
 
Elixir and OTP
Elixir and OTPElixir and OTP
Elixir and OTP
Pedro Medeiros
 
Build Your Own Real-Time Web Service with Elixir Phoenix
Build Your Own Real-Time Web Service with Elixir PhoenixBuild Your Own Real-Time Web Service with Elixir Phoenix
Build Your Own Real-Time Web Service with Elixir Phoenix
Chi-chi Ekweozor
 
Hello elixir (and otp)
Hello elixir (and otp)Hello elixir (and otp)
Hello elixir (and otp)
Abel Muíño
 
Real World Elixir Deployment
Real World Elixir DeploymentReal World Elixir Deployment
Real World Elixir Deployment
Pete Gamache
 
Elixir – Peeking into Elixir's Processes, OTP and Supervisors
Elixir – Peeking into Elixir's Processes, OTP and SupervisorsElixir – Peeking into Elixir's Processes, OTP and Supervisors
Elixir – Peeking into Elixir's Processes, OTP and Supervisors
Benjamin Tan
 
Learn Elixir at Manchester Lambda Lounge
Learn Elixir at Manchester Lambda LoungeLearn Elixir at Manchester Lambda Lounge
Learn Elixir at Manchester Lambda Lounge
Chi-chi Ekweozor
 

Viewers also liked (15)

Manchester Social Media Surgery Events: an Introduction
Manchester Social Media Surgery Events: an IntroductionManchester Social Media Surgery Events: an Introduction
Manchester Social Media Surgery Events: an Introduction
 
The Web Is Your Oyster
The Web Is Your OysterThe Web Is Your Oyster
The Web Is Your Oyster
 
otp-sms-two-factor-authentication
otp-sms-two-factor-authenticationotp-sms-two-factor-authentication
otp-sms-two-factor-authentication
 
Bootstrap |> Elixir - Easy fun for busy developers
Bootstrap |> Elixir - Easy fun for busy developersBootstrap |> Elixir - Easy fun for busy developers
Bootstrap |> Elixir - Easy fun for busy developers
 
Flowex: Flow-Based Programming with Elixir GenStage - Anton Mishchuk
Flowex: Flow-Based Programming with Elixir GenStage - Anton MishchukFlowex: Flow-Based Programming with Elixir GenStage - Anton Mishchuk
Flowex: Flow-Based Programming with Elixir GenStage - Anton Mishchuk
 
Bottleneck in Elixir Application - Alexey Osipenko
 Bottleneck in Elixir Application - Alexey Osipenko  Bottleneck in Elixir Application - Alexey Osipenko
Bottleneck in Elixir Application - Alexey Osipenko
 
Concurrency in Elixir with OTP
Concurrency in Elixir with OTPConcurrency in Elixir with OTP
Concurrency in Elixir with OTP
 
Phoenix Framework
Phoenix FrameworkPhoenix Framework
Phoenix Framework
 
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
 
Elixir and OTP
Elixir and OTPElixir and OTP
Elixir and OTP
 
Build Your Own Real-Time Web Service with Elixir Phoenix
Build Your Own Real-Time Web Service with Elixir PhoenixBuild Your Own Real-Time Web Service with Elixir Phoenix
Build Your Own Real-Time Web Service with Elixir Phoenix
 
Hello elixir (and otp)
Hello elixir (and otp)Hello elixir (and otp)
Hello elixir (and otp)
 
Real World Elixir Deployment
Real World Elixir DeploymentReal World Elixir Deployment
Real World Elixir Deployment
 
Elixir – Peeking into Elixir's Processes, OTP and Supervisors
Elixir – Peeking into Elixir's Processes, OTP and SupervisorsElixir – Peeking into Elixir's Processes, OTP and Supervisors
Elixir – Peeking into Elixir's Processes, OTP and Supervisors
 
Learn Elixir at Manchester Lambda Lounge
Learn Elixir at Manchester Lambda LoungeLearn Elixir at Manchester Lambda Lounge
Learn Elixir at Manchester Lambda Lounge
 

Similar to Elixir and OTP Apps introduction

Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
Svet Ivantchev
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
Diacode
 
Haskell
HaskellHaskell
COSCUP: Introduction to Julia
COSCUP: Introduction to JuliaCOSCUP: Introduction to Julia
COSCUP: Introduction to Julia
岳華 杜
 
7li7w devcon5
7li7w devcon57li7w devcon5
7li7w devcon5
Kerry Buckley
 
Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
Akash Pandey
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potter
distributed matters
 
01_introduction_lab.pdf
01_introduction_lab.pdf01_introduction_lab.pdf
01_introduction_lab.pdf
zehiwot hone
 
Tutorialmatlab kurniawan.s
Tutorialmatlab kurniawan.sTutorialmatlab kurniawan.s
Tutorialmatlab kurniawan.s
Kurniawan susanto
 
Tutorial matlab
Tutorial matlabTutorial matlab
Tutorial matlab
Kavin Patel
 
ClojurianからみたElixir
ClojurianからみたElixirClojurianからみたElixir
ClojurianからみたElixir
Kent Ohashi
 
Ruby basics
Ruby basicsRuby basics
Ruby basics
Aditya Tiwari
 
Enter The Matrix
Enter The MatrixEnter The Matrix
Enter The Matrix
Mike Anderson
 
Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)
Cdiscount
 
Introducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASHIntroducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASH
devbash
 
PyCon 2010 SQLAlchemy tutorial
PyCon 2010 SQLAlchemy tutorialPyCon 2010 SQLAlchemy tutorial
PyCon 2010 SQLAlchemy tutorial
jbellis
 
Elixir in a nutshell - Fundamental Concepts
Elixir in a nutshell - Fundamental ConceptsElixir in a nutshell - Fundamental Concepts
Elixir in a nutshell - Fundamental Concepts
Héla Ben Khalfallah
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data Science
Mike Anderson
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012
Shani729
 
Elixir cheatsheet
Elixir cheatsheetElixir cheatsheet
Elixir cheatsheet
Héla Ben Khalfallah
 

Similar to Elixir and OTP Apps introduction (20)

Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
 
Haskell
HaskellHaskell
Haskell
 
COSCUP: Introduction to Julia
COSCUP: Introduction to JuliaCOSCUP: Introduction to Julia
COSCUP: Introduction to Julia
 
7li7w devcon5
7li7w devcon57li7w devcon5
7li7w devcon5
 
Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potter
 
01_introduction_lab.pdf
01_introduction_lab.pdf01_introduction_lab.pdf
01_introduction_lab.pdf
 
Tutorialmatlab kurniawan.s
Tutorialmatlab kurniawan.sTutorialmatlab kurniawan.s
Tutorialmatlab kurniawan.s
 
Tutorial matlab
Tutorial matlabTutorial matlab
Tutorial matlab
 
ClojurianからみたElixir
ClojurianからみたElixirClojurianからみたElixir
ClojurianからみたElixir
 
Ruby basics
Ruby basicsRuby basics
Ruby basics
 
Enter The Matrix
Enter The MatrixEnter The Matrix
Enter The Matrix
 
Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)
 
Introducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASHIntroducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASH
 
PyCon 2010 SQLAlchemy tutorial
PyCon 2010 SQLAlchemy tutorialPyCon 2010 SQLAlchemy tutorial
PyCon 2010 SQLAlchemy tutorial
 
Elixir in a nutshell - Fundamental Concepts
Elixir in a nutshell - Fundamental ConceptsElixir in a nutshell - Fundamental Concepts
Elixir in a nutshell - Fundamental Concepts
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data Science
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012
 
Elixir cheatsheet
Elixir cheatsheetElixir cheatsheet
Elixir cheatsheet
 

Recently uploaded

Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 

Recently uploaded (20)

Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 

Elixir and OTP Apps introduction

  • 1. elixir and OTP apps introduction
  • 2. content ● Elixir – history – iex – types – operators – patter matching – control flow structures – functions – modules – recursion – pipe operator – comprehensions – processeses ● OTP – scalability – fault tolerance – concurrency – history – behaviours – ets – mix ● Workshop – observer ● Resources ● Q&A
  • 3.
  • 4. history Elixir !! I am your Father !!
  • 5. history Joe designed erlang in the 80s, when he was an Ericsson engineer, focusing on: ● Scalability ● Fault Tolerance ● Concurrency
  • 6. history ● Moore’s law is almost over, but it is too easy to have multicore pc. ● Languages like Python, Javascript or Ruby can’t take advantage of several CPUs
  • 7. history Jose Valim tried to improve Ruby on Rails framework, but he could not. Then, he discovered how Erlang worked, but he did not like the syntax, therefore he decided to create a new language which will run in the BEAM (Erlang Virtual Machine).
  • 8. iex
  • 9. types Elixir is a dynamic language, but of course it has types: 1 INTEGER 0X1F INTEGER 1.0 FLOAT true BOOLEAN* :atom ATOM “string” STRING [1, 2, 3] LIST {1, 2, 3} TUPLE %{id: 1, text: “example”} MAP %{“id” => 1, “text”: “example”} MAP pid(23, 32, 45) PID nil *
  • 10. operators + 2 + 2 = 4 - 3 – 2 = 1 * 2 * 2 = 4 / 10 / 2 = 5 ++ [1, 2, 3] ++ [4, 5, 6] = [1, 2, 3, 4, 5, 6] <> "foo" <> "bar" = “foobar” and true and false = false or true or false = true ! !true = false || 1 || false = 1 && nil && 13 == 1 == 1 = true != 1 != 1 = false === 1 === 1.0 = false < 1 > 1 = false > 1 < 1 = false
  • 11. pattern matching The pattern match operator is “=” iex()> x = 1 1 iex()> {a, b, _} = {:ok, 2, 3} {:ok, 2, 3} iex()> [head | tail] = [1, 2, 3] [1, 2, 3] iex()> head 1 iex()> tail [2, 3] iex()> %{id: id} = %{id: 1, text: “example”} %{id: 1, text: “example”} iex()> id 1 iex()> x = 1 1 iex()> {a, b, _} = {:ok, 2, 3} {:ok, 2, 3} iex()> [head | tail] = [1, 2, 3] [1, 2, 3] iex()> head 1 iex()> tail [2, 3] iex()> %{id: id} = %{id: 1, text: “example”} %{id: 1, text: “example”} iex()> id 1
  • 12. control flow structures Case compares a value against many patterns until we find a matching one: iex> x = {1, 2, 3} {1, 2, 3} iex> case x do ...> {2, 3, 4} → “First option” ...> {1, _, 3} → “Second Option” ...> _ → “It always matches” ...> end “Second Option” iex> x = {1, 7, 3} {1, 2, 3} iex()> case x do ...> {2, 3, 4} → “First option” ...> {1, _, 3} → “Second Option” ...> _ → “It always matches” ...> end “Second Option” iex> x = {1, 2, 3} {1, 2, 3} iex> case x do ...> {2, 3, 4} → “First option” ...> {1, _, 3} → “Second Option” ...> _ → “It always matches” ...> end “Second Option” iex> x = {1, 7, 3} {1, 2, 3} iex()> case x do ...> {2, 3, 4} → “First option” ...> {1, _, 3} → “Second Option” ...> _ → “It always matches” ...> end “Second Option” You can also use guards in your pattern matching: {1, z, 3} when z > 0 → “guards !!!”
  • 13. control flow structures Cond allows us to check different conditions until we find the first true. iex> x = {1, 2, 3} {1, 2, 3} iex> cond do ...> x == {2, 3, 4} → “First option” ...> is_list(x) → “It is a list !!” ...> 2 + 5 == x → “ it is 7 !!” ...> true → “It always matches” ...> end “It always matches” iex> x = {1, 2, 3} {1, 2, 3} iex> cond do ...> x == {2, 3, 4} → “First option” ...> is_list(x) → “It is a list !!” ...> 2 + 5 == x → “ it is 7 !!” ...> true → “It always matches” ...> end “It always matches”
  • 14. control flow structures If and unless are macros, but you can normally use them ;). iex> x = {1, 2, 3} {1, 2, 3} iex> if {1, 2, 3} == x do ...> “Yes, it is” ...> else ...> “No, it is not” ...> end “Yes, it is” iex> unless {1, 2, 3} == x do ...> “No, it is not” ...> else ...> “Yes, it is” ...> end “Yes, it is” iex> x = {1, 2, 3} {1, 2, 3} iex> if {1, 2, 3} == x do ...> “Yes, it is” ...> else ...> “No, it is not” ...> end “Yes, it is” iex> unless {1, 2, 3} == x do ...> “No, it is not” ...> else ...> “Yes, it is” ...> end “Yes, it is”
  • 15. functions Functions are first citizens in elixir. Don’t forget the “.” if it is an anonymous one. iex> square = fn x → x*x end Function<6.52032458/1 in :erl_eval.expr/5> iex> square.(2) 4 iex>my_very_difficult_algo = fn x -> square.(x) end #Function<6.52032458/1 in :erl_eval.expr/5> iex> my_very_difficult_algo.(2) 4 iex> square = fn x → x*x end Function<6.52032458/1 in :erl_eval.expr/5> iex> square.(2) 4 iex>my_very_difficult_algo = fn x -> square.(x) end #Function<6.52032458/1 in :erl_eval.expr/5> iex> my_very_difficult_algo.(2) 4
  • 16. modules The functions are grouped in Modules. iex> defmodule MyCalculator do ...> def square(x) do ...> x * x ...> end ...> end {:module, MyCalculator, <<70, 79, 82, 49, 0, 0, 4, 212, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 147, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:square, 1}} iex> MyCalculator.square(2) 4 iex> defmodule MyCalculator do ...> def square(x) do ...> x * x ...> end ...> end {:module, MyCalculator, <<70, 79, 82, 49, 0, 0, 4, 212, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 147, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:square, 1}} iex> MyCalculator.square(2) 4
  • 17. modules Elixir has a lot of standard modules that you will take advantage of them. ● Enum ● List ● Map ● Stream ● String ● Integer ● Process ● ...
  • 18. modules But Elixir works in the BEAM, so we can also use all the standard modules of Erlang. ● :os ● :calendar ● :rand ● :ets ● :crypto ● :global ● ...
  • 19. recursion How are we going to code my things if I don’t have loops? iex> defmodule Fib do ...> def calculate(x), do: fib(x) ...> defp fib(1), do: 1 ...> defp fib(2), do: 1 ...> defp fib(x), do: fib(x - 1) + fib(x - 2) ...> end {:module, Fib, <<70, 79, 82, 49, 0, 0, 6, 20, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 163, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:fib, 4}} iex> Fib.calculate(7) 13 iex> defmodule Fib do ...> def calculate(x), do: fib(x) ...> defp fib(1), do: 1 ...> defp fib(2), do: 1 ...> defp fib(x), do: fib(x - 1) + fib(x - 2) ...> end {:module, Fib, <<70, 79, 82, 49, 0, 0, 6, 20, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 163, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:fib, 4}} iex> Fib.calculate(7) 13
  • 20. Processes Elixir (and Erlang) follows the actor model paradigm. ● Every process (Erlang process) has his own mailbox and it communicates using messages
  • 21. Processes Self communication !! iex> Process.send(self(), “Hello from Process.send()”, []) iex> send(self(), “Hello send()”) iex> receive do ...> msg → msg ...> end "Hello from Process.send()" iex> receive do ...> msg → msg ...> end "Hello from send()" iex> Process.send(self(), “Hello from Process.send()”, []) iex> send(self(), “Hello send()”) iex> receive do ...> msg → msg ...> end "Hello from Process.send()" iex> receive do ...> msg → msg ...> end "Hello from send()"
  • 22. Processes Communication from outside !! iex> spawn(fn -> send(parent, {:hello, self()}) end) #PID<0.48.0> iex> receive do ...> {:hello, pid} -> "Got hello from #{inspect pid}" ...> end Got hello from #PID<0.48.0> iex> spawn(fn -> send(parent, {:hello, self()}) end) #PID<0.48.0> iex> receive do ...> {:hello, pid} -> "Got hello from #{inspect pid}" ...> end Got hello from #PID<0.48.0>
  • 23. Processes I highly recommend to use Task !! iex> Task.start(fn -> send(parent, {:hello, self()}) end) {:ok, #PID<0.48.0>} iex> receive do ...> {:hello, pid} -> "Got hello from #{inspect pid}" ...> end Got hello from #PID<0.48.0> iex> task = Task.async(fn -> 2 + 2 end) %Task{owner: #PID<0.80.0>, pid: #PID<0.82.0>, ref: #Reference<0.0.1.211>} iex> middle_sum = 3 + 5 8 iex> result = middle_sum + Task.await(task) 12 iex> Task.start(fn -> send(parent, {:hello, self()}) end) {:ok, #PID<0.48.0>} iex> receive do ...> {:hello, pid} -> "Got hello from #{inspect pid}" ...> end Got hello from #PID<0.48.0> iex> task = Task.async(fn -> 2 + 2 end) %Task{owner: #PID<0.80.0>, pid: #PID<0.82.0>, ref: #Reference<0.0.1.211>} iex> middle_sum = 3 + 5 8 iex> result = middle_sum + Task.await(task) 12
  • 24. processes ● Linked Processes: If one process dies, the other dies as well ● Monitored Process: If a monitored process dies, the monitor process will receive a notification. ● Linking: You can start a process with the function start_link() instead of start or just use Process.link(pid) from one process indicating the pid of the other process. ● Monitoring: Execute Process.monitor(pid) from one process indicating the pid of the other process.
  • 25.
  • 26. scalability We have already talk about vertical scalability, but I love this gift Vertical scalability means: “If you have a ‘bigger’ server, your SW will take advantage of it.”
  • 27. scalability Vertical scalability can reach some limitations, but we need to scale, the solution can be horizontal scalability, or adding more servers. It also implies distribution.
  • 28. fault tolerance The only SW that has not bug is the SW that has never been executed. SWs which run indefinitely have to be fault tolerance. The only SW that has no bug is the SW that has never been executed. SWs which run indefinitely have to be fault tolerance. Really good Exampe !!
  • 29. concurrency Although we are able to scale in order to use more CPU cores, sure that you will have more tasks than cores, so you need concurrency.
  • 30. history Having all this things in mind, the Ericsson guys developed OTP which is a collection of useful middle-ware, libraries, and tools written in Erlang programming language. Ericsson OTP Team Twitter: @erlang_org
  • 31. behaviours Behaviours in Elixir (and Erlang) are a way to separate and abstract the generic part of a component (which becomes the behaviour module) from the specific part (which becomes the callback module). The following are provided by OTP (and some new ones from Elixir): ● Supervisor ● GenServer ● GenStage ● Agent ● GenEvent
  • 32. behaviours A Supervisor is a process which supervises other processes, which are referred to as child processes. (Do you remember the linking/monitoring actions?) # Import helpers for defining supervisors import Supervisor.Spec # Supervise the Stack server which will be started with # a single argument [:hello] and the default registered # name of MyStack. children = [ worker(MyProcess, [[:hello], [name: :my_process]]) ] # Start the supervisor with our child {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one) # Import helpers for defining supervisors import Supervisor.Spec # Supervise the Stack server which will be started with # a single argument [:hello] and the default registered # name of MyStack. children = [ worker(MyProcess, [[:hello], [name: :my_process]]) ] # Start the supervisor with our child {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)
  • 33. behaviours A Supervisor can supervises a worker (Elixir Process) or other supervisors.
  • 34. behaviours A GenServer is a process like any other Elixir process and it can be used to keep state, execute code asynchronously and other interesting stuffs providing a standard set of interface functions and include functionality for tracing and error reporting. It will also fit into a supervision tree. 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 # 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 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 # 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
  • 35. behaviours ● GenStage provides the interface to create a distributed set of producer, producer-consumer and consumer processes with back-pressure mechanism. It is based on GenServer. Producer Consumer Consumer Consumer Consumer Prod-ConsProd-Cons Prod-Cons
  • 36. ets ETS is a cache system which allows us to store any Elixir term in an in-memory table. iex> table = :ets.new(:my_table, [:named_table]) :my_table iex> :ets.insert(table, {"foo", self}) true iex> :ets.lookup(table, "foo") [{"foo", #PID<0.80.0>}] iex> :ets.delete(table, "foo") true iex> table = :ets.new(:my_table, [:named_table]) :my_table iex> :ets.insert(table, {"foo", self}) true iex> :ets.lookup(table, "foo") [{"foo", #PID<0.80.0>}] iex> :ets.delete(table, "foo") true
  • 37. mix Mix is a build tool that ships with Elixir that provides tasks for creating, compiling, testing your application, managing its dependencies and much more $> mix new my_project --sup * creating README.md * creating .gitignore * creating mix.exs * creating config * creating config/config.exs * creating lib * creating lib/my_project.ex * creating test * creating test/test_helper.exs * creating test/my_project_test.exs Your Mix project was created successfully. You can use "mix" to compile it, test it, and more: cd my_project mix test Run "mix help" for more commands. $> mix new my_project --sup * creating README.md * creating .gitignore * creating mix.exs * creating config * creating config/config.exs * creating lib * creating lib/my_project.ex * creating test * creating test/test_helper.exs * creating test/my_project_test.exs Your Mix project was created successfully. You can use "mix" to compile it, test it, and more: cd my_project mix test Run "mix help" for more commands. $> cat my_project/mix.exs defmodule MyProject.Mixfile do use Mix.Project def project do [app: :my_project, version: "0.1.0", elixir: "~> 1.3", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, deps: deps()] end # Configuration for the OTP application # # Type "mix help compile.app" for more information def application do [applications: [:logger], mod: {MyProject, []}] end # Dependencies can be Hex packages: # # {:mydep, "~> 0.3.0"} # # Or git/path repositories: # # {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"} # # Type "mix help deps" for more examples and options defp deps do [] end end $> cat my_project/mix.exs defmodule MyProject.Mixfile do use Mix.Project def project do [app: :my_project, version: "0.1.0", elixir: "~> 1.3", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, deps: deps()] end # Configuration for the OTP application # # Type "mix help compile.app" for more information def application do [applications: [:logger], mod: {MyProject, []}] end # Dependencies can be Hex packages: # # {:mydep, "~> 0.3.0"} # # Or git/path repositories: # # {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"} # # Type "mix help deps" for more examples and options defp deps do [] end end
  • 41. resources ● http://elixir-lang.org/ ● http://elixir-lang.org/docs/stable/elixir/ ● http://erlang.org/doc/reference_manual/ ● https://github.com/elixir-lang/elixir ● https://elixir-slackin.herokuapp.com/ ● https://www.elixirforum.com/
  • 43. Q&A