Working with Elixir since 2014
Erlang
Some of its uses are in telecoms, banking, e-commerce, computer telephony and instant messaging. Erlang's runtime system has built-in support for concurrency, distribution and fault tolerance.
Elixir
Elixir leverages the Erlang VM, known for running low-latency, distributed and fault-tolerant systems, while also being successfully used in web development and the embedded software domain.
Phoenix
Phoenix provides high developer productivity and high application performance. It also has some interesting new twists like channels for implementing realtime features and pre-compiled templates for blazing speed.
phoenix liveview
LiveView powered applications are stateful on the server with bidrectional communication via WebSockets, offering a vastly simplified programming model compared to JavaScript alternatives.
Why you should use Elixir?
CONCURRENCY
Functional programming makes concurrency possible by preventing both race conditions (where two programs race to get the same value) and deadlocks, where one program is waiting indefinitely, for the other to write a value.
Fault tolerance
It provides built-in safety mechanisms that allow to work even when something goes wrong. Processes alert a failure to dependent processes, even on other servers.
Scalability
Elixir runs on Erlang VM, it is able to run applications on multiple nodes. We can make larger web and IoT applications that can be scaled over several different servers.
Strong developer community
There is an active user community where even highly qualified engineering are willing to help and share their knowledge.
Pattern matching
Different function signatures allow you to make much clearer intentions of how the code should behave in different cases. It helps make things concise and clean.
DoC & TesT
Elixir has built-in tests an documentation, without adding any 3rd-party library.
Debugging
Debugging is much easier when you don’t have global state. You can look at the arguments of a function, and you’ve got your state right there.
Easier to understand
Elixir is a functional programming language that is easy to read and easy to use
Some examples
Pipe Operator
submarine = Submarine.new({ position: 0 })
submarine.go_deep(100)
submarine.move(200)
submarine.fire()
submarine = Submarine.new(positon:0)
|> Submarine.go_deep(100)
|> Submarine.move(200)
|> Submarine.fire()
Pattern matching
function daisy(woman, man) {
if ( woman === ‘my_love’) {
if (man === ‘me’ ) {
return “She love me!!!”
} else {
return “She love another… :(“
}
}
else if ( woman === ‘my_friend’) {
return “She’s only my friend”
}
else {
return “Who is she?”
}
}
def daisy( :my_love, :me ), do: “She love me!!!”
def daisy( :my_love, _ ), do: “She love another… :(“
def daisy( :my_friend, _ ), do: “She’s only my friend”
def daisy( _ , _ ), do: “Who is she?”
Fibonacci
function fibonacci(num, memo) {
memo = memo || {};
if (memo[num]) return memo[num];
if (num <= 1) return 1;
return memo[num] = fibonacci(num – 1, memo) + fibonacci(num – 2, memo);
}
def fibonacci(n) when n < 2, do: n
def fibonacci(n) do: fibonacci(n-1) + fibonacci(n-2)
Doc & Test built-in
Doc generates the documentation, and Examples defines automatically the a simples test set.
defmodule Fibonacci do
@moduledoc “””
Modurle for fibonacci.
“””
@doc “””
Fibonacci function
## Examples
iex> Fibonacci.fibonacci(3)
2
iex> Fibonacci.fibonacci(7)
13
“””
def fibonacci(n) when n < 2, do: n
def fibonacci(n) do: fibonacci(n-1) + fibonacci(n-2)