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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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...
 

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