SlideShare a Scribd company logo
Functional Programming With Elixir
Nguyen Anh Tien
Table of Contents
● What is Elixir ?
● Functional Programming
● Why Elixir ?
● Syntax of Elixir
● Elixir’s Ecosystem
● Q & A
2
What is Elixir ?
● Functional, Concurrent, General Purpose
● Created by José Valim @ Plataformatec
○ Former Rails Core Team member
○ Author of Crafting Rails 4 Application
● Run on Erlang VM
● Stable release: 1.3.1
● Used by: Pinterest, Dockyard, Bleacher Report, ...
3
What is Elixir ? - Erlang
● Developed by Ericsson, ~1986
● Same characteristic as Elixir
● Used in Telephone Applications
● BEAM VM
○ A virtual machine to run Erlang
○ Interfaces to the “outside” world
● Backed of WhatApp, Amazon’s SimpleDB, ...
○ http://highscalability.com/blog/2014/2/26/the-whatsapp-architecture-facebook-bought-for-19
-billion.html
○ https://blog.whatsapp.com/196/1-million-is-so-2011
● Battle-tested !
4
Functional vs Imperative Programming
● Modules
● Immutable
● Pure functions
○ No side-effect
● Stateless ?
● Declarative
○ Expressions
● Erlang, Haskell, Clojure, ...
● Objects
● Mutable
● Methods
○ Can have side-effect
● Stateful
● Imperative
○ Statements
● Python, Ruby, Java
5
Elixir’s Syntax - Types
Integer 1234 0xcafe 0177 0b100 10_000
Float 1.0 3.1415 6.02e23
Atom :foo :me@home :"with spaces"
Tuple { 1, 2, :ok, "xy" }
List [ 1, 2, 3 ] or [head | tail]
Keyword List [ a: "Foo", b: 123 ]
Map %{ key => value, key => value }
Truth true, false, nil
Range a..b
6
Elixir’s Syntax - Ruby like
7
Elixir’s Syntax
● First class functions - High order functions
○ Functions that can either take other functions as arguments or return them as results
○ Macro 
○ Homoiconicity
● Anonymous functions
Data Function Function Data
transformation
transformation
8
Elixir’s Syntax - Pipe operator (1)
● |>
○ passes the result of an expression as the first parameter of another expression.
● First argument: Data to transform
● Function composing
● Normal (bad) code
9
Elixir’s Syntax - Pipe operator (2)
● Nested code
● Pipe code
10
Elixir’s Syntax - Pattern Matching (1)
● the = operator is actually a match operator -> binding + rebinding
11
Elixir’s Syntax - Pattern Matching (2)
● Function signature matching
12
Elixir’s Syntax - Looping
● Looping through recursion, tail-call
● Iteration
○ Enum.reduce
○ Enum.map
○ Enum.filter
○ ...
13
Why Elixir ? Processes
● Processes
○ Lightweight, low cost (~1KB)
○ Isolated, concurrent
○ Thousand of processes
● Communication by message-passing
○ Inbox
● Connect to other node in another computer
● -> Distributed
14
Why Elixir ? Fast (1)
● Data copying
○ -> inefficient ?
● Garbage Collector
○ Processes have separated
heap
○ No synchronisation
● Robert Virding - Hitchhiker's
Tour of the BEAM
○ https://www.youtube.com
/watch?v=_Pwlvy3zz9M
15
Why Elixir ? Fast (2)
● Let’s see some
benchmark
○ https://github.com/mroth/
phoenix-showdown
16
Why Elixir ? Fault-tolerant (1)
● Todo Server Example
○ Everyone have a Todo
○ Todo: List of todo items
● Use cache when DB
isn’t reachable
● One user’s todo list do
not affect other’s todo
list
17
Why Elixir ? Fault-tolerant (2)
● “Let it crash”
● Link and Monitor
● OTP
● Supervisor Trees -
GenServer
● Restart Strategy
○ one_for_one
○ simple_one_for_one
○ rest_for_one
18
Elixir’s Ecosystem
● Hex - The package manager for the Erlang ecosystem
● Mix - Elixir’s build tool
○ = Rake + Bundler + RubyGems
● Call outside program via Ports or NIF
19
Elixir’s Ecosystem
● Productive - Reliable - Fast
● MVC model, Plug based
● Live reload coding
● Websocket integrated
○ http://www.phoenixframework.org/blog/the-road-to-2-million-websocket-c
onnections
○ https://dockyard.com/blog/2016/08/09/phoenix-channels-vs-rails-action-
cable
● More and more app migration from
Rails to Phoenix
○ https://speakerdeck.com/bcardarella/fro
m-rails-to-phoenix
20
Learning Resources
● Elixir Getting Started
● Elixir Schools
● ElixirConf @ youtube
● #elixir @ confreaks.tv
● exercism.io
● vietnamrb.slack.com
● Elixir-lang.slack.com
● Erlang stuffs !
● ...
21
Q & A
22
23
Thank you !

More Related Content

What's hot (20)

Whirlwind tour of the Runtime Dynamic Linker
Whirlwind tour of the Runtime Dynamic LinkerWhirlwind tour of the Runtime Dynamic Linker
Whirlwind tour of the Runtime Dynamic Linker
Gonçalo Gomes
 
Oslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep DiveOslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep Dive
davanum
 
History of programming languages
History of programming languagesHistory of programming languages
History of programming languages
twuniversity
 
Dynamic in C# 4.0
Dynamic in C# 4.0Dynamic in C# 4.0
Dynamic in C# 4.0
morrisBahrami
 
Elixir otp-basics
Elixir otp-basicsElixir otp-basics
Elixir otp-basics
Ruben Amortegui
 
Ruxmon.2015-08.-.proxenet
Ruxmon.2015-08.-.proxenetRuxmon.2015-08.-.proxenet
Ruxmon.2015-08.-.proxenet
Christophe Alladoum
 
Intro to GO (Bangkok Launchpad 2014)
Intro to GO (Bangkok Launchpad 2014)Intro to GO (Bangkok Launchpad 2014)
Intro to GO (Bangkok Launchpad 2014)
Matthew Campbell
 
A bit more of PE
A bit more of PEA bit more of PE
A bit more of PE
Ange Albertini
 
Sprint Boot & Kotlin - Meetup.pdf
Sprint Boot & Kotlin - Meetup.pdfSprint Boot & Kotlin - Meetup.pdf
Sprint Boot & Kotlin - Meetup.pdf
Christian Zellot
 
Tofu and its environment
Tofu and its environmentTofu and its environment
Tofu and its environment
Kirill Shelopugin
 
Introduction to Go for Java Developers
Introduction to Go for Java DevelopersIntroduction to Go for Java Developers
Introduction to Go for Java Developers
Laszlo Csontos
 
NoSQL Yes, But YesCQL, No?
NoSQL Yes, But YesCQL, No?NoSQL Yes, But YesCQL, No?
NoSQL Yes, But YesCQL, No?
Eric Evans
 
Use notes objects in memory and other useful java tips for xpages development
Use notes objects in memory and other useful java tips for xpages developmentUse notes objects in memory and other useful java tips for xpages development
Use notes objects in memory and other useful java tips for xpages development
Frank van der Linden
 
Introduction to f#
Introduction to f#Introduction to f#
Introduction to f#
mjyeaney
 
Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)
Calvin Cheng
 
Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!
Christophe Alladoum
 
GraphQL is actually rest
GraphQL is actually restGraphQL is actually rest
GraphQL is actually rest
Jakub Riedl
 
IDLs
IDLsIDLs
IDLs
Ruslan Shevchenko
 
Children of Ruby
Children of RubyChildren of Ruby
Children of Ruby
Simon St.Laurent
 
Functional Programming and Concurrency Patterns in Scala
Functional Programming and Concurrency Patterns in ScalaFunctional Programming and Concurrency Patterns in Scala
Functional Programming and Concurrency Patterns in Scala
kellogh
 
Whirlwind tour of the Runtime Dynamic Linker
Whirlwind tour of the Runtime Dynamic LinkerWhirlwind tour of the Runtime Dynamic Linker
Whirlwind tour of the Runtime Dynamic Linker
Gonçalo Gomes
 
Oslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep DiveOslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep Dive
davanum
 
History of programming languages
History of programming languagesHistory of programming languages
History of programming languages
twuniversity
 
Intro to GO (Bangkok Launchpad 2014)
Intro to GO (Bangkok Launchpad 2014)Intro to GO (Bangkok Launchpad 2014)
Intro to GO (Bangkok Launchpad 2014)
Matthew Campbell
 
Sprint Boot & Kotlin - Meetup.pdf
Sprint Boot & Kotlin - Meetup.pdfSprint Boot & Kotlin - Meetup.pdf
Sprint Boot & Kotlin - Meetup.pdf
Christian Zellot
 
Introduction to Go for Java Developers
Introduction to Go for Java DevelopersIntroduction to Go for Java Developers
Introduction to Go for Java Developers
Laszlo Csontos
 
NoSQL Yes, But YesCQL, No?
NoSQL Yes, But YesCQL, No?NoSQL Yes, But YesCQL, No?
NoSQL Yes, But YesCQL, No?
Eric Evans
 
Use notes objects in memory and other useful java tips for xpages development
Use notes objects in memory and other useful java tips for xpages developmentUse notes objects in memory and other useful java tips for xpages development
Use notes objects in memory and other useful java tips for xpages development
Frank van der Linden
 
Introduction to f#
Introduction to f#Introduction to f#
Introduction to f#
mjyeaney
 
Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)
Calvin Cheng
 
GraphQL is actually rest
GraphQL is actually restGraphQL is actually rest
GraphQL is actually rest
Jakub Riedl
 
Functional Programming and Concurrency Patterns in Scala
Functional Programming and Concurrency Patterns in ScalaFunctional Programming and Concurrency Patterns in Scala
Functional Programming and Concurrency Patterns in Scala
kellogh
 

Viewers also liked (20)

The legendary-book
The legendary-bookThe legendary-book
The legendary-book
Huy Hoàng Phạm
 
Growing ELIXIR-UK
Growing ELIXIR-UKGrowing ELIXIR-UK
Growing ELIXIR-UK
jmhancock
 
Enfermedades raras
Enfermedades rarasEnfermedades raras
Enfermedades raras
Franco Vecchio
 
Enfermedades RARAS
Enfermedades RARASEnfermedades RARAS
Enfermedades RARAS
adrimar2450
 
Elixir
ElixirElixir
Elixir
Robert Brown
 
Las Enfermedades Raras
Las Enfermedades Raras Las Enfermedades Raras
Las Enfermedades Raras
Gustavo A. Grima
 
Coordinating European training and ELIXIR UK by Rita Hendricusdottir
Coordinating European training and ELIXIR UK by Rita HendricusdottirCoordinating European training and ELIXIR UK by Rita Hendricusdottir
Coordinating European training and ELIXIR UK by Rita Hendricusdottir
ELIXIR UK
 
Introducción a las Enfermedades Raras - 27.03.2015
Introducción a las Enfermedades Raras - 27.03.2015Introducción a las Enfermedades Raras - 27.03.2015
Introducción a las Enfermedades Raras - 27.03.2015
ilsintelligence
 
The ELIXIR UK training portal (TeSS) by Carole Goble
The ELIXIR UK training portal (TeSS) by Carole GobleThe ELIXIR UK training portal (TeSS) by Carole Goble
The ELIXIR UK training portal (TeSS) by Carole Goble
ELIXIR UK
 
TeSS: ELIXIR Training Portal (Eubic Winter School 2017)
TeSS: ELIXIR Training Portal (Eubic Winter School 2017)TeSS: ELIXIR Training Portal (Eubic Winter School 2017)
TeSS: ELIXIR Training Portal (Eubic Winter School 2017)
Niall Beard
 
An introduction to Erlang and Elixir
An introduction to Erlang and ElixirAn introduction to Erlang and Elixir
An introduction to Erlang and Elixir
ericbmerritt
 
Enfermedades raras II
Enfermedades raras IIEnfermedades raras II
Enfermedades raras II
Fernando Patiño
 
Elixir
ElixirElixir
Elixir
Marek Kirejczyk
 
La Estrategia en Enfermedades Raras del SNS
La Estrategia en Enfermedades Raras del SNSLa Estrategia en Enfermedades Raras del SNS
La Estrategia en Enfermedades Raras del SNS
Plan de Calidad para el SNS
 
¿Qué son las Enfermedades Raras?
¿Qué son las Enfermedades Raras?¿Qué son las Enfermedades Raras?
¿Qué son las Enfermedades Raras?
Ruben Lijo
 
Enfermedades Raras y Crónicas
Enfermedades Raras y CrónicasEnfermedades Raras y Crónicas
Enfermedades Raras y Crónicas
Pedro Roberto Casanova
 
Medición en salud
Medición en saludMedición en salud
Medición en salud
Andrés Jagua-Gualdrón
 
Validacion de escalas de medicion en salud
Validacion de escalas de medicion en saludValidacion de escalas de medicion en salud
Validacion de escalas de medicion en salud
Gerardo Antonio Muñeton Lopez
 
Enfermedades raras i
Enfermedades raras iEnfermedades raras i
Enfermedades raras i
Fernando Patiño
 
Medicamentos huérfanos
Medicamentos huérfanosMedicamentos huérfanos
Medicamentos huérfanos
Mar Sánchez
 
Growing ELIXIR-UK
Growing ELIXIR-UKGrowing ELIXIR-UK
Growing ELIXIR-UK
jmhancock
 
Enfermedades RARAS
Enfermedades RARASEnfermedades RARAS
Enfermedades RARAS
adrimar2450
 
Coordinating European training and ELIXIR UK by Rita Hendricusdottir
Coordinating European training and ELIXIR UK by Rita HendricusdottirCoordinating European training and ELIXIR UK by Rita Hendricusdottir
Coordinating European training and ELIXIR UK by Rita Hendricusdottir
ELIXIR UK
 
Introducción a las Enfermedades Raras - 27.03.2015
Introducción a las Enfermedades Raras - 27.03.2015Introducción a las Enfermedades Raras - 27.03.2015
Introducción a las Enfermedades Raras - 27.03.2015
ilsintelligence
 
The ELIXIR UK training portal (TeSS) by Carole Goble
The ELIXIR UK training portal (TeSS) by Carole GobleThe ELIXIR UK training portal (TeSS) by Carole Goble
The ELIXIR UK training portal (TeSS) by Carole Goble
ELIXIR UK
 
TeSS: ELIXIR Training Portal (Eubic Winter School 2017)
TeSS: ELIXIR Training Portal (Eubic Winter School 2017)TeSS: ELIXIR Training Portal (Eubic Winter School 2017)
TeSS: ELIXIR Training Portal (Eubic Winter School 2017)
Niall Beard
 
An introduction to Erlang and Elixir
An introduction to Erlang and ElixirAn introduction to Erlang and Elixir
An introduction to Erlang and Elixir
ericbmerritt
 
¿Qué son las Enfermedades Raras?
¿Qué son las Enfermedades Raras?¿Qué son las Enfermedades Raras?
¿Qué son las Enfermedades Raras?
Ruben Lijo
 
Medicamentos huérfanos
Medicamentos huérfanosMedicamentos huérfanos
Medicamentos huérfanos
Mar Sánchez
 
Ad

Similar to Functional Programming With Elixir (20)

Intro to elixir and phoenix
Intro to elixir and phoenixIntro to elixir and phoenix
Intro to elixir and phoenix
Jared Smith
 
Elixir
ElixirElixir
Elixir
Fuat Buğra AYDIN
 
Elixir for aspiring Erlang developers
Elixir for aspiring Erlang developersElixir for aspiring Erlang developers
Elixir for aspiring Erlang developers
Torben Dohrn
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
Keith Mattix II
 
What is the deal with Elixir?
What is the deal with Elixir?What is the deal with Elixir?
What is the deal with Elixir?
George Coffey
 
Elixir and Phoenix for Rubyists
Elixir and Phoenix for RubyistsElixir and Phoenix for Rubyists
Elixir and Phoenix for Rubyists
Brooklyn Zelenka
 
Intro to Elixir talk
Intro to Elixir talkIntro to Elixir talk
Intro to Elixir talk
Carlos I. Peña
 
Learning Elixir as a Rubyist
Learning Elixir as a RubyistLearning Elixir as a Rubyist
Learning Elixir as a Rubyist
Alex Kira
 
Elixir and elm
Elixir and elmElixir and elm
Elixir and elm
Mix & Go
 
Elm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and WebElm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and Web
Publitory
 
Repeating History...On Purpose...with Elixir
Repeating History...On Purpose...with ElixirRepeating History...On Purpose...with Elixir
Repeating History...On Purpose...with Elixir
Barry Jones
 
Elixir & Phoenix 推坑
Elixir & Phoenix 推坑Elixir & Phoenix 推坑
Elixir & Phoenix 推坑
Chao-Ju Huang
 
Intro to Elixir
Intro to ElixirIntro to Elixir
Intro to Elixir
Hernán Schmidt
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
Diacode
 
Elixir and OTP Apps introduction
Elixir and OTP Apps introductionElixir and OTP Apps introduction
Elixir and OTP Apps introduction
Gonzalo Gabriel Jiménez Fuentes
 
Basics Of Elixir and Phoenix
Basics Of Elixir and Phoenix Basics Of Elixir and Phoenix
Basics Of Elixir and Phoenix
OnorioCatenacci
 
20240412 QFM010 Elixir Reading List March 2024
20240412 QFM010 Elixir Reading List March 202420240412 QFM010 Elixir Reading List March 2024
20240412 QFM010 Elixir Reading List March 2024
Matthew Sinclair
 
My elixir helWo lorld
My elixir helWo lorldMy elixir helWo lorld
My elixir helWo lorld
Claudio D'Alicandro
 
Why I love Elixir by Jukka Välimaa from Elixir Meetup 2/2020
Why I love Elixir by Jukka Välimaa from Elixir Meetup 2/2020Why I love Elixir by Jukka Välimaa from Elixir Meetup 2/2020
Why I love Elixir by Jukka Välimaa from Elixir Meetup 2/2020
Montel Intergalactic
 
Elixir intro
Elixir introElixir intro
Elixir intro
Anton Mishchuk
 
Intro to elixir and phoenix
Intro to elixir and phoenixIntro to elixir and phoenix
Intro to elixir and phoenix
Jared Smith
 
Elixir for aspiring Erlang developers
Elixir for aspiring Erlang developersElixir for aspiring Erlang developers
Elixir for aspiring Erlang developers
Torben Dohrn
 
What is the deal with Elixir?
What is the deal with Elixir?What is the deal with Elixir?
What is the deal with Elixir?
George Coffey
 
Elixir and Phoenix for Rubyists
Elixir and Phoenix for RubyistsElixir and Phoenix for Rubyists
Elixir and Phoenix for Rubyists
Brooklyn Zelenka
 
Learning Elixir as a Rubyist
Learning Elixir as a RubyistLearning Elixir as a Rubyist
Learning Elixir as a Rubyist
Alex Kira
 
Elixir and elm
Elixir and elmElixir and elm
Elixir and elm
Mix & Go
 
Elm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and WebElm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and Web
Publitory
 
Repeating History...On Purpose...with Elixir
Repeating History...On Purpose...with ElixirRepeating History...On Purpose...with Elixir
Repeating History...On Purpose...with Elixir
Barry Jones
 
Elixir & Phoenix 推坑
Elixir & Phoenix 推坑Elixir & Phoenix 推坑
Elixir & Phoenix 推坑
Chao-Ju Huang
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
Diacode
 
Basics Of Elixir and Phoenix
Basics Of Elixir and Phoenix Basics Of Elixir and Phoenix
Basics Of Elixir and Phoenix
OnorioCatenacci
 
20240412 QFM010 Elixir Reading List March 2024
20240412 QFM010 Elixir Reading List March 202420240412 QFM010 Elixir Reading List March 2024
20240412 QFM010 Elixir Reading List March 2024
Matthew Sinclair
 
Why I love Elixir by Jukka Välimaa from Elixir Meetup 2/2020
Why I love Elixir by Jukka Välimaa from Elixir Meetup 2/2020Why I love Elixir by Jukka Välimaa from Elixir Meetup 2/2020
Why I love Elixir by Jukka Välimaa from Elixir Meetup 2/2020
Montel Intergalactic
 
Ad

More from Framgia Vietnam (20)

Dreamers defense
Dreamers defenseDreamers defense
Dreamers defense
Framgia Vietnam
 
Timeless - Websocket on Rails
Timeless - Websocket on RailsTimeless - Websocket on Rails
Timeless - Websocket on Rails
Framgia Vietnam
 
Game Development with Pygame
Game Development with PygameGame Development with Pygame
Game Development with Pygame
Framgia Vietnam
 
CSS3 Lovers, Gather Together
CSS3 Lovers, Gather TogetherCSS3 Lovers, Gather Together
CSS3 Lovers, Gather Together
Framgia Vietnam
 
Java 8 new features
Java 8 new features Java 8 new features
Java 8 new features
Framgia Vietnam
 
Build public private cloud using openstack
Build public private cloud using openstackBuild public private cloud using openstack
Build public private cloud using openstack
Framgia Vietnam
 
Introduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on RailsIntroduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on Rails
Framgia Vietnam
 
Some ways to DRY in Rails
Some ways to DRY in Rails Some ways to DRY in Rails
Some ways to DRY in Rails
Framgia Vietnam
 
HTML5 DRAG AND DROP
HTML5 DRAG AND DROPHTML5 DRAG AND DROP
HTML5 DRAG AND DROP
Framgia Vietnam
 
Create 3D objects insite Cocos2d-x
Create 3D objects insite Cocos2d-xCreate 3D objects insite Cocos2d-x
Create 3D objects insite Cocos2d-x
Framgia Vietnam
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
Framgia Vietnam
 
Organize directories for applications with front-end and back-end with yii - ...
Organize directories for applications with front-end and back-end with yii - ...Organize directories for applications with front-end and back-end with yii - ...
Organize directories for applications with front-end and back-end with yii - ...
Framgia Vietnam
 
What is new in PHP 5.5 - HuyenNT
What is new in PHP 5.5 - HuyenNTWhat is new in PHP 5.5 - HuyenNT
What is new in PHP 5.5 - HuyenNT
Framgia Vietnam
 
An idea - NghiaLV
An idea - NghiaLVAn idea - NghiaLV
An idea - NghiaLV
Framgia Vietnam
 
Audited activerecord - QuanHV
Audited activerecord - QuanHVAudited activerecord - QuanHV
Audited activerecord - QuanHV
Framgia Vietnam
 
Delegate - KhanhLD
Delegate - KhanhLDDelegate - KhanhLD
Delegate - KhanhLD
Framgia Vietnam
 
Client side validations gem - KhanhHD
Client side validations gem - KhanhHDClient side validations gem - KhanhHD
Client side validations gem - KhanhHD
Framgia Vietnam
 
Backbone.js and rails - BanLV
Backbone.js and rails - BanLVBackbone.js and rails - BanLV
Backbone.js and rails - BanLV
Framgia Vietnam
 
Jenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuJenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh Vu
Framgia Vietnam
 
Timeless - Websocket on Rails
Timeless - Websocket on RailsTimeless - Websocket on Rails
Timeless - Websocket on Rails
Framgia Vietnam
 
Game Development with Pygame
Game Development with PygameGame Development with Pygame
Game Development with Pygame
Framgia Vietnam
 
CSS3 Lovers, Gather Together
CSS3 Lovers, Gather TogetherCSS3 Lovers, Gather Together
CSS3 Lovers, Gather Together
Framgia Vietnam
 
Build public private cloud using openstack
Build public private cloud using openstackBuild public private cloud using openstack
Build public private cloud using openstack
Framgia Vietnam
 
Introduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on RailsIntroduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on Rails
Framgia Vietnam
 
Some ways to DRY in Rails
Some ways to DRY in Rails Some ways to DRY in Rails
Some ways to DRY in Rails
Framgia Vietnam
 
Create 3D objects insite Cocos2d-x
Create 3D objects insite Cocos2d-xCreate 3D objects insite Cocos2d-x
Create 3D objects insite Cocos2d-x
Framgia Vietnam
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
Framgia Vietnam
 
Organize directories for applications with front-end and back-end with yii - ...
Organize directories for applications with front-end and back-end with yii - ...Organize directories for applications with front-end and back-end with yii - ...
Organize directories for applications with front-end and back-end with yii - ...
Framgia Vietnam
 
What is new in PHP 5.5 - HuyenNT
What is new in PHP 5.5 - HuyenNTWhat is new in PHP 5.5 - HuyenNT
What is new in PHP 5.5 - HuyenNT
Framgia Vietnam
 
Audited activerecord - QuanHV
Audited activerecord - QuanHVAudited activerecord - QuanHV
Audited activerecord - QuanHV
Framgia Vietnam
 
Client side validations gem - KhanhHD
Client side validations gem - KhanhHDClient side validations gem - KhanhHD
Client side validations gem - KhanhHD
Framgia Vietnam
 
Backbone.js and rails - BanLV
Backbone.js and rails - BanLVBackbone.js and rails - BanLV
Backbone.js and rails - BanLV
Framgia Vietnam
 
Jenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuJenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh Vu
Framgia Vietnam
 

Recently uploaded (20)

Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 

Functional Programming With Elixir

  • 1. Functional Programming With Elixir Nguyen Anh Tien
  • 2. Table of Contents ● What is Elixir ? ● Functional Programming ● Why Elixir ? ● Syntax of Elixir ● Elixir’s Ecosystem ● Q & A 2
  • 3. What is Elixir ? ● Functional, Concurrent, General Purpose ● Created by José Valim @ Plataformatec ○ Former Rails Core Team member ○ Author of Crafting Rails 4 Application ● Run on Erlang VM ● Stable release: 1.3.1 ● Used by: Pinterest, Dockyard, Bleacher Report, ... 3
  • 4. What is Elixir ? - Erlang ● Developed by Ericsson, ~1986 ● Same characteristic as Elixir ● Used in Telephone Applications ● BEAM VM ○ A virtual machine to run Erlang ○ Interfaces to the “outside” world ● Backed of WhatApp, Amazon’s SimpleDB, ... ○ http://highscalability.com/blog/2014/2/26/the-whatsapp-architecture-facebook-bought-for-19 -billion.html ○ https://blog.whatsapp.com/196/1-million-is-so-2011 ● Battle-tested ! 4
  • 5. Functional vs Imperative Programming ● Modules ● Immutable ● Pure functions ○ No side-effect ● Stateless ? ● Declarative ○ Expressions ● Erlang, Haskell, Clojure, ... ● Objects ● Mutable ● Methods ○ Can have side-effect ● Stateful ● Imperative ○ Statements ● Python, Ruby, Java 5
  • 6. Elixir’s Syntax - Types Integer 1234 0xcafe 0177 0b100 10_000 Float 1.0 3.1415 6.02e23 Atom :foo :me@home :"with spaces" Tuple { 1, 2, :ok, "xy" } List [ 1, 2, 3 ] or [head | tail] Keyword List [ a: "Foo", b: 123 ] Map %{ key => value, key => value } Truth true, false, nil Range a..b 6
  • 7. Elixir’s Syntax - Ruby like 7
  • 8. Elixir’s Syntax ● First class functions - High order functions ○ Functions that can either take other functions as arguments or return them as results ○ Macro  ○ Homoiconicity ● Anonymous functions Data Function Function Data transformation transformation 8
  • 9. Elixir’s Syntax - Pipe operator (1) ● |> ○ passes the result of an expression as the first parameter of another expression. ● First argument: Data to transform ● Function composing ● Normal (bad) code 9
  • 10. Elixir’s Syntax - Pipe operator (2) ● Nested code ● Pipe code 10
  • 11. Elixir’s Syntax - Pattern Matching (1) ● the = operator is actually a match operator -> binding + rebinding 11
  • 12. Elixir’s Syntax - Pattern Matching (2) ● Function signature matching 12
  • 13. Elixir’s Syntax - Looping ● Looping through recursion, tail-call ● Iteration ○ Enum.reduce ○ Enum.map ○ Enum.filter ○ ... 13
  • 14. Why Elixir ? Processes ● Processes ○ Lightweight, low cost (~1KB) ○ Isolated, concurrent ○ Thousand of processes ● Communication by message-passing ○ Inbox ● Connect to other node in another computer ● -> Distributed 14
  • 15. Why Elixir ? Fast (1) ● Data copying ○ -> inefficient ? ● Garbage Collector ○ Processes have separated heap ○ No synchronisation ● Robert Virding - Hitchhiker's Tour of the BEAM ○ https://www.youtube.com /watch?v=_Pwlvy3zz9M 15
  • 16. Why Elixir ? Fast (2) ● Let’s see some benchmark ○ https://github.com/mroth/ phoenix-showdown 16
  • 17. Why Elixir ? Fault-tolerant (1) ● Todo Server Example ○ Everyone have a Todo ○ Todo: List of todo items ● Use cache when DB isn’t reachable ● One user’s todo list do not affect other’s todo list 17
  • 18. Why Elixir ? Fault-tolerant (2) ● “Let it crash” ● Link and Monitor ● OTP ● Supervisor Trees - GenServer ● Restart Strategy ○ one_for_one ○ simple_one_for_one ○ rest_for_one 18
  • 19. Elixir’s Ecosystem ● Hex - The package manager for the Erlang ecosystem ● Mix - Elixir’s build tool ○ = Rake + Bundler + RubyGems ● Call outside program via Ports or NIF 19
  • 20. Elixir’s Ecosystem ● Productive - Reliable - Fast ● MVC model, Plug based ● Live reload coding ● Websocket integrated ○ http://www.phoenixframework.org/blog/the-road-to-2-million-websocket-c onnections ○ https://dockyard.com/blog/2016/08/09/phoenix-channels-vs-rails-action- cable ● More and more app migration from Rails to Phoenix ○ https://speakerdeck.com/bcardarella/fro m-rails-to-phoenix 20
  • 21. Learning Resources ● Elixir Getting Started ● Elixir Schools ● ElixirConf @ youtube ● #elixir @ confreaks.tv ● exercism.io ● vietnamrb.slack.com ● Elixir-lang.slack.com ● Erlang stuffs ! ● ... 21