SlideShare a Scribd company logo
1 hour dive into
            Erlang/OTP


@jvalduvieco            @jordillonch
Problem domain
Lots of users
Lots of users
24x7x365
24x7x365
Lots of critical concurrent
       transactions
Lots of critical concurrent
       transactions
Hardware or software
      breaks
Hardware or software
      breaks
Lots of code changes
Lots of code changes
Unscalable
Unmaintainable   }   code
Unscalable
Unmaintainable   }   code
Maintenance/Debug
        in
production system
Maintenance/Debug
        in
production system
Does it sound to you?
The Erlang solution
Simplicity...
Minimize defensive
  programming
Typeless variables
Develop by contract
t-shirt function
      size
  If
 a
 function
 does
 not
 fit
 
on
 your
 t-shirt
 it
 is
 too
 long!
Single responsibility
      principle
No shared state
between entities
High Concurrency
High Concurrency
High concurrency
Light threads
Light threads
    hundreds of thousands of threads in one
      machine with a good cpu scheduler
Light threads
    hundreds of thousands of threads in one
      machine with a good cpu scheduler


    Lt

                                        Lt




               Lt
Message passing


     Lt

                  Lt




             Lt
Message passing
        A shared nothing architecture that
      communicates through message passing

     Lt

                                        Lt




                 Lt
Message passing
        A shared nothing architecture that
      communicates through message passing

     Lt

                                        Lt




                 Lt
Process Mailbox


     Lt

                  Lt




             Lt
Process Mailbox
     Every process has a mailbox with incoming
       messages, process take on convenience

     Lt

                                           Lt




                  Lt
No shared state


       Lt
   S
                     Lt
                          S



                Lt
            S
No shared state
    Every process its own internal state stored in
         a variable avoiding lock contention

       Lt
   S
                                             Lt
                                                  S



                    Lt
                S
Soft realtime
Soft realtime

You have no strict guarantees on
latency but language is designed
      to have low latency
High availability
High availability
 High availability
Supervised processes



       Pa




                       Pb
Supervised processes
     processes can be monitored by other
      processes, handling its termination


       Pa




                                  Pb
Fail early


                  Pa




             Pb
              S
Fail early
 Fail as soon as possible and let someone
handle bad data, someone will restart you

                                      Pa




                        Pb
                         S
Fail early
 Fail as soon as possible and let someone
handle bad data, someone will restart you

                                      Pa




                       Pb2
                          S
Hot code update




Pb
          Pa v1
              S

     Pc
Hot code update
     processes code and data can be replaced
             without loosing service




Pb
                   Pa v1
                       S

     Pc
Hot code update
     processes code and data can be replaced
             without loosing service




Pb
                   Pa v1
                      v2
                       S

     Pc
Distribution



Node            Node

P      P        P      P



P      P        P      P



P      P        P      P
Distribution
Processes run on nodes and can be located
            wherever they are


Node                        Node

P      P                     P      P



P      P                     P      P



P      P                     P      P
How does it look like?
1 hour dive into Erlang/OTP
Show me the code!
Demo 1
Hands on
The shell
Type on your console:

        erl
You should see:
Erlang R16B (erts-5.10.1) [source] [64-bit]
[smp:2:2] [async-threads:10] [hipe] [kernel-
poll:false] [dtrace]

Eshell V5.10.1   (abort with ^G)
1
Variables
Variables start
 Uppercase
Variables are immutable
Can contain any type
You can do things like...
1 Foo = 1.
1
2 Foo = 2.
** exception error: no match of right hand
side value 2
Foo
 is
 bounded
 to
 1
1 Foo = 1.
1
2 Foo = 2.
** exception error: no match of right hand
side value 2
Foo
 is
 bounded
 to
 1
1 Foo = 1.
1
          Foo
 ==
 2
 ?
2 Foo = 2.
** exception error: no match of right hand
side value 2
1 Foo = 1.
1
2 Bar = 2.
2
3 Foo = Bar.
** exception error: no match of right
hand side value 2
This is GREAT!
Now you have your
basic error checking
system implemented
Advanced
 types
[List]
[1,2,3,4,5,6]
You can do things like...
Iterate sequentially
1 MyList = [1,2,3,4].
[1,2,3,4]
2 [Head|Tail] = MyList.
[1,2,3,4]
3 Head.
1
4 Tail.
[2,3,4]
1 MyList = [1,2,3,4].
[1,2,3,4]
2 [Head|Tail] = MyList.
[1,2,3,4]
3 Head.
1
4 Tail.
[2,3,4]
1 MyList = [1,2,3,4].
[1,2,3,4]
2 [Head|Tail] = MyList.
[1,2,3,4]
3 Head.
1
4 Tail.
[2,3,4]
Do something to all or
 some items on a list
(list comprehensions)
1 MyList = [1, 2, 3, 4].
[1,2,3,4]
2 [X + 2 || X - MyList, X  2].
[5,6]
[Strings]
A list
You can do things like...
1 MyString = Erlang is not Ruby.
Erlang is not Ruby
1 MyString = Erlang is not Ruby.
Erlang is not Ruby
2 [Head2|Tail2] = MyString.
Erlang is not Ruby
3 Head2.
69 ASC
 =
 “E”
4 Tail2.
rlang is not Ruby
{Tuples}
{1,2,3}
Basic data container
random access
matcheable
You can do things like...
1 Mytuple = {1,2,3,4}.
{1,2,3,4}
2 A = 1.
1
3 B = 2.
2
4 {A,B,C,D} = {1,2,3,4}.
{1,2,3,4}
5 C.
3
6 D.
4
1 Mytuple = {1,2,3,4}.
{1,2,3,4}
2 A = 1.
1         A
 and
 B
 are
3 B = 2. bounded
 variables
2
4 {A,B,C,D} = {1,2,3,4}.
{1,2,3,4}
5 C.
3
6 D.
4
1 Mytuple = {1,2,3,4}.
{1,2,3,4}
2 A = 1.
1         A
 and
 B
 are
3 B = 2. bounded
 variables
2
4 {A,B,C,D} = {1,2,3,4}.
{1,2,3,4}
5 C. pattern
 matching
3                                           A==1?
6 D.                              B==2?
4
1 Mytuple = {1,2,3,4}.
{1,2,3,4}
2 A = 1.
1         A
 and
 B
 are
3 B = 2. bounded
 variables
2
4 {A,B,C,D} = {1,2,3,4}.                                                                                                  C
 and
 D
 are
 
{1,2,3,4}
                                                                                                                           unbounded
 
5 C. pattern
 matching
                                                                                                                           variables
3                                           A==1?
6 D.                              B==2?
4
functions
functions are types
single exit point
You can do things like...
foo_bar_func(Foo, Bar) -
 Result = Foo + Bar,
 Result.
This
 is
 a
 arity
 2
 function
 
                                              (2
 parameters)

foo_bar_func(Foo, Bar) -
 Result = Foo + Bar,
 Result.
This
 is
 a
 arity
 2
 function
 
                                                                        (2
 parameters)

foo_bar_func(Foo, Bar) -
 Result = Foo + Bar,
 Result.
                  means
 that
 more
 
                  code
 is
 to
 come
This
 is
 a
 arity
 2
 function
 
                                                                        (2
 parameters)

foo_bar_func(Foo, Bar) -
 Result = Foo + Bar,
 Result.
                  means
 that
 more
 
                  code
 is
 to
 come

                                                                                                                                                        means
 the
 function
 
                                                                                                                                                        code
 has
 ended
This
 is
 a
 arity
 2
 function
 
                                                                                                 (2
 parameters)

foo_bar_func(Foo, Bar) -
 Result = Foo + Bar,
 Result.
                                                                                                                    means

More Related Content

PDF
Kostis Sagonas: Cool Tools for Modern Erlang Program Developmen
PDF
Erlang
PDF
Erlang - Concurrent Language for Concurrent World
PPT
Os Worthington
PPT
Erlang OTP
PDF
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
PDF
1 hour dive into erlang
PPT
Comparing Cpp And Erlang For Motorola Telecoms Software
Kostis Sagonas: Cool Tools for Modern Erlang Program Developmen
Erlang
Erlang - Concurrent Language for Concurrent World
Os Worthington
Erlang OTP
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
1 hour dive into erlang
Comparing Cpp And Erlang For Motorola Telecoms Software

What's hot (20)

PDF
Keynote joearmstrong
PPTX
PPTX
Introduction to Python Programming
PDF
Erlang Developments: The Good, The Bad and The Ugly
DOC
Pré Descobrimento Do Brasil
PPTX
2CPP02 - C++ Primer
KEY
Tew4 Yatce presentation
KEY
TEW4 Yatce deprecated slides
PDF
Peyton jones-2011-parallel haskell-the_future
PDF
Simon Peyton Jones: Managing parallelism
PDF
Ebay News 2001 4 19 Earnings
PDF
P4 P Update January 2009
PDF
Ebay News 2000 10 19 Earnings
PDF
Create Your Own Language
PDF
NDC London 2014: Erlang Patterns Matching Business Needs
PPTX
Reverse-engineering: Using GDB on Linux
PDF
LIL Presentation
PPTX
Yacc (yet another compiler compiler)
PDF
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
PDF
Compilation and Execution
Keynote joearmstrong
Introduction to Python Programming
Erlang Developments: The Good, The Bad and The Ugly
Pré Descobrimento Do Brasil
2CPP02 - C++ Primer
Tew4 Yatce presentation
TEW4 Yatce deprecated slides
Peyton jones-2011-parallel haskell-the_future
Simon Peyton Jones: Managing parallelism
Ebay News 2001 4 19 Earnings
P4 P Update January 2009
Ebay News 2000 10 19 Earnings
Create Your Own Language
NDC London 2014: Erlang Patterns Matching Business Needs
Reverse-engineering: Using GDB on Linux
LIL Presentation
Yacc (yet another compiler compiler)
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Compilation and Execution
Ad

Viewers also liked (20)

KEY
Intro to Erlang
PDF
Getting real with erlang
ODP
An introduction to erlang
PDF
Introduction to Erlang
PDF
Using Clojure, NoSQL Databases and Functional-Style JavaScript to Write Gext-...
PDF
Let it crash! The Erlang Approach to Building Reliable Services
PDF
Building a Network IP Camera using Erlang
KEY
A web app in pure Clojure
PDF
Clojure Reducers / clj-syd Aug 2012
PDF
Distributed Erlang Systems In Operation
PDF
東京Node学園#8 Let It Crash!?
PDF
Monads in Clojure
PDF
Concurrency in Elixir with OTP
PPTX
The mystique of erlang
KEY
Erlang vs. Java
PPT
Let It Crash (@pavlobaron)
PDF
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
PDF
Elixir and OTP
PPTX
Erlang latest version & opensource projects
ODP
Elixir basics
Intro to Erlang
Getting real with erlang
An introduction to erlang
Introduction to Erlang
Using Clojure, NoSQL Databases and Functional-Style JavaScript to Write Gext-...
Let it crash! The Erlang Approach to Building Reliable Services
Building a Network IP Camera using Erlang
A web app in pure Clojure
Clojure Reducers / clj-syd Aug 2012
Distributed Erlang Systems In Operation
東京Node学園#8 Let It Crash!?
Monads in Clojure
Concurrency in Elixir with OTP
The mystique of erlang
Erlang vs. Java
Let It Crash (@pavlobaron)
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
Elixir and OTP
Erlang latest version & opensource projects
Elixir basics
Ad

Similar to 1 hour dive into Erlang/OTP (20)

PPTX
Halo2 Verifier in Move from ZERO to ONE.pptx
KEY
Some Rough Fibrous Material
ODP
Moving to Python 3
PDF
Python and Pytorch tutorial and walkthrough
PDF
The 1990s Called. They Want Their Code Back.
PDF
Specialized Compiler for Hash Cracking
PDF
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
PPTX
0.5mln packets per second with Erlang
PDF
GOTO Night with Todd Montgomery: Aeron: What, why and what next?
PDF
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
DOC
Principles of Compiler Design
DOC
Pcd(Mca)
DOC
PCD ?s(MCA)
DOC
Pcd(Mca)
DOC
Compiler Design Material 2
PPTX
Deep learning for biotechnology presentation
PPT
Python programming
PPTX
Welcome to python workshop
PPTX
Ruby -the wheel Technology
PPS
Disrupt
Halo2 Verifier in Move from ZERO to ONE.pptx
Some Rough Fibrous Material
Moving to Python 3
Python and Pytorch tutorial and walkthrough
The 1990s Called. They Want Their Code Back.
Specialized Compiler for Hash Cracking
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
0.5mln packets per second with Erlang
GOTO Night with Todd Montgomery: Aeron: What, why and what next?
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
Principles of Compiler Design
Pcd(Mca)
PCD ?s(MCA)
Pcd(Mca)
Compiler Design Material 2
Deep learning for biotechnology presentation
Python programming
Welcome to python workshop
Ruby -the wheel Technology
Disrupt

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Electronic commerce courselecture one. Pdf
PDF
KodekX | Application Modernization Development
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Dropbox Q2 2025 Financial Results & Investor Presentation
Digital-Transformation-Roadmap-for-Companies.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Chapter 3 Spatial Domain Image Processing.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
Network Security Unit 5.pdf for BCA BBA.
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MIND Revenue Release Quarter 2 2025 Press Release
Encapsulation_ Review paper, used for researhc scholars
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation theory and applications.pdf
Spectroscopy.pptx food analysis technology
“AI and Expert System Decision Support & Business Intelligence Systems”
20250228 LYD VKU AI Blended-Learning.pptx

1 hour dive into Erlang/OTP