SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
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

Mais conteúdo relacionado

Semelhante a Erlang crash course CiA Oslo 2012

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 3Claus Ibsen
 
Asynchronous Io Programming
Asynchronous Io ProgrammingAsynchronous Io Programming
Asynchronous Io Programmingl xf
 
Ruby Xml Mapping
Ruby Xml MappingRuby Xml Mapping
Ruby Xml MappingMarc Seeger
 
Optimizing MongoDB: Lessons Learned at Localytics
Optimizing MongoDB: Lessons Learned at LocalyticsOptimizing MongoDB: Lessons Learned at Localytics
Optimizing MongoDB: Lessons Learned at Localyticsandrew311
 
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 PuSpark Summit
 
Re-Architecting Spark For Performance Understandability
Re-Architecting Spark For Performance UnderstandabilityRe-Architecting Spark For Performance Understandability
Re-Architecting Spark For Performance UnderstandabilityJen Aman
 
Re-Architecting Spark For Performance Understandability
Re-Architecting Spark For Performance UnderstandabilityRe-Architecting Spark For Performance Understandability
Re-Architecting Spark For Performance UnderstandabilityJen Aman
 
Actor three languages
Actor three languagesActor three languages
Actor three languagesReidar Sollid
 
Erlang workshopdrammen
Erlang workshopdrammenErlang workshopdrammen
Erlang workshopdrammenReidar Sollid
 

Semelhante a 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
 

Último

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
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
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
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
 

Último (20)

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
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
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
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
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
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
 

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