SlideShare une entreprise Scribd logo
1  sur  17
Télécharger pour lire hors ligne
Crash course in Erlang
Erlang in 15 minutes

Page 1
Baksia CiA2012 Erlang

, 09.02.12
" Erlang
• The world is concurrent
• Things in the world don't share data
• Things communicate with messages
• Things fail
- Joe Armstrong

Page 2
Baksia CiA2012 Erlang

, 09.02.12
" What is Erlang
• Created and maintained by Ericsson (now open source)
• Functional, single assignment, strict evaluation, dynamic
typing
• Actor model, concurrent oriented, fault tolerant, soft-realtime
• Light weight processes that communicate using message
passing (an Erlang process is more light weight than a
Java thread)
• Erlang started life as a modified prolog
• Erlang shell, escript and compiled .beam bytecode
Page 3
Baksia CiA2012 Erlang

, 09.02.12
" Atoms and tuples
• An atom is a global constant starting with lower case
• A tuple is an ordered set of elements
• Your Java or C# class would be a tuple with an atom
identifier

Page 4
Baksia CiA2012 Erlang

, 09.02.12
" Erlang processes
• Erlang is designed for massive concurrency. Erlang
processes are light-weight (grow and shrink dynamically)
with small memory footprint, fast to create and terminate
and the scheduling overhead is low.
• A process is created by calling spawn
• Spawn returns a process Id PID in which you can send
messages to with the bang ! sign

Page 5
Baksia CiA2012 Erlang

, 09.02.12
" The *Real* Erlang "Hello, World!"

h"p://egarson.blogspot.com/2008/03/real-­‐erlang-­‐hello-­‐world.html	
  

Page 6
Baksia CiA2012 Erlang

, 09.02.12
" Pattern matching

Page 7
Baksia CiA2012 Erlang

, 09.02.12
" Variables and pattern matching

Page 8
Baksia CiA2012 Erlang

, 09.02.12
" Actors and pattern matching

Page 9
Baksia CiA2012 Erlang

, 09.02.12
" Loops

Page 10
Baksia CiA2012 Erlang

, 09.02.12
" No while or for loops ?

Page 11
Baksia CiA2012 Erlang

, 09.02.12
" Tail recursion

Page 12
Baksia CiA2012 Erlang

, 09.02.12
" Tail optimized recursion

	
  tail	
  recursion	
  as	
  seen	
  here	
  is	
  not	
  making	
  the	
  memory	
  
grow	
  because	
  when	
  the	
  virtual	
  machine	
  sees	
  a	
  funcAon	
  
calling	
  itself	
  in	
  a	
  tail	
  posiAon	
  (the	
  last	
  expression	
  to	
  be	
  
evaluated	
  in	
  a	
  funcAon),	
  it	
  eliminates	
  the	
  current	
  stack	
  
frame.	
  	
  

Page 13
Baksia CiA2012 Erlang

, 09.02.12
" Changes

Page 14
Baksia CiA2012 Erlang

, 09.02.12
" BIF Built In Functions
• BIFs are functions that are part of the Erlang language
• BIFs usually do tasks that are impossible to do in Erlang
•  list_to_tuple([22,cat,”text”]).
•  spawn(fun() -> my_fun(“Hello”) end).

Page 15
Baksia CiA2012 Erlang

, 09.02.12
" Learn you some Erlang
• Great site
• http://learnyousomeerlang.com/

Page 16
Baksia CiA2012 Erlang

, 09.02.12
CiA	
  2012	
  -­‐	
  Bridging	
  the	
  gaps	
  
8	
  februar	
  17:30	
  –	
  20:30	
  
Page 17
Baksia CiA2012 Erlang

, 09.02.12

Contenu connexe

Similaire à Erlang crash course CiA Oslo 2012

Asynchronous Io Programming
Asynchronous Io ProgrammingAsynchronous Io Programming
Asynchronous Io Programming
l xf
 
Actor three languages
Actor three languagesActor three languages
Actor three languages
Reidar Sollid
 

Similaire à Erlang crash course CiA Oslo 2012 (10)

Camel Day Italy 2021 - What's new in Camel 3
Camel Day Italy 2021 - What's new in Camel 3Camel Day Italy 2021 - What's new in Camel 3
Camel Day Italy 2021 - What's new in Camel 3
 
Asynchronous Io Programming
Asynchronous Io ProgrammingAsynchronous Io Programming
Asynchronous Io Programming
 
Ruby Xml Mapping
Ruby Xml MappingRuby Xml Mapping
Ruby Xml Mapping
 
Optimizing MongoDB: Lessons Learned at Localytics
Optimizing MongoDB: Lessons Learned at LocalyticsOptimizing MongoDB: Lessons Learned at Localytics
Optimizing MongoDB: Lessons Learned at Localytics
 
Spark Summit EU talk by Qifan Pu
Spark Summit EU talk by Qifan PuSpark Summit EU talk by Qifan Pu
Spark Summit EU talk by Qifan Pu
 
Re-Architecting Spark For Performance Understandability
Re-Architecting Spark For Performance UnderstandabilityRe-Architecting Spark For Performance Understandability
Re-Architecting Spark For Performance Understandability
 
Re-Architecting Spark For Performance Understandability
Re-Architecting Spark For Performance UnderstandabilityRe-Architecting Spark For Performance Understandability
Re-Architecting Spark For Performance Understandability
 
Actor three languages
Actor three languagesActor three languages
Actor three languages
 
Erlang workshopdrammen
Erlang workshopdrammenErlang workshopdrammen
Erlang workshopdrammen
 
Scala
ScalaScala
Scala
 

Dernier

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 

Dernier (20)

ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 

Erlang crash course CiA Oslo 2012

  • 1. Crash course in Erlang Erlang in 15 minutes Page 1 Baksia CiA2012 Erlang , 09.02.12
  • 2. " Erlang • The world is concurrent • Things in the world don't share data • Things communicate with messages • Things fail - Joe Armstrong Page 2 Baksia CiA2012 Erlang , 09.02.12
  • 3. " What is Erlang • Created and maintained by Ericsson (now open source) • Functional, single assignment, strict evaluation, dynamic typing • Actor model, concurrent oriented, fault tolerant, soft-realtime • Light weight processes that communicate using message passing (an Erlang process is more light weight than a Java thread) • Erlang started life as a modified prolog • Erlang shell, escript and compiled .beam bytecode Page 3 Baksia CiA2012 Erlang , 09.02.12
  • 4. " Atoms and tuples • An atom is a global constant starting with lower case • A tuple is an ordered set of elements • Your Java or C# class would be a tuple with an atom identifier Page 4 Baksia CiA2012 Erlang , 09.02.12
  • 5. " Erlang processes • Erlang is designed for massive concurrency. Erlang processes are light-weight (grow and shrink dynamically) with small memory footprint, fast to create and terminate and the scheduling overhead is low. • A process is created by calling spawn • Spawn returns a process Id PID in which you can send messages to with the bang ! sign Page 5 Baksia CiA2012 Erlang , 09.02.12
  • 6. " The *Real* Erlang "Hello, World!" h"p://egarson.blogspot.com/2008/03/real-­‐erlang-­‐hello-­‐world.html   Page 6 Baksia CiA2012 Erlang , 09.02.12
  • 7. " Pattern matching Page 7 Baksia CiA2012 Erlang , 09.02.12
  • 8. " Variables and pattern matching Page 8 Baksia CiA2012 Erlang , 09.02.12
  • 9. " Actors and pattern matching Page 9 Baksia CiA2012 Erlang , 09.02.12
  • 10. " Loops Page 10 Baksia CiA2012 Erlang , 09.02.12
  • 11. " No while or for loops ? Page 11 Baksia CiA2012 Erlang , 09.02.12
  • 12. " Tail recursion Page 12 Baksia CiA2012 Erlang , 09.02.12
  • 13. " Tail optimized recursion  tail  recursion  as  seen  here  is  not  making  the  memory   grow  because  when  the  virtual  machine  sees  a  funcAon   calling  itself  in  a  tail  posiAon  (the  last  expression  to  be   evaluated  in  a  funcAon),  it  eliminates  the  current  stack   frame.     Page 13 Baksia CiA2012 Erlang , 09.02.12
  • 14. " Changes Page 14 Baksia CiA2012 Erlang , 09.02.12
  • 15. " BIF Built In Functions • BIFs are functions that are part of the Erlang language • BIFs usually do tasks that are impossible to do in Erlang •  list_to_tuple([22,cat,”text”]). •  spawn(fun() -> my_fun(“Hello”) end). Page 15 Baksia CiA2012 Erlang , 09.02.12
  • 16. " Learn you some Erlang • Great site • http://learnyousomeerlang.com/ Page 16 Baksia CiA2012 Erlang , 09.02.12
  • 17. CiA  2012  -­‐  Bridging  the  gaps   8  februar  17:30  –  20:30   Page 17 Baksia CiA2012 Erlang , 09.02.12