SlideShare a Scribd company logo
1 of 35
Download to read offline
A sip of Elixir
@emadb
What language is this?
Erlang
• 1987 - First version written in Prolog.
Good but slow
• Early ’90 - BEAM
• 1992 - Erlang in production
• In 1998 Ericsson announced the
AXD301 switch, containing over a
million lines of Erlang and reported to
achieve a high availability of nine “9"s.
• 1999 Ericsson banned the use of
Erlang
• 2004 Ericsson lifted the ban
Erlang
Concurrency Oriented
Programming Languages
COP Languages
In languages like <noname> they forgot about concurrency. It either
wasn’t designed in from the beginning or else it was added on as an
afterthought.

Armstrong, 2002
COP Languages
• Processes are truly independent
• No penalty for massive parallelism
• No unavoidable penalty for distribution
• Concurrent behaviour of program same on all OSs
• Can deal with failure
COP is nice
• The world is parallel
• The world is distributed
• Things fail
• Make more powerful by adding more processors
• Our brain intuitively understand parallelism
Erlang is COP
Open Telecom Platform
• Delivered with Erlang and written in Erlang, it contains:
• an Erlang interpreter (which is called BEAM)
• an Erlang compiler
• a protocol for communication between servers (nodes)
• An Object Request Broker
• a static analysis tool called Dialyzer
• a distributed database server (Mnesia)
• many other libraries and utilities
Elixir
• R&D project form
Plataformatec (2011)
• His goals were to enable
higher extensibility and
productivity in the
Erlang VM while keeping
compatibility with
Erlang's ecosystem
Features
• Compiles to bytecode for the BEAM
• Functional language, everything is an expression
• Erlang functions can be called without costs
• Metaprogramming with macros
• Polymorphism via a mechanism called protocols and
behaviours
• Pattern matching
• Expressive language that programmers love (like Ruby!)
Elixir today
• Version 1.6.5
• New version every 6 months (1.7 in July)
• Hex package management (~6k packages)
• Vibrant community
A tour of the language
Processes
• Everything runs in a process
• Process is isolated
• Process communicate using messages
• Inside a process code runs in a single thread
GenServer
• The basic behaviour for a general purpose process
• Has state
• A “public interface” (client api vs. server callbacks)
• Callbacks to handle messages and send responses
• Terminate callback
GenServer
• init(args) :: {:ok, state}

A sort of “constructor” for the server
• handle_call(request, from, state) ::
{:reply, reply, new_state}

Handle synchronous messages
• handle_cast(request, state) :: {:noreply,
new_state}

Handle asynchronous messages
Redux?
GenServer and…
• GenStage: Producer-Consumer pipelines
• GenStatem: Event driven state machine
• Agent: State management
Actor model
• GenServer is the basic block for the actor model
• Code inside GenServer is single thread
• GenServer has it’s own message queue
• GenServer can create other Genservers
Supervisor
• A process to monitor other processes
• Handle failures and restarts child as needed
Supervisor
• Restarting strategy
• :one_for_one - if a child process terminates, only
that process is restarted.
• :one_for_all - if a child process terminates, all other
child processes are terminated and then all child
processes are restarted.
• :rest_for_one - if a child process terminates, the
“rest” of the child processes are terminated. Then the
terminated child process and the rest of the child
processes are restarted.
Applications
• Applications are a bundle of sub-application
• Application consists of a manifest
• Dependencies are sub-application
• Usually it starts the main supervisors and the
dependent applications
Other gems
• Macros
• Hot code swapping
• Umbrella projects
• Remote debugging and inspection
• Community ❤
Tooling
• mix is rake for Elixir
• https://hex.pm is the package registry
• Spec and Dyalizer
• Release with distillery (erts inside…no
prerequisites!)
Libraries and
Frameworks
Phoenix
Ecto
Nerves
Absinthe
Online Multiplayer game
In few lines of Elixir
Mars Rovers
Application
RoverSup
rover_1 rover_2 rover_n
WorldMap
Is it production ready?
FAQ
• Should I learn Erlang to use Elixir?
• Is it fast?
• To spawn or not to spawn?
• Does it run on windows?
Thank you

More Related Content

What's hot

JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...jazoon13
 
Clojure's take on concurrency
Clojure's take on concurrencyClojure's take on concurrency
Clojure's take on concurrencyyoavrubin
 
Kubernetes: The Very Hard Way
Kubernetes: The Very Hard WayKubernetes: The Very Hard Way
Kubernetes: The Very Hard WayRob Boll
 
.Net framework
.Net framework.Net framework
.Net frameworksanya6900
 
SyPy IronPython
SyPy IronPythonSyPy IronPython
SyPy IronPythonNick Hodge
 
.Net overview
.Net overview.Net overview
.Net overviewmadydud
 
Parallel language and compiler
Parallel language and compilerParallel language and compiler
Parallel language and compilerSVijaylakshmi
 
ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019Rory Graves
 
The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)lennartkats
 
Translating Apereo Software: A Case Study using Sakai and Transifex
Translating Apereo Software:  A Case Study using Sakai and TransifexTranslating Apereo Software:  A Case Study using Sakai and Transifex
Translating Apereo Software: A Case Study using Sakai and Transifexyuji tokiwa
 
Interpreters & Debuggers
Interpreters  &  DebuggersInterpreters  &  Debuggers
Interpreters & DebuggersMalek Sumaiya
 
Assmbly language mcqs
Assmbly language mcqsAssmbly language mcqs
Assmbly language mcqssunil kumar
 
Desarrollo multiplataforma con el framework .net
Desarrollo multiplataforma con el framework .netDesarrollo multiplataforma con el framework .net
Desarrollo multiplataforma con el framework .netDan Ardelean
 

What's hot (20)

JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
 
Clojure's take on concurrency
Clojure's take on concurrencyClojure's take on concurrency
Clojure's take on concurrency
 
.NET Framework
.NET Framework.NET Framework
.NET Framework
 
Kubernetes: The Very Hard Way
Kubernetes: The Very Hard WayKubernetes: The Very Hard Way
Kubernetes: The Very Hard Way
 
Microsoft .Net Technology
Microsoft .Net TechnologyMicrosoft .Net Technology
Microsoft .Net Technology
 
Evalution about programming language part 1
Evalution about programming language part 1Evalution about programming language part 1
Evalution about programming language part 1
 
Advanced AOP
Advanced AOPAdvanced AOP
Advanced AOP
 
.Net overview by cetpa
.Net overview by cetpa.Net overview by cetpa
.Net overview by cetpa
 
.Net framework
.Net framework.Net framework
.Net framework
 
SyPy IronPython
SyPy IronPythonSyPy IronPython
SyPy IronPython
 
.Net overview
.Net overview.Net overview
.Net overview
 
Parallel language and compiler
Parallel language and compilerParallel language and compiler
Parallel language and compiler
 
Why Kotlin?
Why Kotlin?Why Kotlin?
Why Kotlin?
 
Net overview
Net overviewNet overview
Net overview
 
ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019
 
The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)
 
Translating Apereo Software: A Case Study using Sakai and Transifex
Translating Apereo Software:  A Case Study using Sakai and TransifexTranslating Apereo Software:  A Case Study using Sakai and Transifex
Translating Apereo Software: A Case Study using Sakai and Transifex
 
Interpreters & Debuggers
Interpreters  &  DebuggersInterpreters  &  Debuggers
Interpreters & Debuggers
 
Assmbly language mcqs
Assmbly language mcqsAssmbly language mcqs
Assmbly language mcqs
 
Desarrollo multiplataforma con el framework .net
Desarrollo multiplataforma con el framework .netDesarrollo multiplataforma con el framework .net
Desarrollo multiplataforma con el framework .net
 

Similar to A sip of Elixir

Repeating History...On Purpose...with Elixir
Repeating History...On Purpose...with ElixirRepeating History...On Purpose...with Elixir
Repeating History...On Purpose...with ElixirBarry Jones
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Paolo Negri
 
Erlang, the big switch in social games
Erlang, the big switch in social gamesErlang, the big switch in social games
Erlang, the big switch in social gamesWooga
 
Erlang workshopdrammen
Erlang workshopdrammenErlang workshopdrammen
Erlang workshopdrammenReidar Sollid
 
Intro to elixir and phoenix
Intro to elixir and phoenixIntro to elixir and phoenix
Intro to elixir and phoenixJared Smith
 
Linux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsLinux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsQUONTRASOLUTIONS
 
11 scripting languages
11 scripting languages11 scripting languages
11 scripting languagescherrybear2014
 
Julia Computing - an alternative to Hadoop
Julia Computing - an alternative to HadoopJulia Computing - an alternative to Hadoop
Julia Computing - an alternative to HadoopShaurya Shekhar
 
Phoenix for Rubyists
Phoenix for RubyistsPhoenix for Rubyists
Phoenix for RubyistsDoug Goldie
 
computer languages
computer languagescomputer languages
computer languagesRajendran
 
Real World Elixir Deployment
Real World Elixir DeploymentReal World Elixir Deployment
Real World Elixir DeploymentPete Gamache
 
Writing Well-Behaved Unix Utilities
Writing Well-Behaved Unix UtilitiesWriting Well-Behaved Unix Utilities
Writing Well-Behaved Unix UtilitiesRob Miller
 
Elixir Programming Language 101
Elixir Programming Language 101Elixir Programming Language 101
Elixir Programming Language 101Around25
 
Week 08_Basics of Compiler Construction.pdf
Week 08_Basics of Compiler Construction.pdfWeek 08_Basics of Compiler Construction.pdf
Week 08_Basics of Compiler Construction.pdfAnonymousQ3EMYoWNS
 
PCSG_Computer_Science_Unit_1_Lecture_2.pptx
PCSG_Computer_Science_Unit_1_Lecture_2.pptxPCSG_Computer_Science_Unit_1_Lecture_2.pptx
PCSG_Computer_Science_Unit_1_Lecture_2.pptxAliyahAli19
 

Similar to A sip of Elixir (20)

Repeating History...On Purpose...with Elixir
Repeating History...On Purpose...with ElixirRepeating History...On Purpose...with Elixir
Repeating History...On Purpose...with Elixir
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"
 
Erlang, the big switch in social games
Erlang, the big switch in social gamesErlang, the big switch in social games
Erlang, the big switch in social games
 
Erlang/Elixir and OTP
Erlang/Elixir and OTPErlang/Elixir and OTP
Erlang/Elixir and OTP
 
Erlang workshopdrammen
Erlang workshopdrammenErlang workshopdrammen
Erlang workshopdrammen
 
Intro to elixir and phoenix
Intro to elixir and phoenixIntro to elixir and phoenix
Intro to elixir and phoenix
 
Introduction to multicore .ppt
Introduction to multicore .pptIntroduction to multicore .ppt
Introduction to multicore .ppt
 
Linux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsLinux operating system by Quontra Solutions
Linux operating system by Quontra Solutions
 
11 scripting languages
11 scripting languages11 scripting languages
11 scripting languages
 
Julia Computing - an alternative to Hadoop
Julia Computing - an alternative to HadoopJulia Computing - an alternative to Hadoop
Julia Computing - an alternative to Hadoop
 
Phoenix for Rubyists
Phoenix for RubyistsPhoenix for Rubyists
Phoenix for Rubyists
 
computer languages
computer languagescomputer languages
computer languages
 
Real World Elixir Deployment
Real World Elixir DeploymentReal World Elixir Deployment
Real World Elixir Deployment
 
MPI, Erlang and the web
MPI, Erlang and the webMPI, Erlang and the web
MPI, Erlang and the web
 
Writing Well-Behaved Unix Utilities
Writing Well-Behaved Unix UtilitiesWriting Well-Behaved Unix Utilities
Writing Well-Behaved Unix Utilities
 
Erlang os
Erlang osErlang os
Erlang os
 
Elixir Programming Language 101
Elixir Programming Language 101Elixir Programming Language 101
Elixir Programming Language 101
 
Week 08_Basics of Compiler Construction.pdf
Week 08_Basics of Compiler Construction.pdfWeek 08_Basics of Compiler Construction.pdf
Week 08_Basics of Compiler Construction.pdf
 
PCSG_Computer_Science_Unit_1_Lecture_2.pptx
PCSG_Computer_Science_Unit_1_Lecture_2.pptxPCSG_Computer_Science_Unit_1_Lecture_2.pptx
PCSG_Computer_Science_Unit_1_Lecture_2.pptx
 
Elixir
ElixirElixir
Elixir
 

More from Emanuele DelBono

More from Emanuele DelBono (13)

The simplest thing that could possibly work
The simplest thing that could possibly workThe simplest thing that could possibly work
The simplest thing that could possibly work
 
Una crescita armoniosa
Una crescita armoniosaUna crescita armoniosa
Una crescita armoniosa
 
React.js in real world apps.
React.js in real world apps. React.js in real world apps.
React.js in real world apps.
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
From ActiveRecord to EventSourcing
From ActiveRecord to EventSourcingFrom ActiveRecord to EventSourcing
From ActiveRecord to EventSourcing
 
Ruby seen by a C# developer
Ruby seen by a C# developerRuby seen by a C# developer
Ruby seen by a C# developer
 
Ruby loves DDD
Ruby loves DDDRuby loves DDD
Ruby loves DDD
 
An introduction to knockout.js
An introduction to knockout.jsAn introduction to knockout.js
An introduction to knockout.js
 
Node azure
Node azureNode azure
Node azure
 
Da programmatore a CEO
Da programmatore a CEODa programmatore a CEO
Da programmatore a CEO
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
Test driving an MVVM App
Test driving an MVVM AppTest driving an MVVM App
Test driving an MVVM App
 
Mocking
MockingMocking
Mocking
 

Recently uploaded

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

A sip of Elixir

  • 1. A sip of Elixir @emadb
  • 3. Erlang • 1987 - First version written in Prolog. Good but slow • Early ’90 - BEAM • 1992 - Erlang in production • In 1998 Ericsson announced the AXD301 switch, containing over a million lines of Erlang and reported to achieve a high availability of nine “9"s. • 1999 Ericsson banned the use of Erlang • 2004 Ericsson lifted the ban
  • 6. COP Languages In languages like <noname> they forgot about concurrency. It either wasn’t designed in from the beginning or else it was added on as an afterthought.
 Armstrong, 2002
  • 7. COP Languages • Processes are truly independent • No penalty for massive parallelism • No unavoidable penalty for distribution • Concurrent behaviour of program same on all OSs • Can deal with failure
  • 8. COP is nice • The world is parallel • The world is distributed • Things fail • Make more powerful by adding more processors • Our brain intuitively understand parallelism
  • 10. Open Telecom Platform • Delivered with Erlang and written in Erlang, it contains: • an Erlang interpreter (which is called BEAM) • an Erlang compiler • a protocol for communication between servers (nodes) • An Object Request Broker • a static analysis tool called Dialyzer • a distributed database server (Mnesia) • many other libraries and utilities
  • 11.
  • 12. Elixir • R&D project form Plataformatec (2011) • His goals were to enable higher extensibility and productivity in the Erlang VM while keeping compatibility with Erlang's ecosystem
  • 13. Features • Compiles to bytecode for the BEAM • Functional language, everything is an expression • Erlang functions can be called without costs • Metaprogramming with macros • Polymorphism via a mechanism called protocols and behaviours • Pattern matching • Expressive language that programmers love (like Ruby!)
  • 14. Elixir today • Version 1.6.5 • New version every 6 months (1.7 in July) • Hex package management (~6k packages) • Vibrant community
  • 15. A tour of the language
  • 16. Processes • Everything runs in a process • Process is isolated • Process communicate using messages • Inside a process code runs in a single thread
  • 17. GenServer • The basic behaviour for a general purpose process • Has state • A “public interface” (client api vs. server callbacks) • Callbacks to handle messages and send responses • Terminate callback
  • 18. GenServer • init(args) :: {:ok, state}
 A sort of “constructor” for the server • handle_call(request, from, state) :: {:reply, reply, new_state}
 Handle synchronous messages • handle_cast(request, state) :: {:noreply, new_state}
 Handle asynchronous messages Redux?
  • 19. GenServer and… • GenStage: Producer-Consumer pipelines • GenStatem: Event driven state machine • Agent: State management
  • 20. Actor model • GenServer is the basic block for the actor model • Code inside GenServer is single thread • GenServer has it’s own message queue • GenServer can create other Genservers
  • 21. Supervisor • A process to monitor other processes • Handle failures and restarts child as needed
  • 22. Supervisor • Restarting strategy • :one_for_one - if a child process terminates, only that process is restarted. • :one_for_all - if a child process terminates, all other child processes are terminated and then all child processes are restarted. • :rest_for_one - if a child process terminates, the “rest” of the child processes are terminated. Then the terminated child process and the rest of the child processes are restarted.
  • 23. Applications • Applications are a bundle of sub-application • Application consists of a manifest • Dependencies are sub-application • Usually it starts the main supervisors and the dependent applications
  • 24. Other gems • Macros • Hot code swapping • Umbrella projects • Remote debugging and inspection • Community ❤
  • 25. Tooling • mix is rake for Elixir • https://hex.pm is the package registry • Spec and Dyalizer • Release with distillery (erts inside…no prerequisites!)
  • 28. Ecto
  • 31. Online Multiplayer game In few lines of Elixir
  • 34. FAQ • Should I learn Erlang to use Elixir? • Is it fast? • To spawn or not to spawn? • Does it run on windows?