SlideShare a Scribd company logo
1 of 19
Elixir and OTP
Eric Roberts
Hoffman Lab
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
● A brief introduction
● Motivation
● Overview of Elixir
● Overview of OTP
Overview
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
Quick Introduction
Elixir language
Open Telecom Platform
Erlang language
BEAM Virtual Machine
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
● Not for re-writes
● Elixir (and Erlang)
programs are not typical
● Better “Object oriented
programming”
● A S.O. Most Loved
Motivation
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
● Strong, Dynamically Typed
● Functional
● Extensible with macros
● Massively Parallel and
Fault Tolerant
● Hot swappable code
Elixir language overview
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
iex(1)> a = 1
1
iex(2)> 1 = a
1
iex(3)> 2 = a
** (MatchError) no match of right hand side value: 1
iex(3)> [a,b,c] = [1,2,3]
[1, 2, 3]
iex(4)> c
3
iex(5)> [a,b,a] = [1,2,3]
** (MatchError) no match of right hand side value: [1,
2, 3]
iex(5)> [a,b,a] = [1,2,1]
[1, 2, 1]
Pattern Matching
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
iex(6)> foo = fn([a,b,c]) -> IO.inspect(c) end
#Function<6.99386804/1 in :erl_eval.expr/5>
iex(7)> foo.([1,2,5])
5
iex(8)> foo.([1,2,5,6])
** (FunctionClauseError) no function clause matching in
:erl_eval."-inside-an-interpreted-fun-"/1
iex(8)> bar = fn([head|tail]) -> IO.inspect(head) end
#Function<6.99386804/1 in :erl_eval.expr/5>
iex(9)> bar.([47,23,124,49])
47
Pattern Matching (cont’d)
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
defmodule Foo do
def handle_open({:ok, file}) do
IO.write(“file opened successfully”)
end
def handle_open({:error, _}) do # ignore posix
code
IO.write(“file could not be opened”)
end
end
Foo.handle_open(File.open(“test.txt”))
Pattern Matching (cont’d)
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
defmodule Bar do
def safe_round(value) when is_integer(value)
value
end
def safe_round(value) when is_float(value) do
round(value)
end
end
Bar.safe_round(2.3)
Bar.safe_round(2)
Guards
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
String.graphemes(
String.capitalize(
String.trim(“hello
“)))
iex(18)> "hello " |>
...(18)> String.trim |>
...(18)> String.capitalize |>
...(18)> String.graphemes
["H", "e", "l", "l", "o"]
Pipe Operator
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
● Macros and DSLs
● Streams and Enumerables
● Calling Erlang libraries
● Maps, Keyword Lists,
Structs
● Protocols and Behaviour
Elixir language extras
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
Actor Based Model:
- Actors may send/recv
messages to other actors
- May only modify their own
state
- May create more actors
OTP and Concurrency
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
defmodule Greeting do
def greet do
receive msg do
msg -> IO.puts(“Hello #{msg}!”)
end
end
end
pid = spawn(Greeting, :greet, [])
send(pid, “world”)
Hello world!
Simple Actor Example
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
Task: async, await
Agent: simple server holding
state
*GenServer: Generic Server
Concurrency Modules
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
Supervisor:
- Automatically restarts child
processes
- Supervise other
supervisors
- Various strategies on
children failures
Supervision
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
Connect various VMs across
a network with an agreed
upon signature
Send messages and spawn
processes across Nodes
Nodes
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
Massively parallel
computation
Smaller functions
Smaller processes/actors
Summary
Overview
Quick Introduction
Motivation
Language Overview
Pattern
Matching
Guards
Pipe Operator
Extras
OTP and Concurrency
Actor Example
Concurrency Modules
Supervision
Nodes
Summary
Questions
Questions
NIFs
Extras

More Related Content

What's hot

Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional waynluaces
 
php app development 1
php app development 1php app development 1
php app development 1barryavery
 
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...Dierk König
 
CS152 Programming Paradigm
CS152 Programming Paradigm CS152 Programming Paradigm
CS152 Programming Paradigm Kaya Ota
 
LVEE 2014: Text parsing with Python and PLY
LVEE 2014: Text parsing with Python and PLYLVEE 2014: Text parsing with Python and PLY
LVEE 2014: Text parsing with Python and PLYdmbaturin
 
About Tokens and Lexemes
About Tokens and LexemesAbout Tokens and Lexemes
About Tokens and LexemesBen Scholzen
 
From Programming to Modeling And Back Again
From Programming to Modeling And Back AgainFrom Programming to Modeling And Back Again
From Programming to Modeling And Back AgainMarkus Voelter
 
Week 8 intro to python
Week 8   intro to pythonWeek 8   intro to python
Week 8 intro to pythonbrianjihoonlee
 
Tools for the Toolmakers
Tools for the ToolmakersTools for the Toolmakers
Tools for the ToolmakersCaleb Callaway
 
How does intellisense work?
How does intellisense work?How does intellisense work?
How does intellisense work?Adam Friedman
 

What's hot (14)

Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional way
 
1 cc
1 cc1 cc
1 cc
 
php app development 1
php app development 1php app development 1
php app development 1
 
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
 
Tdd in practice
Tdd in practiceTdd in practice
Tdd in practice
 
Prolog
PrologProlog
Prolog
 
CS152 Programming Paradigm
CS152 Programming Paradigm CS152 Programming Paradigm
CS152 Programming Paradigm
 
LVEE 2014: Text parsing with Python and PLY
LVEE 2014: Text parsing with Python and PLYLVEE 2014: Text parsing with Python and PLY
LVEE 2014: Text parsing with Python and PLY
 
About Tokens and Lexemes
About Tokens and LexemesAbout Tokens and Lexemes
About Tokens and Lexemes
 
Coding standard
Coding standardCoding standard
Coding standard
 
From Programming to Modeling And Back Again
From Programming to Modeling And Back AgainFrom Programming to Modeling And Back Again
From Programming to Modeling And Back Again
 
Week 8 intro to python
Week 8   intro to pythonWeek 8   intro to python
Week 8 intro to python
 
Tools for the Toolmakers
Tools for the ToolmakersTools for the Toolmakers
Tools for the Toolmakers
 
How does intellisense work?
How does intellisense work?How does intellisense work?
How does intellisense work?
 

Similar to Elixir and OTP

Elixir and elm
Elixir and elmElixir and elm
Elixir and elmMix & Go
 
Mastering Regex in Perl
Mastering Regex in PerlMastering Regex in Perl
Mastering Regex in PerlEdureka!
 
Jerry Shea Resume And Addendum 5 2 09
Jerry  Shea Resume And Addendum 5 2 09Jerry  Shea Resume And Addendum 5 2 09
Jerry Shea Resume And Addendum 5 2 09gshea11
 
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi Petang
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi PetangMajlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi Petang
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi PetangImsamad
 
Agapornis Mansos - www.criadourosudica.blogspot.com
Agapornis Mansos - www.criadourosudica.blogspot.comAgapornis Mansos - www.criadourosudica.blogspot.com
Agapornis Mansos - www.criadourosudica.blogspot.comAntonio Silva
 
Paulo Freire Pedagpogia 1
Paulo Freire Pedagpogia 1Paulo Freire Pedagpogia 1
Paulo Freire Pedagpogia 1Alejandra Perez
 
Washington Practitioners Significant Changes To Rpc 1.5
Washington Practitioners Significant Changes To Rpc 1.5Washington Practitioners Significant Changes To Rpc 1.5
Washington Practitioners Significant Changes To Rpc 1.5Oregon Law Practice Management
 
What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)Moaid Hathot
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C LanguageMohamed Elsayed
 
Erlang workshopdrammen
Erlang workshopdrammenErlang workshopdrammen
Erlang workshopdrammenReidar Sollid
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processorsRebaz Najeeb
 
Technical screening .Net Developer
Technical screening  .Net DeveloperTechnical screening  .Net Developer
Technical screening .Net DeveloperTom Henricksen
 
The Joy Of Functional Programming
The Joy Of Functional ProgrammingThe Joy Of Functional Programming
The Joy Of Functional Programmingjasondew
 

Similar to Elixir and OTP (20)

Elixir and elm
Elixir and elmElixir and elm
Elixir and elm
 
Erlang
ErlangErlang
Erlang
 
Mastering Regex in Perl
Mastering Regex in PerlMastering Regex in Perl
Mastering Regex in Perl
 
MMBJ Shanzhai Culture
MMBJ Shanzhai CultureMMBJ Shanzhai Culture
MMBJ Shanzhai Culture
 
Jerry Shea Resume And Addendum 5 2 09
Jerry  Shea Resume And Addendum 5 2 09Jerry  Shea Resume And Addendum 5 2 09
Jerry Shea Resume And Addendum 5 2 09
 
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi Petang
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi PetangMajlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi Petang
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi Petang
 
Agapornis Mansos - www.criadourosudica.blogspot.com
Agapornis Mansos - www.criadourosudica.blogspot.comAgapornis Mansos - www.criadourosudica.blogspot.com
Agapornis Mansos - www.criadourosudica.blogspot.com
 
LoteríA Correcta
LoteríA CorrectaLoteríA Correcta
LoteríA Correcta
 
Paulo Freire Pedagpogia 1
Paulo Freire Pedagpogia 1Paulo Freire Pedagpogia 1
Paulo Freire Pedagpogia 1
 
Washington Practitioners Significant Changes To Rpc 1.5
Washington Practitioners Significant Changes To Rpc 1.5Washington Practitioners Significant Changes To Rpc 1.5
Washington Practitioners Significant Changes To Rpc 1.5
 
What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C Language
 
PARADIGM IT.pptx
PARADIGM IT.pptxPARADIGM IT.pptx
PARADIGM IT.pptx
 
LANGUAGE TRANSLATOR
LANGUAGE TRANSLATORLANGUAGE TRANSLATOR
LANGUAGE TRANSLATOR
 
Erlang workshopdrammen
Erlang workshopdrammenErlang workshopdrammen
Erlang workshopdrammen
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 
Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
Technical screening .Net Developer
Technical screening  .Net DeveloperTechnical screening  .Net Developer
Technical screening .Net Developer
 
The Joy Of Functional Programming
The Joy Of Functional ProgrammingThe Joy Of Functional Programming
The Joy Of Functional Programming
 

More from Hoffman Lab

GNU Parallel: Lab meeting—technical talk
GNU Parallel: Lab meeting—technical talkGNU Parallel: Lab meeting—technical talk
GNU Parallel: Lab meeting—technical talkHoffman Lab
 
Efficient querying of genomic reference databases with gget
Efficient querying of genomic reference databases with ggetEfficient querying of genomic reference databases with gget
Efficient querying of genomic reference databases with ggetHoffman Lab
 
WashU Epigenome Browser
WashU Epigenome BrowserWashU Epigenome Browser
WashU Epigenome BrowserHoffman Lab
 
Wireguard: A Virtual Private Network Tunnel
Wireguard: A Virtual Private Network TunnelWireguard: A Virtual Private Network Tunnel
Wireguard: A Virtual Private Network TunnelHoffman Lab
 
Plotting heatmap with matplotlib/seaborn
Plotting heatmap with matplotlib/seabornPlotting heatmap with matplotlib/seaborn
Plotting heatmap with matplotlib/seabornHoffman Lab
 
Go Get Data (GGD)
Go Get Data (GGD)Go Get Data (GGD)
Go Get Data (GGD)Hoffman Lab
 
fastp: the FASTQ pre-processor
fastp: the FASTQ pre-processorfastp: the FASTQ pre-processor
fastp: the FASTQ pre-processorHoffman Lab
 
R markdown and Rmdformats
R markdown and RmdformatsR markdown and Rmdformats
R markdown and RmdformatsHoffman Lab
 
File searching tools
File searching toolsFile searching tools
File searching toolsHoffman Lab
 
Better BibTeX (BBT) for Zotero
Better BibTeX (BBT) for ZoteroBetter BibTeX (BBT) for Zotero
Better BibTeX (BBT) for ZoteroHoffman Lab
 
Awk primer and Bioawk
Awk primer and BioawkAwk primer and Bioawk
Awk primer and BioawkHoffman Lab
 
Terminals and Shells
Terminals and ShellsTerminals and Shells
Terminals and ShellsHoffman Lab
 
BioRender & Glossary/Acronym
BioRender & Glossary/AcronymBioRender & Glossary/Acronym
BioRender & Glossary/AcronymHoffman Lab
 
BioSyntax: syntax highlighting for computational biology
BioSyntax: syntax highlighting for computational biologyBioSyntax: syntax highlighting for computational biology
BioSyntax: syntax highlighting for computational biologyHoffman Lab
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With GitHoffman Lab
 
Tech Talk: UCSC Genome Browser
Tech Talk: UCSC Genome BrowserTech Talk: UCSC Genome Browser
Tech Talk: UCSC Genome BrowserHoffman Lab
 
MultiQC: summarize analysis results for multiple tools and samples in a singl...
MultiQC: summarize analysis results for multiple tools and samples in a singl...MultiQC: summarize analysis results for multiple tools and samples in a singl...
MultiQC: summarize analysis results for multiple tools and samples in a singl...Hoffman Lab
 
dreamRs: interactive ggplot2
dreamRs: interactive ggplot2dreamRs: interactive ggplot2
dreamRs: interactive ggplot2Hoffman Lab
 

More from Hoffman Lab (20)

GNU Parallel: Lab meeting—technical talk
GNU Parallel: Lab meeting—technical talkGNU Parallel: Lab meeting—technical talk
GNU Parallel: Lab meeting—technical talk
 
TCRpower
TCRpowerTCRpower
TCRpower
 
Efficient querying of genomic reference databases with gget
Efficient querying of genomic reference databases with ggetEfficient querying of genomic reference databases with gget
Efficient querying of genomic reference databases with gget
 
WashU Epigenome Browser
WashU Epigenome BrowserWashU Epigenome Browser
WashU Epigenome Browser
 
Wireguard: A Virtual Private Network Tunnel
Wireguard: A Virtual Private Network TunnelWireguard: A Virtual Private Network Tunnel
Wireguard: A Virtual Private Network Tunnel
 
Plotting heatmap with matplotlib/seaborn
Plotting heatmap with matplotlib/seabornPlotting heatmap with matplotlib/seaborn
Plotting heatmap with matplotlib/seaborn
 
Go Get Data (GGD)
Go Get Data (GGD)Go Get Data (GGD)
Go Get Data (GGD)
 
fastp: the FASTQ pre-processor
fastp: the FASTQ pre-processorfastp: the FASTQ pre-processor
fastp: the FASTQ pre-processor
 
R markdown and Rmdformats
R markdown and RmdformatsR markdown and Rmdformats
R markdown and Rmdformats
 
File searching tools
File searching toolsFile searching tools
File searching tools
 
Better BibTeX (BBT) for Zotero
Better BibTeX (BBT) for ZoteroBetter BibTeX (BBT) for Zotero
Better BibTeX (BBT) for Zotero
 
Awk primer and Bioawk
Awk primer and BioawkAwk primer and Bioawk
Awk primer and Bioawk
 
Terminals and Shells
Terminals and ShellsTerminals and Shells
Terminals and Shells
 
BioRender & Glossary/Acronym
BioRender & Glossary/AcronymBioRender & Glossary/Acronym
BioRender & Glossary/Acronym
 
Linters in R
Linters in RLinters in R
Linters in R
 
BioSyntax: syntax highlighting for computational biology
BioSyntax: syntax highlighting for computational biologyBioSyntax: syntax highlighting for computational biology
BioSyntax: syntax highlighting for computational biology
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
 
Tech Talk: UCSC Genome Browser
Tech Talk: UCSC Genome BrowserTech Talk: UCSC Genome Browser
Tech Talk: UCSC Genome Browser
 
MultiQC: summarize analysis results for multiple tools and samples in a singl...
MultiQC: summarize analysis results for multiple tools and samples in a singl...MultiQC: summarize analysis results for multiple tools and samples in a singl...
MultiQC: summarize analysis results for multiple tools and samples in a singl...
 
dreamRs: interactive ggplot2
dreamRs: interactive ggplot2dreamRs: interactive ggplot2
dreamRs: interactive ggplot2
 

Recently uploaded

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Elixir and OTP

Editor's Notes

  1. This tech talk will be focused on a “new” language (6 years, 3 years since the first major release) built upon a very old platform (30+ years) Why...
  2. In this presentation I will quickly start with why I would even bother with presenting this topic to data scientists Will give a brief talk about what it is all about Elixir Overview, the language syntax, a very brief overview and highlights of the syntax OTP Overview A very *brief* overview. In terms of scale it would something similar to giving a presentation on Java Language and Platform.
  3. So Elixir is language built on top of a very old language called Erlang. Erlang’s syntax is derived from Prolog and is a lot of programmers are turned off from the syntax. So like Java, Elixir and Erlang and both languages that compile down and are interpreted by a virtual machine. The virtual machine, platform, and Erlang itself has been around for around 33 years or so. While Elixir has only been released for about 6 years or so which is very young by language standards. It came about from a Rails (ruby) core member was fed up with trying to make rails concurrent. Oddly enough the latest point release came out yesterday with a bunch of improvements to performance and the library. Focusing on Elixir as a language in this presentation since it’s the only language in use that uses OTP that is somewhat prevalent aside from Erlang. People tend prefer the syntax to Elixir than Erlang, even the one of the creators of the Erlang language (Joe Armstrong) admitted to so. BEAM = Bogdan/Bjorn’s Erlang Abstract Machine
  4. So first motivation is *not* to have you re-write your programs in Elixir or Erlang immediately after this presentation despite how convincingly awesome I present them. Instead, in general this is supposed to expose the lab as a whole and you individually on different programming paradigms and make you a better programmer, write better programs and introduce new concepts when it comes to job control and supervision. Everyone here writes in an object-oriented language. The man who coined the term (ask?) Alan Kay, had this to say about the term: “I was too blythe(sp) about the term back in the 60s and should have chosen something like "message oriented"” “Significant parts of Erlang are more like a real OOP language the the current Smalltalk, and certainly the C based languages that have been painted with “OOP paint””. In terms of “Most Loved” Elixir trails only .3% respondents behind Python from 2017. Oddly enough Smalltalk ranked 2nd.
  5. Strongly typed as in there will be errors if you try to do something with a particular type there is no operation for. Dynamic as-in bindings can be anything to start with, you don’t need to specify a type beforehand. Almost without exception, all types and data are immutable. There are no references to anything. Whatsapp (went from 1 to 2 million connections on a single machine from 2011 to 2012, 35 engineers 450 million users, and 50 engineers to 900 million, 24 billion messages in a single day) Facebook messenger Discord Massively Parallel is not an exaggeration, hundreds of thousands of processes on a single machine Demonstration more for parallelism than speed. iex(1)> 1..100000 |> ...(1)> Enum.map(fn(x) -> Task.async(fn -> x*x end) end) |> ...(1)> Enum.map(fn(x) -> Task.await(x) end) This clearly is more bottlenecked by the creation and teardown of a process rather than the squaring of a number. Very similar syntax in Python 3 - but it’s not technically possibly due to the Global Interpreter Lock. In general it works in Python if you’re blocked on a system call.
  6. At the heart of Elixir is writing functions with Pattern matching. There is no “assignment” operator in Elixir. Instead the equals operator is more like an assertion\ checking that the left hand side can match the right side. This is not as crazy as it may seem and you can get some useful properties.
  7. Here we can write a function that expects a list with 3 elements and print only the 3rd element through pattern matching. The function will fail if it cannot match a 3 element list. Also there’s syntax for pattern matching a head of a list with the rest of the list (called a tail). In this case we simply print the first element of a list.
  8. Here we are defining a module which is necessary for creating named functions. This is to ensure that all named functions always live in some namespace to avoid clashing. For example, the handle_open name for our function here may be defined in another module without a naming clash. They are also used often for messaging passing between processes. I understand this a whirlwind tour as well but the “colon” names are called atoms. They are simply unique identifiers to use however you wish. Often in Elixir programs they are used for return status codes instead of say an integer from C or whatever you choose for Python (true, false, etc). Here the File.open call returns a tuple with either an :ok file handle tuple or an :error, posix error code tuple There are other builtin types such as maps, and you can define your own types “structures” which are syntatic sugar for maps as well. These can obviously all be pattern matched on as well. Notably, in general although conditionals are available for Elixir, they are often not used in lieu of just more pattern matching. Notably in a switch case conditional you can pattern match on the case statement.
  9. Here we are defining a module which is necessary for creating named functions. This is to ensure that all named functions always live in some namespace to avoid clashing. For example, the handle_open name for our function here may be defined in another module without a naming clash. They are also used often for messaging passing between processes. I understand this a whirlwind tour as well but the “colon” names are called atoms. They are simply unique identifiers to use however you wish. Often in Elixir programs they are used for return status codes instead of say an integer from C or whatever you choose for Python (true, false, etc). Here the File.open call returns a tuple with either an :ok file handle tuple or an :error, posix error code tuple There are other builtin types such as maps, and you can define your own types “structures” which are syntatic sugar for maps as well. These can obviously all be pattern matched on as well. Notably, in general although conditionals are available for Elixir, they are often not used in lieu of just more pattern matching. Notably in a switch case conditional you can pattern match on the case statement.
  10. F#, Swift, elm,
  11. There ways to define your own operators. The Elixir library is filled with them, including the if statement. A huge portion of Elixir is manipulating collections of data There are a bunch of built in types that are useful that I’ll also be glossing over For modules there are also language supported contracts for what a module supports. Sort of like the interface keyword from Java or abstract classes from C++ where you promise to implement certain functions etc.
  12. This is closer to what Alan Kay had in mind apparently when it came to OOP It’s a very simple model, no one can modify each other’s state. Actor can update their own state if they want.
  13. Spawn send and receieve are the smallest primitives available to send messages amongst processes The greet blocks until it recieves a message that was sent to it. Notably you can also get your own process id with self(), so you can send your own pid to a server if you want to program a response. Sending again doesn’t do anything. The spawned process terminates after the function is complete, in this case after the receive block is evaluated
  14. In reality no one really uses send, receive and spawn. They are there in case you want to create any of your own concurrency models More commonly: Tasks are for firing off asynchronous computation. You async a computation, do whatever else and then when you need the result later on you await it. Agents are simple servers that you can use if you need to maintain some form of state or cache. You give it a function that sets up an initial value for whatever state you want it to hold. Then you call functions referencing the returned process id to update the given state, etc. GenServer is a behaviour you implement for your module. You implement certain functions depending on how you want to handle asynchronous messages, synchronous messages, How does things hold state? Tail call for infinite loops to hold state.
  15. Any module that implements the previous modules can be supervised Automatic restart if a child process exits abnormally Children specify how they should be setup and run, restart strategies, what to do in abnormal exit situations etc. Strategies: One for one (only restart the one child), one for all (restart all children)
  16. Connections are usually done through a local network Programs in Elixir typically grow and scale as you need it
  17. Generally functions are very small when it comes with guard clauses and pattern matching This typically makes modules and libraries fairly small as well. As a consequence it’s not uncommon to be OK with rewriting a process/actor/object. When new features come in that don’t quite fit your current model there’s a far more realistic consideration to delete and/or rewrite that section to have the feature fit the model better instead of working around it.