SlideShare a Scribd company logo
A look into a modern
programming language
ELIXIR PROGRAMMING LANGUAGE
THE OLD WEB
• Large codebases
• No separation of concerns
• Minimal or no tests and usually with low code coverage
• Extra features before bug fixes and refactoring
Single codebases
THE OLD WEB
• Minimal use of HTTP verbs
• Lack of understanding of HTTP cache control
• No RESTFul API or Hypermedia support
• Custom request/response formats (see Paypal NVP Gateway)
• Mostly XML and WSDL APIs
Minimal understanding of HTTP
THE OLD WEB
• No separation of API and HTML generation
• No language separations (PHP, HTML, CSS & JS)
				 - Frameworks tried to help
Backend generated html
THE OLD WEB
• Scaling meant improving hardware (CPU or RAM)
• Inefficient use of resources
• Same codebase replicated on multiple nodes
Vertical scalability
THE OLD WEB
• FTP
• SCP
• Archives
• Developers have access to production servers
• Mutable infrastructure
Manual deployments
THE
MODERN
WEB
THE MODERN WEB
• Multiple codebases/apps
• Bounded context
• Multiple databases
• Minimal shared resources
• Deployed and scaled individually
Separation of concerns
Service/microservice oriented
• In the codebase
(React, Elm, Elixir, Erlang, Haskell, Scala, Lisp)
• In deployment
• Stateless: JWT, Memcache/Redis
ImmutabilityTHE MODERN WEB
THE MODERN WEB
See https://12factor.net/
• Distributed
• Scalable
THE MODERN WEB
• Faster applications
• Better use of CPU cores
• Abstracting thread/process/
					server communication
• Multiple services working together
Concurrency
Real time communication
Standards & Best practices
No devs in production
Logging & Monitoring
Automation
THE MODERN WEB
ERLANG VM
ERLANG VM
• Distributed
• Fault-tolerant
• Soft real-time
• Highly available, non-stop applications
• Hot swapping code without stopping applications
Created in 1986 by Ericsson
to build telecom switches
Built for the following use cases:
ERLANG VM
• Distributed
• Fault-tolerant
• Soft real-time
• Highly available, non-stop applications
• Hot swapping code without stopping applications
Created in 1986 by Ericsson
to build telecom switches
Built for the following use cases:
ERLANG VM
• Distributed
• Fault-tolerant
• Soft real-time
• Highly available, non-stop applications
• Hot swapping code without stopping applications
Created in 1986 by Ericsson
to build telecom switches
Built for the following use cases:
ERLANG VM
• Distributed
• Fault-tolerant
• Soft real-time
• Highly available, non-stop applications
• Hot swapping code without stopping applications
Created in 1986 by Ericsson
to build telecom switches
Built for the following use cases:
ELIXIR
• A modern language with Ruby like syntax
• Compiles to Erlang VM code
• Functional
• Built for concurrency
• Resilient
• Immutable
• Share nothing Actor model
ELIXIR
• Everything runs in a very small VM Process
• Processes as state
• Sync or Async
• Supervisors
• Distributed/scalable out of the box
• Easy to understand
• Pattern matching
• Hot code reload
RUBY STYLE SYNTAX
defmodule Math do
def sum(a, b) do
do_sum(a, b)
end
defp do_sum(a, b) do
a + b
end
end
IO.puts Math.sum(1, 2) #=> 3
IO.puts Math.do_sum(1, 2) #=> ** (UndefinedFunctionError)
FUNCTIONAL
defmodule Math do
def zero?(0), do: true
def zero?(x) when is_integer(x), do: false
end
%User{name: name, age: age} = User.get(“John Doe”)
name #=> “John Doe”
FUNCTIONAL
defmodule MyElixir.Emails do
import Bamboo.Email
import Bamboo.SendgridHelper
def welcome_email(email) do
template_id = Application.get_env(:my_elixir_api, MyElixirApi.Mailer)[:welcome_template_id]
new_email()
|> to(email)
|> from(“support@example.com”)
|> substitute(“%name%”, “Jon Snow”)
|> with_template(template_id)
end
end
PATTERN MATCHING
• “=” is not an assignment
• “=” handles assignment and comparison at the same time
• “=” can destructure complex types and assign them to variables
• Fails when matching is not as expected
Back to basics:
def serve_drinks(%User{age: age}) when age >= 21 do
# Code that serves drinks!
end
serve_drinks User.get(“John Doe”)
#=> Fails if the user is under 21
PATTERN MATCHING
defmodule Fib do
def fib(0), do: 0
def fib(1), do: 1
def fib(n), do: fib(n-1) + fib(n-2)
end
PATTERN MATCHING
IMMUTABLE
• You don’t know what happens to your data when you call a method
• Magic moments
• Hard to implement concurrent code
• Race conditions
• Safely share data between processes
What wrong with mutability?
In Elixir all data is immutable
current_process = self()
# Spawn an Elixir process (not an operating system one!)
pid = spawn_link(fn ->
send current_process, {:msg, “hello world”}
end)
# Block until the message is received
receive do
{:msg, contents} -> IO.puts contents
end
PROCESSES
PROCESSES
- Your code does not change if you deploy on
one node or on multiple nodes
• Native support for lightweight processes
• Can start tens of thousands of processes
• Processes are isolated
• Communicate using messages
• Elixir abstracts away the location of the processes
PROCESSES
• A process that monitors other processes and restarts them
when they crash
• Multiple restart strategies
• Supervisor hierarchies help you design fault tolerance
• Let it crash and restart from a known state
• You can supervise processes from other nodes
Supervisors
Each process has an inbox for incoming messages
CLUSTERS
• Connect to other nodes in the network
• Connected nodes can send and receive messages between processes
• Run code on another node
• Monitor node health
Node A Node A
Node B
Node D
Node C
Node E connects
to Node A ...
Node E is connected
to everyone else!
Node D
Node B Node C
Node E
Node E
HOT CODE RELOAD
• Keep application running when updating code
• Determine how your state changes for each module
• Simple update API
defmodule Inc do
use GenServer
def start_link, do: GenServer.start_link(__MODULE__, [])
def inc(i), do: GenServer.call(i, :inc)
def get(i), do: GenServer.call(i, :total)
def init(_), do: {:ok, 0}
def handle_call(:inc, _from, total) do
new_total = total + 1
# new_total = total + 2
{:reply, new_total, new_total}
end
def handle_call(:total, _from, total), do: {:reply, total, total}
def code_change(old_vsn, state, extra) do
IO.puts “New version. Moving out of #{old_vsn} #{inspect extra}”
{:ok, state}
end
end
HOT CODE RELOAD
c “inc.ex”
{:ok, pid} = Inc.start_link
Inc.inc(pid)
# 1
### Do code changes
:sys.suspend(pid)
# :ok
c “inc.ex”
# inc.ex:1: warning: redefining module Inc
# [Inc]
:sys.change_code(pid, Inc, “1”, [:hello])
# New version. Moving out of 1 [:hello]
# :ok
:sys.resume(pid)
# :ok
Inc.inc(pid)
# 3
HOT CODE RELOAD
OTHER NOTES
• No single process can slow down other processes
• Errors are isolated to the running process
• Scale down resources and handle more load
• Easy web sockets support with Phoenix Channels
THANK YOU!
Visit us @ around25.com

More Related Content

PDF
Introduction to Elixir
PPTX
php basics
PDF
Introduction to Bootstrap
PPTX
PHP-MySQL Database Connectivity Using XAMPP Server
PDF
Basics of JavaScript
PPTX
Javascript conditional statements
PPTX
Flex box
KEY
HTML CSS & Javascript
Introduction to Elixir
php basics
Introduction to Bootstrap
PHP-MySQL Database Connectivity Using XAMPP Server
Basics of JavaScript
Javascript conditional statements
Flex box
HTML CSS & Javascript

What's hot (20)

PPTX
Introduction to PHP
PPTX
Php.ppt
PDF
jQuery for beginners
PPTX
PPTX
Introduction to ajax
PPTX
jQuery
PPTX
React event
PDF
JavaScript: Variables and Functions
PPTX
Php technical presentation
PPTX
Lecture 7: Server side programming
PPT
Asynchronous JavaScript & XML (AJAX)
PPTX
Intro to React
PDF
Asynchronous JavaScript Programming
PPTX
Introduction to ASP.NET
PPT
Introduction to JavaScript
PDF
Fundamental JavaScript [UTC, March 2014]
PPTX
Brief History of JavaScript
PPTX
Php functions
PDF
Functional programming
PDF
Effective CMake
Introduction to PHP
Php.ppt
jQuery for beginners
Introduction to ajax
jQuery
React event
JavaScript: Variables and Functions
Php technical presentation
Lecture 7: Server side programming
Asynchronous JavaScript & XML (AJAX)
Intro to React
Asynchronous JavaScript Programming
Introduction to ASP.NET
Introduction to JavaScript
Fundamental JavaScript [UTC, March 2014]
Brief History of JavaScript
Php functions
Functional programming
Effective CMake
Ad

Similar to Elixir Programming Language 101 (20)

PDF
VoltDB and Erlang - Tech planet 2012
PPTX
haXe - One codebase to rule'em all
PDF
FITC - Node.js 101
PDF
Scaling tappsi
PDF
Delivering big content at NBC News with RavenDB
PPTX
Build software like a bag of marbles, not a castle of LEGO®
PDF
Phoenix for Rubyists
PDF
Intro to elixir and phoenix
PPT
Computer Fundamentals
PPT
Computer fundamental
PPTX
Object Oriented Programming I
PDF
CNIT 127 Ch 6: The Wild World of Windows
PDF
Node.js 101 with Rami Sayar
PDF
Ch 6: The Wild World of Windows
PDF
Erlang/Elixir and OTP
PDF
Real World Elixir Deployment
KEY
The Architect Way
PPTX
Build software like a bag of marbles, not a castle of LEGO®
PDF
Raffaele Rialdi
PDF
OSCON: Unikernels and Docker: From revolution to evolution
VoltDB and Erlang - Tech planet 2012
haXe - One codebase to rule'em all
FITC - Node.js 101
Scaling tappsi
Delivering big content at NBC News with RavenDB
Build software like a bag of marbles, not a castle of LEGO®
Phoenix for Rubyists
Intro to elixir and phoenix
Computer Fundamentals
Computer fundamental
Object Oriented Programming I
CNIT 127 Ch 6: The Wild World of Windows
Node.js 101 with Rami Sayar
Ch 6: The Wild World of Windows
Erlang/Elixir and OTP
Real World Elixir Deployment
The Architect Way
Build software like a bag of marbles, not a castle of LEGO®
Raffaele Rialdi
OSCON: Unikernels and Docker: From revolution to evolution
Ad

Recently uploaded (20)

PDF
top salesforce developer skills in 2025.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
ai tools demonstartion for schools and inter college
PPTX
Introduction to Artificial Intelligence
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Digital Strategies for Manufacturing Companies
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
AI in Product Development-omnex systems
top salesforce developer skills in 2025.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Upgrade and Innovation Strategies for SAP ERP Customers
ai tools demonstartion for schools and inter college
Introduction to Artificial Intelligence
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
How to Migrate SBCGlobal Email to Yahoo Easily
history of c programming in notes for students .pptx
Design an Analysis of Algorithms I-SECS-1021-03
CHAPTER 2 - PM Management and IT Context
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Digital Strategies for Manufacturing Companies
Odoo Companies in India – Driving Business Transformation.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Which alternative to Crystal Reports is best for small or large businesses.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
How Creative Agencies Leverage Project Management Software.pdf
AI in Product Development-omnex systems

Elixir Programming Language 101

  • 1. A look into a modern programming language ELIXIR PROGRAMMING LANGUAGE
  • 2. THE OLD WEB • Large codebases • No separation of concerns • Minimal or no tests and usually with low code coverage • Extra features before bug fixes and refactoring Single codebases
  • 3. THE OLD WEB • Minimal use of HTTP verbs • Lack of understanding of HTTP cache control • No RESTFul API or Hypermedia support • Custom request/response formats (see Paypal NVP Gateway) • Mostly XML and WSDL APIs Minimal understanding of HTTP
  • 4. THE OLD WEB • No separation of API and HTML generation • No language separations (PHP, HTML, CSS & JS) - Frameworks tried to help Backend generated html
  • 5. THE OLD WEB • Scaling meant improving hardware (CPU or RAM) • Inefficient use of resources • Same codebase replicated on multiple nodes Vertical scalability
  • 6. THE OLD WEB • FTP • SCP • Archives • Developers have access to production servers • Mutable infrastructure Manual deployments
  • 8. THE MODERN WEB • Multiple codebases/apps • Bounded context • Multiple databases • Minimal shared resources • Deployed and scaled individually Separation of concerns Service/microservice oriented
  • 9. • In the codebase (React, Elm, Elixir, Erlang, Haskell, Scala, Lisp) • In deployment • Stateless: JWT, Memcache/Redis ImmutabilityTHE MODERN WEB
  • 10. THE MODERN WEB See https://12factor.net/ • Distributed • Scalable
  • 11. THE MODERN WEB • Faster applications • Better use of CPU cores • Abstracting thread/process/ server communication • Multiple services working together Concurrency
  • 12. Real time communication Standards & Best practices No devs in production Logging & Monitoring Automation THE MODERN WEB
  • 14. ERLANG VM • Distributed • Fault-tolerant • Soft real-time • Highly available, non-stop applications • Hot swapping code without stopping applications Created in 1986 by Ericsson to build telecom switches Built for the following use cases:
  • 15. ERLANG VM • Distributed • Fault-tolerant • Soft real-time • Highly available, non-stop applications • Hot swapping code without stopping applications Created in 1986 by Ericsson to build telecom switches Built for the following use cases:
  • 16. ERLANG VM • Distributed • Fault-tolerant • Soft real-time • Highly available, non-stop applications • Hot swapping code without stopping applications Created in 1986 by Ericsson to build telecom switches Built for the following use cases:
  • 17. ERLANG VM • Distributed • Fault-tolerant • Soft real-time • Highly available, non-stop applications • Hot swapping code without stopping applications Created in 1986 by Ericsson to build telecom switches Built for the following use cases:
  • 18. ELIXIR • A modern language with Ruby like syntax • Compiles to Erlang VM code • Functional • Built for concurrency • Resilient • Immutable • Share nothing Actor model
  • 19. ELIXIR • Everything runs in a very small VM Process • Processes as state • Sync or Async • Supervisors • Distributed/scalable out of the box • Easy to understand • Pattern matching • Hot code reload
  • 20. RUBY STYLE SYNTAX defmodule Math do def sum(a, b) do do_sum(a, b) end defp do_sum(a, b) do a + b end end IO.puts Math.sum(1, 2) #=> 3 IO.puts Math.do_sum(1, 2) #=> ** (UndefinedFunctionError)
  • 21. FUNCTIONAL defmodule Math do def zero?(0), do: true def zero?(x) when is_integer(x), do: false end %User{name: name, age: age} = User.get(“John Doe”) name #=> “John Doe”
  • 22. FUNCTIONAL defmodule MyElixir.Emails do import Bamboo.Email import Bamboo.SendgridHelper def welcome_email(email) do template_id = Application.get_env(:my_elixir_api, MyElixirApi.Mailer)[:welcome_template_id] new_email() |> to(email) |> from(“support@example.com”) |> substitute(“%name%”, “Jon Snow”) |> with_template(template_id) end end
  • 23. PATTERN MATCHING • “=” is not an assignment • “=” handles assignment and comparison at the same time • “=” can destructure complex types and assign them to variables • Fails when matching is not as expected Back to basics:
  • 24. def serve_drinks(%User{age: age}) when age >= 21 do # Code that serves drinks! end serve_drinks User.get(“John Doe”) #=> Fails if the user is under 21 PATTERN MATCHING
  • 25. defmodule Fib do def fib(0), do: 0 def fib(1), do: 1 def fib(n), do: fib(n-1) + fib(n-2) end PATTERN MATCHING
  • 26. IMMUTABLE • You don’t know what happens to your data when you call a method • Magic moments • Hard to implement concurrent code • Race conditions • Safely share data between processes What wrong with mutability? In Elixir all data is immutable
  • 27. current_process = self() # Spawn an Elixir process (not an operating system one!) pid = spawn_link(fn -> send current_process, {:msg, “hello world”} end) # Block until the message is received receive do {:msg, contents} -> IO.puts contents end PROCESSES
  • 28. PROCESSES - Your code does not change if you deploy on one node or on multiple nodes • Native support for lightweight processes • Can start tens of thousands of processes • Processes are isolated • Communicate using messages • Elixir abstracts away the location of the processes
  • 29. PROCESSES • A process that monitors other processes and restarts them when they crash • Multiple restart strategies • Supervisor hierarchies help you design fault tolerance • Let it crash and restart from a known state • You can supervise processes from other nodes Supervisors Each process has an inbox for incoming messages
  • 30. CLUSTERS • Connect to other nodes in the network • Connected nodes can send and receive messages between processes • Run code on another node • Monitor node health Node A Node A Node B Node D Node C Node E connects to Node A ... Node E is connected to everyone else! Node D Node B Node C Node E Node E
  • 31. HOT CODE RELOAD • Keep application running when updating code • Determine how your state changes for each module • Simple update API
  • 32. defmodule Inc do use GenServer def start_link, do: GenServer.start_link(__MODULE__, []) def inc(i), do: GenServer.call(i, :inc) def get(i), do: GenServer.call(i, :total) def init(_), do: {:ok, 0} def handle_call(:inc, _from, total) do new_total = total + 1 # new_total = total + 2 {:reply, new_total, new_total} end def handle_call(:total, _from, total), do: {:reply, total, total} def code_change(old_vsn, state, extra) do IO.puts “New version. Moving out of #{old_vsn} #{inspect extra}” {:ok, state} end end HOT CODE RELOAD
  • 33. c “inc.ex” {:ok, pid} = Inc.start_link Inc.inc(pid) # 1 ### Do code changes :sys.suspend(pid) # :ok c “inc.ex” # inc.ex:1: warning: redefining module Inc # [Inc] :sys.change_code(pid, Inc, “1”, [:hello]) # New version. Moving out of 1 [:hello] # :ok :sys.resume(pid) # :ok Inc.inc(pid) # 3 HOT CODE RELOAD
  • 34. OTHER NOTES • No single process can slow down other processes • Errors are isolated to the running process • Scale down resources and handle more load • Easy web sockets support with Phoenix Channels
  • 35. THANK YOU! Visit us @ around25.com