Upload
motiejus-jakstys
View
16
Download
0
Embed Size (px)
Citation preview
Why (not) ErlangMotiejus Jakštys @mo_kelione
All drawings acquired from http://learnyousomeerlang.com/
1/27
About me
no cultural meaning whatsoever
• PreErl: Linux, Python, C++• Started Erlang on 2011• Spil since 2012 May• Backend• Special care
I correctnessI reliability
2/27
This is about:1. Little bit of semantics (fault tolerance and distribution)2. Erlang comparison with different languages3. Strengths and weaknesses
3/27
Intro
IntroHigh-level properties / goals
SemanticsSmall processesNo shared stateLet it crashDistribution
ComparisonPythonJavaHaskell
Learning Erlang5/27
Intro High-level properties / goals
Telephone switches in late 1980s• Massively scalable• High availability• Soft real-time
AXD301 reported 9.99999999% (nine nines) availability 1
1Joe Armstrong: http://pragprog.com/articles/erlang6/27
Intro High-level properties / goals
Telephone switches in late 1980s• Massively scalable• High availability• Soft real-time
AXD301 reported 9.99999999% (nine nines) availability 1
1Joe Armstrong: http://pragprog.com/articles/erlang6/27
Semantics
IntroHigh-level properties / goals
SemanticsSmall processesNo shared stateLet it crashDistribution
ComparisonPythonJavaHaskell
Learning Erlang8/27
Semantics Small processes
• Quick to create: 660K proc/sec
• Memory footprint:Standard ∼ 300 words / process (2.4KB)Hibernated even less
9/27
Semantics Small processes
• Quick to create: 660K proc/sec• Memory footprint:
Standard ∼ 300 words / process (2.4KB)Hibernated even less
9/27
Semantics Small processes
• Process per user session• Process per DB transaction• Process per anything
Let’s try
10/27
Semantics Small processes
• Process per user session• Process per DB transaction• Process per anything
Let’s try
10/27
Semantics No shared state
• Only message passing• No shared memory 2
• Immutable data structures (no variables)
2almost11/27
Semantics No shared state
Consequences:
• Only critical sectionsavoid deadlocks
• Easier garbage collectionmark & sweep, no cycles!
12/27
Semantics No shared state
Consequences:• Only critical sections
avoid deadlocks
• Easier garbage collectionmark & sweep, no cycles!
12/27
Comparison
IntroHigh-level properties / goals
SemanticsSmall processesNo shared stateLet it crashDistribution
ComparisonPythonJavaHaskell
Learning Erlang16/27
Comparison Python
Python works for:• Systems programming• Classical web development• Scripting (amount of libraries and ease to include)• UI
17/27
Comparison Python
Python not really• Distributed, scalable• Protocol implementations• Computational performance• Live system debugging
18/27
Comparison Java
Java works for:• Computational performance
if you do not do allocations, eg. use freelists
• Processing XML and creating SOAP web services
I am serious
19/27
Comparison Java
Java works for:• Computational performance
if you do not do allocations, eg. use freelists
• Processing XML and creating SOAP web servicesI am serious
19/27
Comparison Java
Java not really:• Latency is unpredictable• Failure isolation• Encapsulation because of statically typed OO
You wanted a banana but what you got was a gorilla holding thebanana and the entire jungle - Joe Armstrong
20/27
Comparison Haskell
Good for:• High-level computationally expensive code
• State machines, parsers. VERY concise syntax• Being academic in CS• Compiles to single binary• UI (gtk2hs) is beautiful
Concepts like Java, but 10x less code
• Nothing beats pure functional reusability
21/27
Comparison Haskell
Good for:• High-level computationally expensive code• State machines, parsers. VERY concise syntax
• Being academic in CS• Compiles to single binary• UI (gtk2hs) is beautiful
Concepts like Java, but 10x less code
• Nothing beats pure functional reusability
21/27
Comparison Haskell
Good for:• High-level computationally expensive code• State machines, parsers. VERY concise syntax• Being academic in CS
• Compiles to single binary• UI (gtk2hs) is beautiful
Concepts like Java, but 10x less code
• Nothing beats pure functional reusability
21/27
Comparison Haskell
Good for:• High-level computationally expensive code• State machines, parsers. VERY concise syntax• Being academic in CS• Compiles to single binary
• UI (gtk2hs) is beautifulConcepts like Java, but 10x less code
• Nothing beats pure functional reusability
21/27
Comparison Haskell
Good for:• High-level computationally expensive code• State machines, parsers. VERY concise syntax• Being academic in CS• Compiles to single binary• UI (gtk2hs) is beautiful
Concepts like Java, but 10x less code
• Nothing beats pure functional reusability
21/27
Comparison Haskell
Good for:• High-level computationally expensive code• State machines, parsers. VERY concise syntax• Being academic in CS• Compiles to single binary• UI (gtk2hs) is beautiful
Concepts like Java, but 10x less code
• Nothing beats pure functional reusability
21/27
Comparison Haskell
Haskell not really:• Distribution (not production ready)• Concurrent code, either:
I pthreads-likeI or not prod ready
• Failure isolation
22/27
Learning Erlang
IntroHigh-level properties / goals
SemanticsSmall processesNo shared stateLet it crashDistribution
ComparisonPythonJavaHaskell
Learning Erlang23/27