SlideShare ist ein Scribd-Unternehmen logo
1 von 145
Erlang, The Road Movie
           Lessons learned in Erlang Land




                                @drkrab
                          Kresten Krab Thorup
                                  CTO, Trifork
1
About Me
    ■ Language Geek Emacs/TeX Hacker,
      GCC: Objective C, NeXT, Compiled Java,
      Ph.D. from Århus [language design]
    ■ Developer J2EE AppServer,
      CORBA/RMI, XA-TM, Java Firefighter
    ■ Trifork CTO Technology Adoption
      Conference Editor, GOTO/QCon

2
’90s Object Revolution




3
’90s Object Revolution
    Increased
    Complexity




4
’90s Object Revolution
       Increased
       Complexity




    Program Structure

4
’90s Object Revolution
       Increased
       Complexity




         Component Reuse
    Program Structure

4
’90s Object Revolution
       Increased
       Complexity




              Domain Modeling
         Component Reuse
    Program Structure

4
Languages



                              C#   Ruby
              C++
         Smalltalk     Java
    Simula         Objective-C

5
Thinking Tools
              Patterns               DDD

               UML

         OOA&D


                                C#   Ruby
              C++
         Smalltalk       Java
    Simula         Objective-C

6
American               Scandinavian
      School                   School
       Increased
       Complexity




              Domain Modeling
         Component Reuse
    Program Structure

7
American               Scandinavian
      School                   School
       Increased                Conceptual
       Complexity                Modeling

                                Pa rticipatory
                                    Design
              Domain Modeling
         Component Reuse
    Program Structure

7
American               Scandinavian
      School                   School
      Economics
      Increased                 Conceptual
         Reuse
      Complexity                 Modeling
      Engineering
                                Pa rticipatory
                                    Design
              Domain Modeling
         Component Reuse
    Program Structure

7
American                 Scandinavian
      School                     School
                        Internet
       Increased
       Complexity




              Domain Modeling
         Component Reuse
    Program Structure

8
Internet
       Increased
       Complexity




              Domain Modeling
         Component Reuse
    Program Structure

9
More Complexity




10
More Complexity
     Infrastructure made of Software




10
More Complexity
     Infrastructure made of Software




11
More Complexity
     Infrastructure made of Software




12
More Complexity
        Infrastructure made of Software




     Fault Tolerance, Availability, QoS




12
More Complexity
        Infrastructure made of Software




          Integration, Coordination
     Fault Tolerance, Availability, QoS




12
More Complexity
        Infrastructure made of Software




                Cloud, Multi-Core
          Integration, Coordination
     Fault Tolerance, Availability, QoS




12
More Complexity     We  ’re struggling to
                               n dle these with an
                            haSoftware
        Infrastructure made of
                               object mindset!

                Cloud, Multi-Core
          Integration, Coordination
     Fault Tolerance, Availability, QoS




12
Time for a new
         revolution?




                Cloud, Multi-Core
          Integration, Coordination
     Fault Tolerance, Availability, QoS




13
What’s a
     Revolution?




     Thomas Kuhn
     The Structure of Scientific Revolutions
14
paradigm



 paradigm




15
paradigm



 paradigm




15
paradigm



 paradigm

 normal
 science




15
paradigm
           observe
           anomalies

 paradigm

 normal
 science




15
paradigm
           observe
           anomalies

 paradigm       CRISIS


 normal
 science




15
paradigm
           observe
           anomalies

 paradigm       CRISIS


 normal          revolutionary
 science         science




15
paradigm
           observe
           anomalies             normal
                                 science
 paradigm       CRISIS


 normal          revolutionary
 science         science




15
What is the
                                      right paradigm to
                                       cope with these?


                Cloud, Multi-Core
          Integration, Coordination
     Fault Tolerance, Availability, QoS




16
What is the
                                      right paradigm to
                                       cope with these?


                Cloud, Multi-Core
          Integration, Coordination
     Fault Tolerance, Availability, QoS
                                 Parallel Compilers
                           Erlang, Actor Models
                      Functional, Data-Parallel
16
Johnso   n’s blog
             Ralph             Next J  ava”             What is the
             “Erl  ang, the                     right paradigm to
                                               a very with these?
                                    g to be cope
                    rlang   is goin           Its main
              ... E                uage ...
               imp   orta nt lang               erfectly
                             e is tha t it is p
               a    Cloud, Multi-Core core, web
                 dvantag
                         for the   multi-
                suite  d
           Integration, Coordinationt, i         t is the
                             future . In fac
                services                  -QoSd
                                       ck soli
                   NLY ma     ture, ro
     Fault Tolerance, Availability,
                                               ble for
                 O
                           ge that  is suita
                 lang   ua                Parallel stems
                                           able sy Compilers
                                 hly scal
                       ing hig Erlang, Actor iModels
                                                  h nes.
                  writ                  ore mac
                      run on    multic
                  to
                           Functional, Data-Parallel
16
Objects




               Actors


17
Actors



     Objects




17
Actors



     Objects



       American
        School
       Performance
       Engineering
17
Actors



     Objects



       American      Scandinavian
        School          School
       Performance    Conceptual
       Engineering     Modeling
17
Actors

               anomalies

     Objects



       American            Scandinavian
        School                School
       Performance          Conceptual
       Engineering           Modeling
17
Actors

               Quest in this talk:
                anomalies

     Objects
         If Actor-Prog ramming
                     Paradigm,
          is the new Scandinavian
       American
         School re the
         What a        anomalies
                             School
              ance uld see Coow? tual
       Perform sho
            we             n ncep
       Engineering           Modeling
17
18
Making reliable
     distributed control systems
     in the presence of errors




19
Making reliable
     distributed control systems
     in the presence of errors




19
Making reliable
     distributed control systems
     in the presence of errors
      ■ The “secret weapon” for
        Ericsson’s market leading,
        real-time telephony
        systems.




19
Making reliable
     distributed control systems
     in the presence of errors
      ■ The “secret weapon” for
        Ericsson’s market leading,
        real-time telephony
        systems.
      ■ 20+ years of experience
        to learn from.

19
Erlang/OTP
       Open Telecommunications Platform


                         ■ Embedded
                           Distributed Systems
                         ■ High Availability
                         ■ In-Production
                           Upgrades


20
How to Learn Erlang




21
How to Learn Erlang

           diss ect a frog,
     Don’t
          Build  One!
                    Nicolas Negropont
                                      e




21
Your Erlang Program
            Platform Framework
     BEAM




       BEAM Emulator            BIFs
             Your favorite OS




22
Your Erlang Program
            Platform Framework
     BEAM




       BEAM Emulator            BIFs



             Your favorite OS


22
Your Erlang Program
            Platform Framework
     BEAM




            ERJANG              BIFs
     JVM




            Java Virtual Machine
             Your favorite OS


23
Anomalies in
     the object-oriented
          world view


24
Figure 2-1                                      Interface and implementation

                                   interface                                                implementation




                                                                               11
                                                              10
                                                             9
                                                              8
                                                                               7
                                                                                      6


25                                 Looking at such a unit from the inside, as the implem
     Graphics from Object-Oriented Programming with Objective C, Apple, 2011
Figure 3-1                  An object
     Encapsulation

                             m et h o d




                                          me
                  et h o d     data




                                          thod
                m

                             m et h o d



26
and a data structure that serves
     Figure 3-1          An object          fields of its data structure are it
                                            hide them from the rest of the
        The insight of object-oriented programming is to combine st
           m et h o da high-level unit, an object, and to give it language su
        data—in                             Figure 3-1        An object




                                      me
        and a data structure that serves those functions. The function

     m et h o d
            data




                                       thod
        fields of its data structure are its instanceovariables. The met
        hide them from the rest of the program,   m et has Figure 3-1 illustrat
                                                          d




                                                                                     me
                                                           m et h o d
                     m et h o d
                                                                          data




                                                                                     thod
             Figure 3-1                        An object
                                                                        m et h o d
                m et h o d
     If you’ve ever tackled any kind of difficult programming problem
     groups of functions that work on a particular kind of data—implic
                                            me
                  m et h o d




     Object-oriented programming makes these function groups expl
                 data
                                              thod

     group, rather than its components.If you’ve ever tackled any kind
                                           The only way to an object’s dat
                               m et h o d groups of functions that work o
                                          Object-oriented programming
     By combining both state and behavior in a single unit, an object b
     really is greater than the sum of itsgroup, rather thanis a componen
                                           parts. An object its kind of se
     over a specific functional area. It can play a full-fledged modular
         If you’ve ever tackled any kind By difficult programmingand be
                                          of combining both state prob
                                          really is greater than the sum o
         groups of functions that work on a particular kind of data—im
27   Terminology: Object-oriented terminology varies from language
and a data structure that serves
     Figure 3-1          An object          fields of its data structure are it
                                            hide them from the rest of the
        The insight of object-oriented programming is to combine st
           m et h o da high-level unit, an object, and to give it language su
        data—in                             Figure 3-1        An object




                                      me
        and a data structure that serves those functions. The function

     m et h o d
            data




                                       thod
        fields of its data structure are its instanceovariables. The met
        hide them from the rest of the program,   m et has Figure 3-1 illustrat
                                                          d




                                                                                     me
                                                           m et h o d
                     m et h o d
                                                                          data




                                                                                     thod
             Figure 3-1                        An object
                                                                        m et h o d
                m et h o d
     If you’ve ever tackled any kind of difficult programming problem
     groups of functions that work on a particular kind of data—implic
                                            me
                  m et h o d




     Object-oriented programming makes these function groups expl
                 data
                                              thod

     group, rather than its components.If you’ve ever tackled any kind
                                           The only way to an object’s dat
                               m et h o d groups of functions that work o
                                          Object-oriented programming
     By combining both state and behavior in a single unit, an object b
     really is greater than the sum of itsgroup, rather thanis a componen
                                           parts. An object its kind of se
     over a specific functional area. It can play a full-fledged modular
         If you’ve ever tackled any kind By difficult programmingand be
                                          of combining both state prob
                                          really is greater than the sum o
         groups of functions that work on a particular kind of data—im
27   Terminology: Object-oriented terminology varies from language
and a data structure that serves
     Figure 3-1          An object          fields of its data structure are it
                                            hide them from the rest of the
        The insight of object-oriented programming is to combine st
           m et h o da high-level unit, an object, and to give it language su
        data—in                             Figure 3-1        An object




                                      me
        and a data structure that serves those functions. The function

     m et h o d
            data




                                       thod
        fields of its data structure are its instanceovariables. The met
        hide them from the rest of the program,   m et has Figure 3-1 illustrat
                                                          d




                                                                                     me
                                                           m et h o d
                     m et h o d
                                                                          data




                                                                                     thod
             Figure 3-1                        An object
                                                                        m et h o d
                m et h o d
     If you’ve ever tackled any kind of difficult programming problem
     groups of functions that work on a particular kind of data—implic
                                            me
                  m et h o d




     Object-oriented programming makes these function groups expl
                 data
                                              thod

     group, rather than its components.If you’ve ever tackled any kind
                                           The only way to an object’s dat
                               m et h o d groups of functions that work o
                                          Object-oriented programming
     By combining both state and behavior in a single unit, an object b
     really is greater than the sum of itsgroup, rather thanis a componen
                                           parts. An object its kind of se
     over a specific functional area. It can play a full-fledged modular
         If you’ve ever tackled any kind By difficult programmingand be
                                          of combining both state prob
                                          really is greater than the sum o
         groups of functions that work on a particular kind of data—im
27   Terminology: Object-oriented terminology varies from language
and a data structure that serves
     Figure 3-1          An object          fields of its data structure are it
                                            hide them from the rest of the
        The insight of object-oriented programming is to combine st
           m et h o da high-level unit, an object, and to give it language su
        data—in                             Figure 3-1        An object




                                      me
        and a data structure that serves those functions. The function

     m et h o d
            data




                                       thod
        fields of its data structure are its instanceovariables. The met
        hide them from the rest of the program,   m et has Figure 3-1 illustrat
                                                          d




                                                                                     me
                                                           m et h o d
                     m et h o d
                                                                          data




                                                                                     thod
             Figure 3-1                        An object
                                                                        m et h o d
                m et h o d
     If you’ve ever tackled any kind of difficult programming problem
     groups of functions that work on a particular kind of data—implic
                                            me
                  m et h o d




     Object-oriented programming makes these function groups expl
                 data
                                              thod

     group, rather than its components.If you’ve ever tackled any kind
                                           The only way to an object’s dat
                               m et h o d groups of functions that work o
                                          Object-oriented programming
     By combining both state and behavior in a single unit, an object b
     really is greater than the sum of itsgroup, rather thanis a componen
                                           parts. An object its kind of se
     over a specific functional area. It can play a full-fledged modular
         If you’ve ever tackled any kind By difficult programmingand be
                                          of combining both state prob
                                          really is greater than the sum o
         groups of functions that work on a particular kind of data—im
27   Terminology: Object-oriented terminology varies from language
and a data structure that serves
     Figure 3-1          An object          fields of its data structure are it
                                            hide them from the rest of the
        The insight of object-oriented programming is to combine st
           m et h o da high-level unit, an object, and to give it language su
        data—in                             Figure 3-1        An object




                                      me
        and a data structure that serves those functions. The function

     m et h o d
            data




                                       thod
        fields of its data structure are its instanceovariables. The met
        hide them from the rest of the program,   m et has Figure 3-1 illustrat
                                                          d




                                                                                     me
                                                           m et h o d
                     m et h o d
                                                                          data




                                                                                     thod
             Figure 3-1                        An object
                                                                        m et h o d
                m et h o d
     If you’ve ever tackled any kind of difficult programming problem
     groups of functions that work on a particular kind of data—implic
                                            me
                  m et h o d




     Object-oriented programming makes these function groups expl
                 data
                                              thod

     group, rather than its components.If you’ve ever tackled any kind
                                           The only way to an object’s dat
                               m et h o d groups of functions that work o
                                          Object-oriented programming
     By combining both state and behavior in a single unit, an object b
     really is greater than the sum of itsgroup, rather thanis a componen
                                           parts. An object its kind of se
     over a specific functional area. It can play a full-fledged modular
         If you’ve ever tackled any kind By difficult programmingand be
                                          of combining both state prob
                                          really is greater than the sum o
         groups of functions that work on a particular kind of data—im
27   Terminology: Object-oriented terminology varies from language
and a data structure that serves
     Figure 3-1          An object          fields of its data structure are it
                                            hide them from the rest of the
        The insight of object-oriented programming is to combine st
           m et h o da high-level unit, an object, and to give it language su
        data—in                             Figure 3-1        An object
                                                                                 ma ly
                                                             no

                                      me
        and a data structure that serves those functions. The function

     m et h o d
            data
                                                           A

                                       thod
        fields of its data structure are its instanceovariables. The met
        hide them from the rest of the program,   m et has Figure 3-1 illustrat
                                                          d




                                                                                     me
                                                           m et h o d
                     m et h o d
                                                                          data




                                                                                     thod
             Figure 3-1                        An object
                                                                        m et h o d
                m et h o d
     If you’ve ever tackled any kind of difficult programming problem
     groups of functions that work on a particular kind of data—implic
                                            me
                  m et h o d




     Object-oriented programming makes these function groups expl
                 data
                                              thod

     group, rather than its components.If you’ve ever tackled any kind
                                           The only way to an object’s dat
                               m et h o d groups of functions that work o
                                          Object-oriented programming
     By combining both state and behavior in a single unit, an object b
     really is greater than the sum of itsgroup, rather thanis a componen
                                           parts. An object its kind of se
     over a specific functional area. It can play a full-fledged modular
         If you’ve ever tackled any kind By difficult programmingand be
                                          of combining both state prob
                                          really is greater than the sum o
         groups of functions that work on a particular kind of data—im
27   Terminology: Object-oriented terminology varies from language
and a data structure that serves those functions. The functions are known as the object’s methods, a
                                                  fields of its data structure are its instance variables. The methods wrap around the instance variable
                                                  hide them from the rest of the program, as Figure 3-1 illustrates.

     The insight of object-oriented programming is to 3-1
                                                   Figure combineAn object behavior—data The insight of object-oriented programming is to combine
                                                                    state and                  and operations on
     CHAPTER a high-level unit, an object, and to give it language support. An object is a group of related functions
     data—in 3                                                                                data—in a high-level unit, an object, and to give it languag
                                                           et h o d
     and a data structure that serves those functions.m functions are known as the object’s methods, and the serves those functions. The funct
                                                          The                                 and a data structure that
     fields of its data structure are its instance variables. The methods wrap around the instance variables and
                                                                                              fields of its data structure are its instance variables. The m




                                                                            me
                                                  m et h o d
     hide them from the rest of the program, as Figuredata illustrates.
                                                           3-1                                hide them from the rest of the program, as Figure 3-1 illus




                                                                            thod
     Figure 3-1                 An object                      m et h o d                      Figure 3-1                 An object

     The Object Model
                  m et h o d                      CHAPTER 3                                                 m et h o d




                               me




                                                                                                                         me
                                                  If you’ve ever tackled any kind of difficult programming problem, it’s likely that your design has inclu
     m et h o d




                                                                                               m et h o d
                    data                          groups of functions that work on a particular kind data

                               thod




                                                                                                                         thod
                                                                                                      of data—implicit “objects” without the language su
                                                  Object-oriented programming makes these function groups explicit and permits you to think in terms
                  m et h o d                                                                                m et h o d
                                                  group, rather than its components. The only way to an object’s data, the only interface, is through its me
     The insight of object-oriented programming is to combine state and behavior—data single unit, an object becomes more than either alone; the
                                                    By combining both state and behavior in a and operations on
                                                  The Object Model
     data—in a high-level unit, an object, and toreallyit language support.sumobjectparts. An object is a kind of self-sufficient “subprogram” with juris
                                                     give is greater than the An of its is a group of related functions
     If you’ve ever tackled any kind of difficult programming problem, known that your design has included
     and a data structure that serves those functions. The functions areit’s likelyas the object’s methods,tackled any kind of difficult programming pr
                                                                                                  If you’ve ever and the
                                                    over a specific functional area. It can play a full-fledged modular role within a larger program design
     groups its data structure are on a particular kind of The methods “objects” without groups variables and
     fields ofof functions that work its instance variables. data—implicitwrap around the instanceof functions that work on a particular kind of data—
                                                                                                   the language support.
     Object-oriented programming program, as function groups explicit and permits you to think in terms programming makes these function group
     hide them from the rest of the makes these Figure 3-1 illustrates.                           Object-oriented of the
                                                    Terminology: Object-oriented terminology variesratherlanguage to language.The only way to an objec
                                                                                                  group, from than its components. For example, in C++, m
     group, rather than its components. The only way to an object’s data, the only interface, is through its methods.
                                                    are called member functions and instance variables are known as data members. This document uses
     Figure 3-1        An object
     By combining both state and behavior in a terminology ofobject becomes more than basis in Smalltalk. state and behavior in a single unit, an o
                                                    single unit, an Objective-C, which has its either alone; the whole
                                                                                                  By combining both
                                                    The insighta kind of self-sufficient “subprogram” iscombinethan the sum of its parts. An object is a kin
     really is greater than the sum of its parts. An object is    of object-oriented programming is to greater state and behavior—data and operations
                                                                                                  really with jurisdiction
           m et h o d functional area. It can play a full-fledged modular rolean object, and toover a specific functional area. It can play a full-fledged fun
     over a specific                                data—in a high-level unit, within a larger program design. support. An object is a group of related mo
                                                                                                    give it language
                                                    For example, if you were to write a program that The functions are known as the object’s methods, a
                                                    and a data structure that serves those functions. modeled home water usage, you might invent obje
                               me
     m et h o d




              data                                  fields of its data structure are its instance variables. The methods wrap around Faucet object that
                                                    represent the various components of the water-delivery system. One might be a the instance variable
                               thod




     Terminology: Object-oriented terminology varies from language and stopprogram, ofTerminology:methods
                                                    hide methods to start to language. flow as water, set the rate of
                                                    have them from the rest of the the For example, in3-1 illustrates.flow, return the amount of water con
                                                                                                    Figure C++, Object-oriented terminology varies from lan
     are called member functions and instance variables are known as so on. To do this work, acalled member functions and instance variables to keep
                  m et h o d                        in a given period, and data members. This document uses the would need instance variables are kno
                                                                                                  are Faucet object
     terminology of Objective-C, which has its basis in Smalltalk. is open or shut, how much water is being used, andwhich has its basis in Smalltal
                                                    of whether the tap object                     terminology of Objective-C, where the water is coming fr
                                                    Figure 3-1        An
                                                   Clearly, a programmatic Faucet object can be smarter than a real one (it’s analogous to a mechanical
     For example, if you were to write a program thatm et h o d problem,water usage, you mightexample, if you to
     If you’ve ever tackled any kind of difficult programming home it’s likely that attached). invent includedwere to like anyprogramcomponent, ex
                                                           modeled                               For        objects           write a        that modeled
                                                   with lots of gauges and instruments your design hasBut even a real faucet,         system
     represent functions that work on a particular kind of data—implicit “objects”be a Faucet language support.
     groups of the various components of the water-delivery system. One might without represent theyou need programming the water-delivery th
                                                                                                 the object that wouldcomponents of units, like objects, sy
                                                                                                               various
                                                                            me
                                                  m et h o d




                                                   both state and behavior. To effectively model a system,
     have methods toprogramming makes thesewater, data rate of flow, return the amountthink in terms of theand stop the flow of water, set the ra
     Object-oriented start and stop the flow ofcombine state and behavior. permits you to of methods to start
                                                           set the                               have water consumed
                                                                            thod




                                                     function groups explicit and
     in a given period, and so on. To doThe only wayFaucet object would need instance variables toperiod, and so on. To do this work, a Faucet ob
     group, rather than its components. this work, a to an object’s data, the only interface, is through its methods.
                                                                                                 in a given keep track
     of whether the tap is open or shut, how much water is being used,network of interconnected objects that open or shut, how much water part o
                                                   A program consists of a and where the water is coming from.is call upon each other to solve a is bei
                                                               m et h o d                        of whether the tap
     By combining both state and behavior in a puzzle unit, an objectin Figure 3-2 (page 16)). Each object has a specific role to play in the overall des
                                                   single (as illustrated becomes more than either alone; the whole
     Clearly, a programmatic Faucet its parts. An object is athan a real one (it’s analogous Clearly, a programmatic Faucet object can be smarter tha
     really is greater than the sum of  object can be smarter kind of self-sufficient “subprogram” with jurisdiction
                                                                                                 to a mechanical faucet
                                                   the program and is able to communicate with other objects. Objects communicate through messages
     with a specific functional area. It can attached). But evenmodular role within a larger program design.
     over lots of gauges and instruments play a full-fledged to perform methods. systemwith lots of gauges and instruments attached). But even a
                                                                   a real faucet, like any        component, exhibits
                                                   are requests
     both state and behavior. To effectively model a system, you need programming units, like objects, that also it’s likely that your design has inclu
                                                   If you’ve ever tackled any kind of difficult programming problem, To effectively model a system, yo
                                                                                                 both state and behavior.
     combine state and behavior.                   groups of functions that work on a particular kind ofstate and behavior.
                                                                                                 combine data—implicit “objects” without the language su
     Terminology: Object-oriented terminology varies from language to language. For example, in C++, methods and permits you to think in terms
                                                   Object-oriented programming makes these function groups explicit
28   are called member functions and instance variables are known ascall upon each otherdocument part of the a network interface, is through its me
                                                   group, rather than its data members. This A solvean object’s of
     A program consists of a network of interconnected objects thatcomponents. The onlytoprogramuses thedata, the only of interconnected object
                                                                                                  way to a consists
and a data structure that serves those functions. The functions are known as the object’s methods, a
                                                  fields of its data structure are its instance variables. The methods wrap around the instance variable
                                                  hide them from the rest of the program, as Figure 3-1 illustrates.

     The insight of object-oriented programming is to 3-1
                                                   Figure combineAn object behavior—data The insight of object-oriented programming is to combine
                                                                    state and                  and operations on
     CHAPTER a high-level unit, an object, and to give it language support. An object is a group of related functions
     data—in 3                                                                                data—in a high-level unit, an object, and to give it languag
                                                           et h o d
     and a data structure that serves those functions.m functions are known as the object’s methods, and the serves those functions. The funct
                                                          The                                 and a data structure that
     fields of its data structure are its instance variables. The methods wrap around the instance variables and
                                                                                              fields of its data structure are its instance variables. The m




                                                                            me
                                                  m et h o d
     hide them from the rest of the program, as Figuredata illustrates.
                                                           3-1                                hide them from the rest of the program, as Figure 3-1 illus




                                                                            thod
     Figure 3-1                 An object                      m et h o d                      Figure 3-1                 An object

     The Object Model
                  m et h o d                      CHAPTER 3                                                 m et h o d




                               me




                                                                                                                         me
                                                  If you’ve ever tackled any kind of difficult programming problem, it’s likely that your design has inclu
     m et h o d




                                                                                               m et h o d
                    data                          groups of functions that work on a particular kind data

                               thod




                                                                                                                         thod
                                                                                                      of data—implicit “objects” without the language su
                                                  Object-oriented programming makes these function groups explicit and permits you to think in terms
                  m et h o d                                                                                m et h o d
                                                  group, rather than its components. The only way to an object’s data, the only interface, is through its me
     The insight of object-oriented programming is to combine state and behavior—data single unit, an object becomes more than either alone; the
                                                    By combining both state and behavior in a and operations on
                                                  The Object Model
     data—in a high-level unit, an object, and toreallyit language support.sumobjectparts. An object is a kind of self-sufficient “subprogram” with juris
                                                     give is greater than the An of its is a group of related functions
     If you’ve ever tackled any kind of difficult programming problem, known that your design has included
     and a data structure that serves those functions. The functions areit’s likelyas the object’s methods,tackled any kind of difficult programming pr
                                                                                                  If you’ve ever and the
                                                    over a specific functional area. It can play a full-fledged modular role within a larger program design
     groups its data structure are on a particular kind of The methods “objects” without groups variables and
     fields ofof functions that work its instance variables. data—implicitwrap around the instanceof functions that work on a particular kind of data—
                                                                                                   the language support.
     Object-oriented programming program, as function groups explicit and permits you to think in terms programming makes these function group
     hide them from the rest of the makes these Figure 3-1 illustrates.                           Object-oriented of the
                                                    Terminology: Object-oriented terminology variesratherlanguage to language.The only way to an objec
                                                                                                  group, from than its components. For example, in C++, m
     group, rather than its components. The only way to an object’s data, the only interface, is through its methods.
                                                    are called member functions and instance variables are known as data members. This document uses
     Figure 3-1        An object
     By combining both state and behavior in a terminology ofobject becomes more than basis in Smalltalk. state and behavior in a single unit, an o
                                                    single unit, an Objective-C, which has its either alone; the whole
                                                                                                  By combining both
                                                    The insighta kind of self-sufficient “subprogram” iscombinethan the sum of its parts. An object is a kin
     really is greater than the sum of its parts. An object is    of object-oriented programming is to greater state and behavior—data and operations
                                                                                                  really with jurisdiction
           m et h o d functional area. It can play a full-fledged modular rolean object, and toover a specific functional area. It can play a full-fledged fun
     over a specific                                data—in a high-level unit, within a larger program design. support. An object is a group of related mo
                                                                                                    give it language
                                                    For example, if you were to write a program that The functions are known as the object’s methods, a
                                                    and a data structure that serves those functions. modeled home water usage, you might invent obje
                               me
     m et h o d




              data                                  fields of its data structure are its instance variables. The methods wrap around Faucet object that
                                                    represent the various components of the water-delivery system. One might be a the instance variable
                               thod




     Terminology: Object-oriented terminology varies from language and stopprogram, ofTerminology:methods
                                                    hide methods to start to language. flow as water, set the rate of
                                                    have them from the rest of the the For example, in3-1 illustrates.flow, return the amount of water con
                                                                                                    Figure C++, Object-oriented terminology varies from lan
     are called member functions and instance variables are known as so on. To do this work, acalled member functions and instance variables to keep
                  m et h o d                        in a given period, and data members. This document uses the would need instance variables are kno
                                                                                                  are Faucet object
     terminology of Objective-C, which has its basis in Smalltalk. is open or shut, how much water is being used, andwhich has its basis in Smalltal
                                                    of whether the tap object                     terminology of Objective-C, where the water is coming fr
                                                    Figure 3-1        An
                                                   Clearly, a programmatic Faucet object can be smarter than a real one (it’s analogous to a mechanical
     For example, if you were to write a program thatm et h o d problem,water usage, you mightexample, if you to
     If you’ve ever tackled any kind of difficult programming home it’s likely that attached). invent includedwere to like anyprogramcomponent, ex
                                                           modeled                               For        objects           write a        that modeled
                                                   with lots of gauges and instruments your design hasBut even a real faucet,         system
     represent functions that work on a particular kind of data—implicit “objects”be a Faucet language support.
     groups of the various components of the water-delivery system. One might without represent theyou need programming the water-delivery th
                                                                                                 the object that wouldcomponents of units, like objects, sy
                                                                                                               various
                                                                            me
                                                  m et h o d




                                                   both state and behavior. To effectively model a system,
     have methods toprogramming makes thesewater, data rate of flow, return the amountthink in terms of theand stop the flow of water, set the ra
     Object-oriented start and stop the flow ofcombine state and behavior. permits you to of methods to start
                                                           set the                               have water consumed
                                                                            thod




                                                     function groups explicit and
     in a given period, and so on. To doThe only wayFaucet object would need instance variables toperiod, and so on. To do this work, a Faucet ob
     group, rather than its components. this work, a to an object’s data, the only interface, is through its methods.
                                                                                                 in a given keep track
     of whether the tap is open or shut, how much water is being used,network of interconnected objects that open or shut, how much water part o
                                                   A program consists of a and where the water is coming from.is call upon each other to solve a is bei
                                                               m et h o d                        of whether the tap
     By combining both state and behavior in a puzzle unit, an objectin Figure 3-2 (page 16)). Each object has a specific role to play in the overall des
                                                   single (as illustrated becomes more than either alone; the whole
     Clearly, a programmatic Faucet its parts. An object is athan a real one (it’s analogous Clearly, a programmatic Faucet object can be smarter tha
     really is greater than the sum of  object can be smarter kind of self-sufficient “subprogram” with jurisdiction
                                                                                                 to a mechanical faucet
                                                   the program and is able to communicate with other objects. Objects communicate through messages
     with a specific functional area. It can attached). But evenmodular role within a larger program design.
     over lots of gauges and instruments play a full-fledged to perform methods. systemwith lots of gauges and instruments attached). But even a
                                                                   a real faucet, like any        component, exhibits
                                                   are requests
     both state and behavior. To effectively model a system, you need programming units, like objects, that also it’s likely that your design has inclu
                                                   If you’ve ever tackled any kind of difficult programming problem, To effectively model a system, yo
                                                                                                 both state and behavior.
     combine state and behavior.                   groups of functions that work on a particular kind ofstate and behavior.
                                                                                                 combine data—implicit “objects” without the language su
     Terminology: Object-oriented terminology varies from language to language. For example, in C++, methods and permits you to think in terms
                                                   Object-oriented programming makes these function groups explicit
28   are called member functions and instance variables are known ascall upon each otherdocument part of the a network interface, is through its me
                                                   group, rather than its data members. This A solvean object’s of
     A program consists of a network of interconnected objects thatcomponents. The onlytoprogramuses thedata, the only of interconnected object
                                                                                                  way to a consists
and a data structure that serves those functions. The functions are known as the object’s methods, a
                                                  fields of its data structure are its instance variables. The methods wrap around the instance variable
                                                  hide them from the rest of the program, as Figure 3-1 illustrates.

     The insight of object-oriented programming is to 3-1
                                                   Figure combineAn object behavior—data The insight of object-oriented programming is to combine
                                                                    state and                  and operations on
                                                                                              CHAPTER 3
     CHAPTER a high-level unit, an object, and to give it language support. An object is a group of related functions
     data—in 3                                                                                data—in a high-level unit, an object, and to give it languag
                                                           et h o d
     and a data structure that serves those functions.m functions are known as the object’s methods, and the serves those functions. The funct
                                                          The                                 and a data structure that
     fields of its data structure are its instance variables. The methods wrap around the instance variables and
                                                                                              fields of its data structure are its instance variables. The m




                                                                             me
                                                   m et h o d
     hide them from the rest of the program, as Figuredata illustrates.
                                                           3-1                                hide them from the rest of the program, as Figure 3-1 illus




                                                                             thod
     Figure 3-1                 An object                                                       Figure 3-1                 An object
                                                                                                The Object Model
                                                                m et h o d


     The Object Model
                  m et h o d                      CHAPTER 3                                                  m et h o d




                               me




                                                                                                                          me
                                                   If you’ve ever tackled any kind of difficult programming problem, it’s likely that your design has inclu
     m et h o d




                                                                                                m et h o d
                    data                           groups of functions that work on a particular kind data

                               thod




                                                                                                                          thod
                                                                                                            of data—implicit “objects” without the language su
                                                   Object-oriented programming makes these function groups explicit and permits you to think in terms
                  m et h o d                                                                                 m et h o d
                                                   group, rather than its components. The only way to an object’s data, the only interface, is through its me
                                                                                                 The insight of object-oriented programming is to combine
     The insight of object-oriented programming is to combine state and behavior—data data—in a high-level unit, an object, and to give it languag
                                                                                                  and operations on
                                                  The Object Model
                                                   By combining both state and behavior in a single unit, an object becomes more than either alone; the
     data—in a high-level unit, an object, and toreallyit language support.sumobjectparts. An object is a kind of self-sufficient “subprogram” withfunct
                                                    give is greater than the An of its is a group of related functions serves those functions. The juris
                                                                                                 and a data structure that
     If you’ve ever tackled any kind of difficult programming problem, known that your design has included
     and a data structure that serves those functions. The functions areit’s likelyas the object’s methods,tackled any kind ofinstance programming pr
                                                                                                 If you’ve its data structure
                                                                                                 fields of ever and the               difficult variables. The
                                                   over a specific functional area. It can play a full-fledged modular roleare its a larger program designm
                                                                                                                               within
     groups its data structure are on a particular kind of The methods “objects” without groups variables and work program, as Figure 3-1 illus
     fields ofof functions that work its instance variables. data—implicitwrap around the instanceof functions that of theon a particular kind of data—
                                                                                                 hidelanguage support.
                                                                                                  the them from the rest
     Object-oriented programming program, as function groups explicit and permits you to think in terms programming makes these function group
     hide them from the rest of the makes these Figure 3-1 illustrates.                          Object-oriented of the
                                                   Terminology: Object-oriented terminology variesratherlanguage to language.The only way to an objec
                                                                                                 group, from than its components. For example, in C++, m
     group, rather than its components. The only way to an object’s data, the only interface, is through its methods.
                                                                                                 Figure 3-1
                                                   are called member functions and instance variables are knownobject members. This document uses
                                                                                                                    An as data
     Figure 3-1        An object
     By combining both state and behavior in a terminology ofobject becomes more than basis in Smalltalk. state and behavior in a single unit, an o
                                                   single unit, an Objective-C, which has its either alone; the whole
                                                                                                 By combining both
                                                   The insighta kind of self-sufficient “subprogram”m combinethan the sum of its parts. An object is a kin
     really is greater than the sum of its parts. An object is   of object-oriented programming is to et h ojurisdictionand behavior—data and operations
                                                                                                 really is greater state
                                                                                                         with d
              et h o d
     over a specific functional area. It can play a full-fledged modular rolean object, and toover a specific functional area. It can play a full-fledged fun
           m                                       data—in a high-level unit, within a larger program design. support. An object is a group of related mo
                                                                                                   give it language




                                                                                                                          me
                                                                                                m et h o d
                                                   For example, if you were to write a program that The functions are known as the object’s methods, a
                                                   and a data structure that serves those functions. modeled home water usage, you might invent obje
                               me
     m et h o d




                                                                                                           data




                                                                                                                          thod
              data                                 fields of its data structure are its instance variables. The methods wrap around Faucet object that
                                                   represent the various components of the water-delivery system. One might be a the instance variable
                               thod




     Terminology: Object-oriented terminology varies from language and stopprogram, ofTerminology:methods
                                                   hide methods to start to language. flow as water, set the rate of
                                                   have them from the rest of the the For example, in3-1 illustrates.flow, return the amount of water con
                                                                                                   Figure C++, Object-oriented terminology varies from lan
                                                                                                             m et h o d
     are called member functions and instance variables are known as so on. To do this work, acalled member functions and instance variables to keep
                  m et h o d                       in a given period, and data members. This document uses the would need instance variables are kno
                                                                                                 are Faucet object
     terminology of Objective-C, which has its basis in Smalltalk. is open or shut, how much water is being used, andwhich has its basis in Smalltal
                                                   of whether the tap object                     terminology of Objective-C, where the water is coming fr
                                                   Figure 3-1        An
                                                   Clearly, a programmatic Faucet object can be smarter than a real one (it’sof difficult programming pr
                                                                                                                                   analogous to a mechanical
     For example, if you were to write a program thatm et h o d problem,water usage, you mightexample, if you to anyto write a program that modeled
                                                           modeled home it’s likely that your design has includedwere kind
     If you’ve ever tackled any kind of difficult programming
                                                                                                 If you’ve ever tackled
                                                                                                 For invent objects
                                                   with lots of gauges and instruments attached). But even a real faucet, like any system component, ex
     represent functions that work on a particular kind of data—implicit “objects”be a Faucet language support. work on a particular kind of data—
     groups of   the various components of the water-delivery system. One might without groups of functions that
                                                                                                 represent the various components of the water-delivery sy
                                                                                                 the object that would
                                                                             me
                                                   m et h o d




                                                   both state and behavior. To effectively model a system, you need programming units, like objects, th
     have methods toprogramming makes thesewater, data rate of flow, return the amountthink in terms of theand stop the flow of function the ra
                                                                                                 Object-oriented programming makes thesewater, set group
     Object-oriented start and stop the flow ofcombine state and behavior. permits you to of methods to start
                                                           set the                               have water consumed
                                                                             thod




                                                     function groups explicit and
     in a given period, and so on. To doThe only wayFaucet object would need instance variables toperiod, and so on. To doThe only wayFaucet ob
                                                                                                 group, rather than its components. this work, a to an objec
     group, rather than its components. this work, a to an object’s data, the only interface, is through its methods.
                                                                                                 in a given keep track
     of whether the tap is open or shut, how much water is being used,network of interconnected objects that open or shut, how much water part o
                                                   A program consists of a and where the watercombining from.is calland behavior in a single unit, an o
                                                                                                 of whether the tap
                                                                                                      is coming                                           is bei
                                                                                                                 both state upon each other to solve a
                                                                m et h o d
                                                                                                 By
     By combining both state and behavior in a puzzle unit, an objectin Figure 3-2 (page 16)). Each greater has a the sumrole to play in the overall des
                                                   single (as illustrated becomes more than either alone; thethan specific of
                                                                                                           object whole
     Clearly, a programmatic Faucet its parts. An object is athan a real one (it’s analogous really is a programmatic Faucet its parts. An object is atha
     really is greater than the sum of  object can be smarter kind of self-sufficient “subprogram” with jurisdiction
                                                                                                 Clearly,
                                                                                                 to a mechanical faucet             object can be smarter kin
                                                   the program and is able to communicate with other objects. Objects communicate through messages
                                                                                                 over a specific functional area. It can play a full-fledged mo
     with a specific functional area. It can attached). But evenmodular role within a larger program design.
     over lots of gauges and instruments play a full-fledged to perform methods. systemwith lots of gauges and instruments attached). But even a
                                                                   a real faucet, like any         component, exhibits
                                                   are requests
     both state and behavior. To effectively model a system, you need programming units, like objects, that also it’s likely that your design has inclu
                                                   If you’ve ever tackled any kind of difficult programming problem, To effectively model a system, yo
                                                                                                 both state and behavior.
     combine state and behavior.                   groups of functions that work on a particular kind ofstate Object-oriented terminology varies from lan
                                                                                                 combine data—implicit “objects” without the language su
                                                                                                 Terminology: and behavior.
     Terminology: Object-oriented terminology varies from language to language. For example, in C++, methods and permits youvariablesin terms
                                                   Object-oriented programming makes these function memberexplicit and instance to think are kno
                                                                                                 are called groups functions
28   are called member functions and instance variables are known ascall upon each otherdocument part of the a network interface,basis in Smalltal
                                                                            data members. This A programuses Objective-C, only ofhas its is through its me
                                                   group, rather than its                        terminology of the of
     A program consists of a network of interconnected objects thatcomponents. The onlyto solvean object’s data, the which interconnected object
                                                                                                  way to a consists
Active Object +
     State Machine Figure 3-1                  An object

          mailbox
                                 m et h o d




                                              me
                      et h o d
                                   data




                                              thod
                    m
                                 m et h o d



29
Active Object +
     State Machine Figure 3-1                  An object

          mailbox
                                 m et h o d




                                              me
                      et h o d
                                   data




                                              thod
                    m
                                 m et h o d



29
Active Object +
     State Machine Figure 3-1                    An object

            mailbox
                                   m et h o d




                                                me
                        et h o d
                                     data




                                                thod
                      m
                                   m et h o d



30
Active Object +
     State Machine Figure 3-1                    An object

            mailbox
                                   m et h o d




                                                me
                        et h o d
                                     data




                                                thod
                      m
                                   m et h o d



30
box




      empty




      full(X)




31
box




                  empty

     {‘put’,X}


                  full(X)




31
box




                  empty

     {‘put’,X}              {‘take’,From} /
                            send(From, X)

                  full(X)




31
box() ➞ empty().

     empty() ➞                        box
      receive
       {‘put’, X} ➞
          full(X)
      end.                             empty

     full(X) ➞            {‘put’,X}              {‘take’,From} /
                                                 send(From, X)
      receive
       {‘take’, From} ➞                full(X)
           From ! X,
           empty()
      end.




32
box() ➞ empty().

     empty() ➞                        box
      receive
       {‘put’, X} ➞
          full(X)
      end.                             empty

     full(X) ➞            {‘put’,X}              {‘take’,From} /
                                                 send(From, X)
      receive
       {‘take’, From} ➞                full(X)
           From ! X,
           empty()
      end.                                     {‘peek’,From} /
                                             send(From,{‘ok’, X})




33
box() ➞ empty().

     empty() ➞                             box
      receive
       {‘put’, X} ➞
          full(X)
      end.                                  empty

     full(X) ➞                 {‘put’,X}              {‘take’,From} /
                                                      send(From, X)
      receive
       {‘take’, From} ➞                     full(X)
           From ! X,
           empty();
       {‘peek’, From} ➞                             {‘peek’,From} /
                                                  send(From,{‘ok’, X})
           From ! {‘ok’, X},
           full(X)
      end.

34
box() ➞ empty().

     empty() ➞                             box
      receive
       {‘put’, X} ➞
          full(X)
      end.                                  empty

     full(X) ➞                 {‘put’,X}              {‘take’,From} /
                                                      send(From, X)
      receive
       {‘take’, From} ➞                     full(X)
           From ! X,
           empty();
       {‘peek’, From} ➞                             {‘peek’,From} /
                                                  send(From,{‘ok’, X})
           From ! {‘ok’, X},
           full(X)
      end.

34
box() ➞ empty().

     empty() ➞
      receive
       {‘put’, X} ➞
           full(X)
      end.

     full(X) ➞
      receive
       {‘take’, From} ➞
           From ! X,
           empty();
       {‘peek’, From} ➞
           From ! {‘ok’, X},
           full(X)
      end.

35
box() ➞ empty().          Box = spawn(fun box/0),

     empty() ➞
      receive
       {‘put’, X} ➞
           full(X)
      end.

     full(X) ➞
      receive
       {‘take’, From} ➞
           From ! X,
           empty();
       {‘peek’, From} ➞
           From ! {‘ok’, X},
           full(X)
      end.

35
box() ➞ empty().          Box = spawn(fun box/0),

     empty() ➞                 Box ! {‘put’, 27},
      receive
       {‘put’, X} ➞
           full(X)
      end.

     full(X) ➞
      receive
       {‘take’, From} ➞
           From ! X,
           empty();
       {‘peek’, From} ➞
           From ! {‘ok’, X},
           full(X)
      end.

35
box() ➞ empty().          Box = spawn(fun box/0),

     empty() ➞                 Box ! {‘put’, 27},
      receive
       {‘put’, X} ➞            Box ! {‘take’, self()},
           full(X)             receive
      end.                      Value ➞ print(Value)
                               end
     full(X) ➞
      receive
       {‘take’, From} ➞
           From ! X,
           empty();
       {‘peek’, From} ➞
           From ! {‘ok’, X},
           full(X)
      end.

35
Interface
     Objects
                   Fixed API


                   Protocol
     Actors      API changes
               with internal state




36
ma ly
               A no   Interface
     Objects
                      Fixed API


                      Protocol
     Actors         API changes
                  with internal state




36
Pull vs. Push




37
Pull vs. Push




37
Pull vs. Push




37
Pull vs. Push




37
Pull vs. Push




37
Pull vs. Push




37
But isn’t this expensive?




38
But isn’t this expensive?
      ... heard in the ‘90s

       Use Objects!




38
But isn’t this expensive?
      ... heard in the ‘90s

                        100.000’s of objects,
       Use Objects!        are you crazy?




38
But isn’t this expensive?
      ... heard yesterday


      Use Actors!




38
But isn’t this expensive?
      ... heard yesterday

                       100.000’s of processes,
      Use Actors!
                              silly you!




38
fields of its data structu
                               hide them from the rest

     Effect Containment 3-1
                     Figure                               An obje

                                            m et h o d
     ■ Functional languages




                                                         me
                                 et h o d
       disallow effects                       data




                                                         thod
     ■ Many object-oriented




                               m
                                            m et h o d
       styles encourage side
       effects.
     ■ Actors confine effects   If you’ve ever tackled an
                               groups of functions tha
                               Object-oriented program
39                             group, rather than its co
From C++ to Java      Garbage Collection




     From Java to Erlang   State Containment




40
Activity Composition
          The Object Model                                                     The Object Model


          The insight of object-oriented programming is to combine state and behavior—data and operations on
                                                                             The insight of object-oriented programming is to combine state and
          data—in a high-level unit, an object, and to give it language support. An object is a group of related functions give it language support.
                                                                             data—in a high-level unit, an object, and to
                                                                             and a data the object’s methods, and the
          and a data structure that serves those functions. The functions are known asstructure that serves those functions. The functions are k
          fields of its data structure are its instance variables. The methods wrap around the instance variables and variables. The methods w
                                                                             fields of its data structure are its instance
          hide them from the rest of the program, as Figure 3-1 illustrates. hide them from the rest of the program, as Figure 3-1 illustrates.

          Figure 3-1                 An object                                 Figure 3-1                  An object

                       m et h o d   me
                                                 spawn                                       m et h o d




                                                                                                          me
          m et h o d




                                                                                m et h o d
                         data                                                                  data
                                    thod




                                                                                                          thod
                       m et h o d                                                            m et h o d




          If you’ve ever tackled any kind of difficult programming problem,If you’ve ever tackled any kind included programming problem, it’
                                                                             it’s likely that your design has of difficult
          groups of functions that work on a particular kind of data—implicit “objects” without the language a particular kind of data—implicit “
                                                                             groups of functions that work on support.
          Object-oriented programming makes these function groups explicit and permits you to think in terms ofthese function groups explicit
                                                                             Object-oriented programming makes the
          group, rather than its components. The only way to an object’s data, the only interface, iscomponents. The only way to an object’s data, th
                                                                             group, rather than its through its methods.

          By combining both state and behavior in a single unit, an object becomes more than eitherand behavior in a single unit, an object bec
                                                                                 By combining both state alone; the whole
          really is greater than the sum of its parts. An object is a kind of self-sufficient “subprogram”sum of its parts. An object is a kind of self-s
                                                                                 really is greater than the with jurisdiction
          over a specific functional area. It can play a full-fledged modular role within a larger program design. play a full-fledged modular role
                                                                                 over a specific functional area. It can

          Terminology: Object-oriented terminology varies from language to language. For example, in C++, methods varies from language to
                                                                          Terminology: Object-oriented terminology
          are called member functions and instance variables are known as data members. Thisfunctions and instance variables are known as da
                                                                          are called member document uses the
          terminology of Objective-C, which has its basis in Smalltalk.   terminology of Objective-C, which has its basis in Smalltalk.


          For example, if you were to write a program that modeled home water usage, you might invent objects to that modeled home wa
                                                                              For example, if you were to write a program
          represent the various components of the water-delivery system. One mightthe a Faucet object thatof the water-delivery system. On
                                                                              represent be various components would
          have methods to start and stop the flow of water, set the rate of flow, return the amount and stop consumed water, set the rate of flow
                                                                              have methods to start of water the flow of
41        in a given period, and so on. To do this work, a Faucet object would need instanceand so on.to keep track
                                                                              in a given period, variables To do this work, a Faucet object woul
Activity Composition
          The Object Model                                                     The Object Model


          The insight of object-oriented programming is to combine state and behavior—data and operations on
                                                                             The insight of object-oriented programming is to combine state and
          data—in a high-level unit, an object, and to give it language support. An object is a group of related functions give it language support.
                                                                             data—in a high-level unit, an object, and to
                                                                             and a data the object’s methods, and the
          and a data structure that serves those functions. The functions are known asstructure that serves those functions. The functions are k
          fields of its data structure are its instance variables. The methods wrap around the instance variables and variables. The methods w
                                                                             fields of its data structure are its instance
          hide them from the rest of the program, as Figure 3-1 illustrates. hide them from the rest of the program, as Figure 3-1 illustrates.

          Figure 3-1                 An object                                 Figure 3-1                  An object

                       m et h o d   me
                                                 link                                        m et h o d




                                                                                                          me
          m et h o d




                                                                                m et h o d
                         data                                                                  data
                                    thod




                                                                                                          thod
                       m et h o d                                                            m et h o d




          If you’ve ever tackled any kind of difficult programming problem,If you’ve ever tackled any kind included programming problem, it’
                                                                             it’s likely that your design has of difficult
          groups of functions that work on a particular kind of data—implicit “objects” without the language a particular kind of data—implicit “
                                                                             groups of functions that work on support.
          Object-oriented programming makes these function groups explicit and permits you to think in terms ofthese function groups explicit
                                                                             Object-oriented programming makes the
          group, rather than its components. The only way to an object’s data, the only interface, iscomponents. The only way to an object’s data, th
                                                                             group, rather than its through its methods.

          By combining both state and behavior in a single unit, an object becomes more than eitherand behavior in a single unit, an object bec
                                                                                 By combining both state alone; the whole
          really is greater than the sum of its parts. An object is a kind of self-sufficient “subprogram”sum of its parts. An object is a kind of self-s
                                                                                 really is greater than the with jurisdiction
          over a specific functional area. It can play a full-fledged modular role within a larger program design. play a full-fledged modular role
                                                                                 over a specific functional area. It can

          Terminology: Object-oriented terminology varies from language to language. For example, in C++, methods varies from language to
                                                                          Terminology: Object-oriented terminology
          are called member functions and instance variables are known as data members. Thisfunctions and instance variables are known as da
                                                                          are called member document uses the
          terminology of Objective-C, which has its basis in Smalltalk.   terminology of Objective-C, which has its basis in Smalltalk.


          For example, if you were to write a program that modeled home water usage, you might invent objects to that modeled home wa
                                                                              For example, if you were to write a program
          represent the various components of the water-delivery system. One mightthe a Faucet object thatof the water-delivery system. On
                                                                              represent be various components would
          have methods to start and stop the flow of water, set the rate of flow, return the amount and stop consumed water, set the rate of flow
                                                                              have methods to start of water the flow of
42        in a given period, and so on. To do this work, a Faucet object would need instanceand so on.to keep track
                                                                              in a given period, variables To do this work, a Faucet object woul
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]
Erlang, The Road Movie [GOTO:CPH 2011 Keynote]

Weitere ähnliche Inhalte

Ähnlich wie Erlang, The Road Movie [GOTO:CPH 2011 Keynote]

Complex Environment Evolution
Complex Environment EvolutionComplex Environment Evolution
Complex Environment EvolutionAndrej Eisfeld
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsTristan Gomez
 
Apcera Case Study: The selection of the Go language
Apcera Case Study: The selection of the Go languageApcera Case Study: The selection of the Go language
Apcera Case Study: The selection of the Go languageDerek Collison
 
Library of Coupled Operators
Library of Coupled OperatorsLibrary of Coupled Operators
Library of Coupled OperatorsSander Vermolen
 
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)Darshan Karandikar
 
The Rise of Dynamic Languages
The Rise of Dynamic LanguagesThe Rise of Dynamic Languages
The Rise of Dynamic Languagesgreenwop
 
Framework Engineering_Final
Framework Engineering_FinalFramework Engineering_Final
Framework Engineering_FinalYoungSu Son
 
Roundup presentation
Roundup presentationRoundup presentation
Roundup presentationmattgrommes
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Javawiradikusuma
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMarakana Inc.
 
Tech Ed09 India Ver M New
Tech Ed09 India Ver M NewTech Ed09 India Ver M New
Tech Ed09 India Ver M Newrsnarayanan
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSkills Matter
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futureTakayuki Muranushi
 
O Reilly Learning Python 3rd Edition
 O Reilly Learning Python 3rd Edition O Reilly Learning Python 3rd Edition
O Reilly Learning Python 3rd Editiongavin shaw
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to ClojureRenzo Borgatti
 

Ähnlich wie Erlang, The Road Movie [GOTO:CPH 2011 Keynote] (20)

Complex Environment Evolution
Complex Environment EvolutionComplex Environment Evolution
Complex Environment Evolution
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby Apps
 
Apcera Case Study: The selection of the Go language
Apcera Case Study: The selection of the Go languageApcera Case Study: The selection of the Go language
Apcera Case Study: The selection of the Go language
 
Library of Coupled Operators
Library of Coupled OperatorsLibrary of Coupled Operators
Library of Coupled Operators
 
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
 
The Rise of Dynamic Languages
The Rise of Dynamic LanguagesThe Rise of Dynamic Languages
The Rise of Dynamic Languages
 
Clojure
ClojureClojure
Clojure
 
Introduction to R for Data Mining
Introduction to R for Data MiningIntroduction to R for Data Mining
Introduction to R for Data Mining
 
WebWorkersCamp 2010
WebWorkersCamp 2010WebWorkersCamp 2010
WebWorkersCamp 2010
 
Framework Engineering_Final
Framework Engineering_FinalFramework Engineering_Final
Framework Engineering_Final
 
Roundup presentation
Roundup presentationRoundup presentation
Roundup presentation
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
 
Foolangjs
FoolangjsFoolangjs
Foolangjs
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for Scala
 
Tech Ed09 India Ver M New
Tech Ed09 India Ver M NewTech Ed09 India Ver M New
Tech Ed09 India Ver M New
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_future
 
O Reilly Learning Python 3rd Edition
 O Reilly Learning Python 3rd Edition O Reilly Learning Python 3rd Edition
O Reilly Learning Python 3rd Edition
 
Ruby Metaprogramming 08
Ruby Metaprogramming 08Ruby Metaprogramming 08
Ruby Metaprogramming 08
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
 

Kürzlich hochgeladen

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
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
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
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
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
 
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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
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
 
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
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

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
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
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
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
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
 
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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
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
 
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
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 

Erlang, The Road Movie [GOTO:CPH 2011 Keynote]

  • 1. Erlang, The Road Movie Lessons learned in Erlang Land @drkrab Kresten Krab Thorup CTO, Trifork 1
  • 2. About Me ■ Language Geek Emacs/TeX Hacker, GCC: Objective C, NeXT, Compiled Java, Ph.D. from Århus [language design] ■ Developer J2EE AppServer, CORBA/RMI, XA-TM, Java Firefighter ■ Trifork CTO Technology Adoption Conference Editor, GOTO/QCon 2
  • 4. ’90s Object Revolution Increased Complexity 4
  • 5. ’90s Object Revolution Increased Complexity Program Structure 4
  • 6. ’90s Object Revolution Increased Complexity Component Reuse Program Structure 4
  • 7. ’90s Object Revolution Increased Complexity Domain Modeling Component Reuse Program Structure 4
  • 8. Languages C# Ruby C++ Smalltalk Java Simula Objective-C 5
  • 9. Thinking Tools Patterns DDD UML OOA&D C# Ruby C++ Smalltalk Java Simula Objective-C 6
  • 10. American Scandinavian School School Increased Complexity Domain Modeling Component Reuse Program Structure 7
  • 11. American Scandinavian School School Increased Conceptual Complexity Modeling Pa rticipatory Design Domain Modeling Component Reuse Program Structure 7
  • 12. American Scandinavian School School Economics Increased Conceptual Reuse Complexity Modeling Engineering Pa rticipatory Design Domain Modeling Component Reuse Program Structure 7
  • 13. American Scandinavian School School Internet Increased Complexity Domain Modeling Component Reuse Program Structure 8
  • 14. Internet Increased Complexity Domain Modeling Component Reuse Program Structure 9
  • 16. More Complexity Infrastructure made of Software 10
  • 17. More Complexity Infrastructure made of Software 11
  • 18. More Complexity Infrastructure made of Software 12
  • 19. More Complexity Infrastructure made of Software Fault Tolerance, Availability, QoS 12
  • 20. More Complexity Infrastructure made of Software Integration, Coordination Fault Tolerance, Availability, QoS 12
  • 21. More Complexity Infrastructure made of Software Cloud, Multi-Core Integration, Coordination Fault Tolerance, Availability, QoS 12
  • 22. More Complexity We ’re struggling to n dle these with an haSoftware Infrastructure made of object mindset! Cloud, Multi-Core Integration, Coordination Fault Tolerance, Availability, QoS 12
  • 23. Time for a new revolution? Cloud, Multi-Core Integration, Coordination Fault Tolerance, Availability, QoS 13
  • 24. What’s a Revolution? Thomas Kuhn The Structure of Scientific Revolutions 14
  • 28. paradigm observe anomalies paradigm normal science 15
  • 29. paradigm observe anomalies paradigm CRISIS normal science 15
  • 30. paradigm observe anomalies paradigm CRISIS normal revolutionary science science 15
  • 31. paradigm observe anomalies normal science paradigm CRISIS normal revolutionary science science 15
  • 32. What is the right paradigm to cope with these? Cloud, Multi-Core Integration, Coordination Fault Tolerance, Availability, QoS 16
  • 33. What is the right paradigm to cope with these? Cloud, Multi-Core Integration, Coordination Fault Tolerance, Availability, QoS Parallel Compilers Erlang, Actor Models Functional, Data-Parallel 16
  • 34. Johnso n’s blog Ralph Next J ava” What is the “Erl ang, the right paradigm to a very with these? g to be cope rlang is goin Its main ... E uage ... imp orta nt lang erfectly e is tha t it is p a Cloud, Multi-Core core, web dvantag for the multi- suite d Integration, Coordinationt, i t is the future . In fac services -QoSd ck soli NLY ma ture, ro Fault Tolerance, Availability, ble for O ge that is suita lang ua Parallel stems able sy Compilers hly scal ing hig Erlang, Actor iModels h nes. writ ore mac run on multic to Functional, Data-Parallel 16
  • 35. Objects Actors 17
  • 36. Actors Objects 17
  • 37. Actors Objects American School Performance Engineering 17
  • 38. Actors Objects American Scandinavian School School Performance Conceptual Engineering Modeling 17
  • 39. Actors anomalies Objects American Scandinavian School School Performance Conceptual Engineering Modeling 17
  • 40. Actors Quest in this talk: anomalies Objects If Actor-Prog ramming Paradigm, is the new Scandinavian American School re the What a anomalies School ance uld see Coow? tual Perform sho we n ncep Engineering Modeling 17
  • 41. 18
  • 42. Making reliable distributed control systems in the presence of errors 19
  • 43. Making reliable distributed control systems in the presence of errors 19
  • 44. Making reliable distributed control systems in the presence of errors ■ The “secret weapon” for Ericsson’s market leading, real-time telephony systems. 19
  • 45. Making reliable distributed control systems in the presence of errors ■ The “secret weapon” for Ericsson’s market leading, real-time telephony systems. ■ 20+ years of experience to learn from. 19
  • 46. Erlang/OTP Open Telecommunications Platform ■ Embedded Distributed Systems ■ High Availability ■ In-Production Upgrades 20
  • 47. How to Learn Erlang 21
  • 48. How to Learn Erlang diss ect a frog, Don’t Build One! Nicolas Negropont e 21
  • 49. Your Erlang Program Platform Framework BEAM BEAM Emulator BIFs Your favorite OS 22
  • 50. Your Erlang Program Platform Framework BEAM BEAM Emulator BIFs Your favorite OS 22
  • 51. Your Erlang Program Platform Framework BEAM ERJANG BIFs JVM Java Virtual Machine Your favorite OS 23
  • 52. Anomalies in the object-oriented world view 24
  • 53. Figure 2-1 Interface and implementation interface implementation 11 10 9 8 7 6 25 Looking at such a unit from the inside, as the implem Graphics from Object-Oriented Programming with Objective C, Apple, 2011
  • 54. Figure 3-1 An object Encapsulation m et h o d me et h o d data thod m m et h o d 26
  • 55. and a data structure that serves Figure 3-1 An object fields of its data structure are it hide them from the rest of the The insight of object-oriented programming is to combine st m et h o da high-level unit, an object, and to give it language su data—in Figure 3-1 An object me and a data structure that serves those functions. The function m et h o d data thod fields of its data structure are its instanceovariables. The met hide them from the rest of the program, m et has Figure 3-1 illustrat d me m et h o d m et h o d data thod Figure 3-1 An object m et h o d m et h o d If you’ve ever tackled any kind of difficult programming problem groups of functions that work on a particular kind of data—implic me m et h o d Object-oriented programming makes these function groups expl data thod group, rather than its components.If you’ve ever tackled any kind The only way to an object’s dat m et h o d groups of functions that work o Object-oriented programming By combining both state and behavior in a single unit, an object b really is greater than the sum of itsgroup, rather thanis a componen parts. An object its kind of se over a specific functional area. It can play a full-fledged modular If you’ve ever tackled any kind By difficult programmingand be of combining both state prob really is greater than the sum o groups of functions that work on a particular kind of data—im 27 Terminology: Object-oriented terminology varies from language
  • 56. and a data structure that serves Figure 3-1 An object fields of its data structure are it hide them from the rest of the The insight of object-oriented programming is to combine st m et h o da high-level unit, an object, and to give it language su data—in Figure 3-1 An object me and a data structure that serves those functions. The function m et h o d data thod fields of its data structure are its instanceovariables. The met hide them from the rest of the program, m et has Figure 3-1 illustrat d me m et h o d m et h o d data thod Figure 3-1 An object m et h o d m et h o d If you’ve ever tackled any kind of difficult programming problem groups of functions that work on a particular kind of data—implic me m et h o d Object-oriented programming makes these function groups expl data thod group, rather than its components.If you’ve ever tackled any kind The only way to an object’s dat m et h o d groups of functions that work o Object-oriented programming By combining both state and behavior in a single unit, an object b really is greater than the sum of itsgroup, rather thanis a componen parts. An object its kind of se over a specific functional area. It can play a full-fledged modular If you’ve ever tackled any kind By difficult programmingand be of combining both state prob really is greater than the sum o groups of functions that work on a particular kind of data—im 27 Terminology: Object-oriented terminology varies from language
  • 57. and a data structure that serves Figure 3-1 An object fields of its data structure are it hide them from the rest of the The insight of object-oriented programming is to combine st m et h o da high-level unit, an object, and to give it language su data—in Figure 3-1 An object me and a data structure that serves those functions. The function m et h o d data thod fields of its data structure are its instanceovariables. The met hide them from the rest of the program, m et has Figure 3-1 illustrat d me m et h o d m et h o d data thod Figure 3-1 An object m et h o d m et h o d If you’ve ever tackled any kind of difficult programming problem groups of functions that work on a particular kind of data—implic me m et h o d Object-oriented programming makes these function groups expl data thod group, rather than its components.If you’ve ever tackled any kind The only way to an object’s dat m et h o d groups of functions that work o Object-oriented programming By combining both state and behavior in a single unit, an object b really is greater than the sum of itsgroup, rather thanis a componen parts. An object its kind of se over a specific functional area. It can play a full-fledged modular If you’ve ever tackled any kind By difficult programmingand be of combining both state prob really is greater than the sum o groups of functions that work on a particular kind of data—im 27 Terminology: Object-oriented terminology varies from language
  • 58. and a data structure that serves Figure 3-1 An object fields of its data structure are it hide them from the rest of the The insight of object-oriented programming is to combine st m et h o da high-level unit, an object, and to give it language su data—in Figure 3-1 An object me and a data structure that serves those functions. The function m et h o d data thod fields of its data structure are its instanceovariables. The met hide them from the rest of the program, m et has Figure 3-1 illustrat d me m et h o d m et h o d data thod Figure 3-1 An object m et h o d m et h o d If you’ve ever tackled any kind of difficult programming problem groups of functions that work on a particular kind of data—implic me m et h o d Object-oriented programming makes these function groups expl data thod group, rather than its components.If you’ve ever tackled any kind The only way to an object’s dat m et h o d groups of functions that work o Object-oriented programming By combining both state and behavior in a single unit, an object b really is greater than the sum of itsgroup, rather thanis a componen parts. An object its kind of se over a specific functional area. It can play a full-fledged modular If you’ve ever tackled any kind By difficult programmingand be of combining both state prob really is greater than the sum o groups of functions that work on a particular kind of data—im 27 Terminology: Object-oriented terminology varies from language
  • 59. and a data structure that serves Figure 3-1 An object fields of its data structure are it hide them from the rest of the The insight of object-oriented programming is to combine st m et h o da high-level unit, an object, and to give it language su data—in Figure 3-1 An object me and a data structure that serves those functions. The function m et h o d data thod fields of its data structure are its instanceovariables. The met hide them from the rest of the program, m et has Figure 3-1 illustrat d me m et h o d m et h o d data thod Figure 3-1 An object m et h o d m et h o d If you’ve ever tackled any kind of difficult programming problem groups of functions that work on a particular kind of data—implic me m et h o d Object-oriented programming makes these function groups expl data thod group, rather than its components.If you’ve ever tackled any kind The only way to an object’s dat m et h o d groups of functions that work o Object-oriented programming By combining both state and behavior in a single unit, an object b really is greater than the sum of itsgroup, rather thanis a componen parts. An object its kind of se over a specific functional area. It can play a full-fledged modular If you’ve ever tackled any kind By difficult programmingand be of combining both state prob really is greater than the sum o groups of functions that work on a particular kind of data—im 27 Terminology: Object-oriented terminology varies from language
  • 60. and a data structure that serves Figure 3-1 An object fields of its data structure are it hide them from the rest of the The insight of object-oriented programming is to combine st m et h o da high-level unit, an object, and to give it language su data—in Figure 3-1 An object ma ly no me and a data structure that serves those functions. The function m et h o d data A thod fields of its data structure are its instanceovariables. The met hide them from the rest of the program, m et has Figure 3-1 illustrat d me m et h o d m et h o d data thod Figure 3-1 An object m et h o d m et h o d If you’ve ever tackled any kind of difficult programming problem groups of functions that work on a particular kind of data—implic me m et h o d Object-oriented programming makes these function groups expl data thod group, rather than its components.If you’ve ever tackled any kind The only way to an object’s dat m et h o d groups of functions that work o Object-oriented programming By combining both state and behavior in a single unit, an object b really is greater than the sum of itsgroup, rather thanis a componen parts. An object its kind of se over a specific functional area. It can play a full-fledged modular If you’ve ever tackled any kind By difficult programmingand be of combining both state prob really is greater than the sum o groups of functions that work on a particular kind of data—im 27 Terminology: Object-oriented terminology varies from language
  • 61. and a data structure that serves those functions. The functions are known as the object’s methods, a fields of its data structure are its instance variables. The methods wrap around the instance variable hide them from the rest of the program, as Figure 3-1 illustrates. The insight of object-oriented programming is to 3-1 Figure combineAn object behavior—data The insight of object-oriented programming is to combine state and and operations on CHAPTER a high-level unit, an object, and to give it language support. An object is a group of related functions data—in 3 data—in a high-level unit, an object, and to give it languag et h o d and a data structure that serves those functions.m functions are known as the object’s methods, and the serves those functions. The funct The and a data structure that fields of its data structure are its instance variables. The methods wrap around the instance variables and fields of its data structure are its instance variables. The m me m et h o d hide them from the rest of the program, as Figuredata illustrates. 3-1 hide them from the rest of the program, as Figure 3-1 illus thod Figure 3-1 An object m et h o d Figure 3-1 An object The Object Model m et h o d CHAPTER 3 m et h o d me me If you’ve ever tackled any kind of difficult programming problem, it’s likely that your design has inclu m et h o d m et h o d data groups of functions that work on a particular kind data thod thod of data—implicit “objects” without the language su Object-oriented programming makes these function groups explicit and permits you to think in terms m et h o d m et h o d group, rather than its components. The only way to an object’s data, the only interface, is through its me The insight of object-oriented programming is to combine state and behavior—data single unit, an object becomes more than either alone; the By combining both state and behavior in a and operations on The Object Model data—in a high-level unit, an object, and toreallyit language support.sumobjectparts. An object is a kind of self-sufficient “subprogram” with juris give is greater than the An of its is a group of related functions If you’ve ever tackled any kind of difficult programming problem, known that your design has included and a data structure that serves those functions. The functions areit’s likelyas the object’s methods,tackled any kind of difficult programming pr If you’ve ever and the over a specific functional area. It can play a full-fledged modular role within a larger program design groups its data structure are on a particular kind of The methods “objects” without groups variables and fields ofof functions that work its instance variables. data—implicitwrap around the instanceof functions that work on a particular kind of data— the language support. Object-oriented programming program, as function groups explicit and permits you to think in terms programming makes these function group hide them from the rest of the makes these Figure 3-1 illustrates. Object-oriented of the Terminology: Object-oriented terminology variesratherlanguage to language.The only way to an objec group, from than its components. For example, in C++, m group, rather than its components. The only way to an object’s data, the only interface, is through its methods. are called member functions and instance variables are known as data members. This document uses Figure 3-1 An object By combining both state and behavior in a terminology ofobject becomes more than basis in Smalltalk. state and behavior in a single unit, an o single unit, an Objective-C, which has its either alone; the whole By combining both The insighta kind of self-sufficient “subprogram” iscombinethan the sum of its parts. An object is a kin really is greater than the sum of its parts. An object is of object-oriented programming is to greater state and behavior—data and operations really with jurisdiction m et h o d functional area. It can play a full-fledged modular rolean object, and toover a specific functional area. It can play a full-fledged fun over a specific data—in a high-level unit, within a larger program design. support. An object is a group of related mo give it language For example, if you were to write a program that The functions are known as the object’s methods, a and a data structure that serves those functions. modeled home water usage, you might invent obje me m et h o d data fields of its data structure are its instance variables. The methods wrap around Faucet object that represent the various components of the water-delivery system. One might be a the instance variable thod Terminology: Object-oriented terminology varies from language and stopprogram, ofTerminology:methods hide methods to start to language. flow as water, set the rate of have them from the rest of the the For example, in3-1 illustrates.flow, return the amount of water con Figure C++, Object-oriented terminology varies from lan are called member functions and instance variables are known as so on. To do this work, acalled member functions and instance variables to keep m et h o d in a given period, and data members. This document uses the would need instance variables are kno are Faucet object terminology of Objective-C, which has its basis in Smalltalk. is open or shut, how much water is being used, andwhich has its basis in Smalltal of whether the tap object terminology of Objective-C, where the water is coming fr Figure 3-1 An Clearly, a programmatic Faucet object can be smarter than a real one (it’s analogous to a mechanical For example, if you were to write a program thatm et h o d problem,water usage, you mightexample, if you to If you’ve ever tackled any kind of difficult programming home it’s likely that attached). invent includedwere to like anyprogramcomponent, ex modeled For objects write a that modeled with lots of gauges and instruments your design hasBut even a real faucet, system represent functions that work on a particular kind of data—implicit “objects”be a Faucet language support. groups of the various components of the water-delivery system. One might without represent theyou need programming the water-delivery th the object that wouldcomponents of units, like objects, sy various me m et h o d both state and behavior. To effectively model a system, have methods toprogramming makes thesewater, data rate of flow, return the amountthink in terms of theand stop the flow of water, set the ra Object-oriented start and stop the flow ofcombine state and behavior. permits you to of methods to start set the have water consumed thod function groups explicit and in a given period, and so on. To doThe only wayFaucet object would need instance variables toperiod, and so on. To do this work, a Faucet ob group, rather than its components. this work, a to an object’s data, the only interface, is through its methods. in a given keep track of whether the tap is open or shut, how much water is being used,network of interconnected objects that open or shut, how much water part o A program consists of a and where the water is coming from.is call upon each other to solve a is bei m et h o d of whether the tap By combining both state and behavior in a puzzle unit, an objectin Figure 3-2 (page 16)). Each object has a specific role to play in the overall des single (as illustrated becomes more than either alone; the whole Clearly, a programmatic Faucet its parts. An object is athan a real one (it’s analogous Clearly, a programmatic Faucet object can be smarter tha really is greater than the sum of object can be smarter kind of self-sufficient “subprogram” with jurisdiction to a mechanical faucet the program and is able to communicate with other objects. Objects communicate through messages with a specific functional area. It can attached). But evenmodular role within a larger program design. over lots of gauges and instruments play a full-fledged to perform methods. systemwith lots of gauges and instruments attached). But even a a real faucet, like any component, exhibits are requests both state and behavior. To effectively model a system, you need programming units, like objects, that also it’s likely that your design has inclu If you’ve ever tackled any kind of difficult programming problem, To effectively model a system, yo both state and behavior. combine state and behavior. groups of functions that work on a particular kind ofstate and behavior. combine data—implicit “objects” without the language su Terminology: Object-oriented terminology varies from language to language. For example, in C++, methods and permits you to think in terms Object-oriented programming makes these function groups explicit 28 are called member functions and instance variables are known ascall upon each otherdocument part of the a network interface, is through its me group, rather than its data members. This A solvean object’s of A program consists of a network of interconnected objects thatcomponents. The onlytoprogramuses thedata, the only of interconnected object way to a consists
  • 62. and a data structure that serves those functions. The functions are known as the object’s methods, a fields of its data structure are its instance variables. The methods wrap around the instance variable hide them from the rest of the program, as Figure 3-1 illustrates. The insight of object-oriented programming is to 3-1 Figure combineAn object behavior—data The insight of object-oriented programming is to combine state and and operations on CHAPTER a high-level unit, an object, and to give it language support. An object is a group of related functions data—in 3 data—in a high-level unit, an object, and to give it languag et h o d and a data structure that serves those functions.m functions are known as the object’s methods, and the serves those functions. The funct The and a data structure that fields of its data structure are its instance variables. The methods wrap around the instance variables and fields of its data structure are its instance variables. The m me m et h o d hide them from the rest of the program, as Figuredata illustrates. 3-1 hide them from the rest of the program, as Figure 3-1 illus thod Figure 3-1 An object m et h o d Figure 3-1 An object The Object Model m et h o d CHAPTER 3 m et h o d me me If you’ve ever tackled any kind of difficult programming problem, it’s likely that your design has inclu m et h o d m et h o d data groups of functions that work on a particular kind data thod thod of data—implicit “objects” without the language su Object-oriented programming makes these function groups explicit and permits you to think in terms m et h o d m et h o d group, rather than its components. The only way to an object’s data, the only interface, is through its me The insight of object-oriented programming is to combine state and behavior—data single unit, an object becomes more than either alone; the By combining both state and behavior in a and operations on The Object Model data—in a high-level unit, an object, and toreallyit language support.sumobjectparts. An object is a kind of self-sufficient “subprogram” with juris give is greater than the An of its is a group of related functions If you’ve ever tackled any kind of difficult programming problem, known that your design has included and a data structure that serves those functions. The functions areit’s likelyas the object’s methods,tackled any kind of difficult programming pr If you’ve ever and the over a specific functional area. It can play a full-fledged modular role within a larger program design groups its data structure are on a particular kind of The methods “objects” without groups variables and fields ofof functions that work its instance variables. data—implicitwrap around the instanceof functions that work on a particular kind of data— the language support. Object-oriented programming program, as function groups explicit and permits you to think in terms programming makes these function group hide them from the rest of the makes these Figure 3-1 illustrates. Object-oriented of the Terminology: Object-oriented terminology variesratherlanguage to language.The only way to an objec group, from than its components. For example, in C++, m group, rather than its components. The only way to an object’s data, the only interface, is through its methods. are called member functions and instance variables are known as data members. This document uses Figure 3-1 An object By combining both state and behavior in a terminology ofobject becomes more than basis in Smalltalk. state and behavior in a single unit, an o single unit, an Objective-C, which has its either alone; the whole By combining both The insighta kind of self-sufficient “subprogram” iscombinethan the sum of its parts. An object is a kin really is greater than the sum of its parts. An object is of object-oriented programming is to greater state and behavior—data and operations really with jurisdiction m et h o d functional area. It can play a full-fledged modular rolean object, and toover a specific functional area. It can play a full-fledged fun over a specific data—in a high-level unit, within a larger program design. support. An object is a group of related mo give it language For example, if you were to write a program that The functions are known as the object’s methods, a and a data structure that serves those functions. modeled home water usage, you might invent obje me m et h o d data fields of its data structure are its instance variables. The methods wrap around Faucet object that represent the various components of the water-delivery system. One might be a the instance variable thod Terminology: Object-oriented terminology varies from language and stopprogram, ofTerminology:methods hide methods to start to language. flow as water, set the rate of have them from the rest of the the For example, in3-1 illustrates.flow, return the amount of water con Figure C++, Object-oriented terminology varies from lan are called member functions and instance variables are known as so on. To do this work, acalled member functions and instance variables to keep m et h o d in a given period, and data members. This document uses the would need instance variables are kno are Faucet object terminology of Objective-C, which has its basis in Smalltalk. is open or shut, how much water is being used, andwhich has its basis in Smalltal of whether the tap object terminology of Objective-C, where the water is coming fr Figure 3-1 An Clearly, a programmatic Faucet object can be smarter than a real one (it’s analogous to a mechanical For example, if you were to write a program thatm et h o d problem,water usage, you mightexample, if you to If you’ve ever tackled any kind of difficult programming home it’s likely that attached). invent includedwere to like anyprogramcomponent, ex modeled For objects write a that modeled with lots of gauges and instruments your design hasBut even a real faucet, system represent functions that work on a particular kind of data—implicit “objects”be a Faucet language support. groups of the various components of the water-delivery system. One might without represent theyou need programming the water-delivery th the object that wouldcomponents of units, like objects, sy various me m et h o d both state and behavior. To effectively model a system, have methods toprogramming makes thesewater, data rate of flow, return the amountthink in terms of theand stop the flow of water, set the ra Object-oriented start and stop the flow ofcombine state and behavior. permits you to of methods to start set the have water consumed thod function groups explicit and in a given period, and so on. To doThe only wayFaucet object would need instance variables toperiod, and so on. To do this work, a Faucet ob group, rather than its components. this work, a to an object’s data, the only interface, is through its methods. in a given keep track of whether the tap is open or shut, how much water is being used,network of interconnected objects that open or shut, how much water part o A program consists of a and where the water is coming from.is call upon each other to solve a is bei m et h o d of whether the tap By combining both state and behavior in a puzzle unit, an objectin Figure 3-2 (page 16)). Each object has a specific role to play in the overall des single (as illustrated becomes more than either alone; the whole Clearly, a programmatic Faucet its parts. An object is athan a real one (it’s analogous Clearly, a programmatic Faucet object can be smarter tha really is greater than the sum of object can be smarter kind of self-sufficient “subprogram” with jurisdiction to a mechanical faucet the program and is able to communicate with other objects. Objects communicate through messages with a specific functional area. It can attached). But evenmodular role within a larger program design. over lots of gauges and instruments play a full-fledged to perform methods. systemwith lots of gauges and instruments attached). But even a a real faucet, like any component, exhibits are requests both state and behavior. To effectively model a system, you need programming units, like objects, that also it’s likely that your design has inclu If you’ve ever tackled any kind of difficult programming problem, To effectively model a system, yo both state and behavior. combine state and behavior. groups of functions that work on a particular kind ofstate and behavior. combine data—implicit “objects” without the language su Terminology: Object-oriented terminology varies from language to language. For example, in C++, methods and permits you to think in terms Object-oriented programming makes these function groups explicit 28 are called member functions and instance variables are known ascall upon each otherdocument part of the a network interface, is through its me group, rather than its data members. This A solvean object’s of A program consists of a network of interconnected objects thatcomponents. The onlytoprogramuses thedata, the only of interconnected object way to a consists
  • 63. and a data structure that serves those functions. The functions are known as the object’s methods, a fields of its data structure are its instance variables. The methods wrap around the instance variable hide them from the rest of the program, as Figure 3-1 illustrates. The insight of object-oriented programming is to 3-1 Figure combineAn object behavior—data The insight of object-oriented programming is to combine state and and operations on CHAPTER 3 CHAPTER a high-level unit, an object, and to give it language support. An object is a group of related functions data—in 3 data—in a high-level unit, an object, and to give it languag et h o d and a data structure that serves those functions.m functions are known as the object’s methods, and the serves those functions. The funct The and a data structure that fields of its data structure are its instance variables. The methods wrap around the instance variables and fields of its data structure are its instance variables. The m me m et h o d hide them from the rest of the program, as Figuredata illustrates. 3-1 hide them from the rest of the program, as Figure 3-1 illus thod Figure 3-1 An object Figure 3-1 An object The Object Model m et h o d The Object Model m et h o d CHAPTER 3 m et h o d me me If you’ve ever tackled any kind of difficult programming problem, it’s likely that your design has inclu m et h o d m et h o d data groups of functions that work on a particular kind data thod thod of data—implicit “objects” without the language su Object-oriented programming makes these function groups explicit and permits you to think in terms m et h o d m et h o d group, rather than its components. The only way to an object’s data, the only interface, is through its me The insight of object-oriented programming is to combine The insight of object-oriented programming is to combine state and behavior—data data—in a high-level unit, an object, and to give it languag and operations on The Object Model By combining both state and behavior in a single unit, an object becomes more than either alone; the data—in a high-level unit, an object, and toreallyit language support.sumobjectparts. An object is a kind of self-sufficient “subprogram” withfunct give is greater than the An of its is a group of related functions serves those functions. The juris and a data structure that If you’ve ever tackled any kind of difficult programming problem, known that your design has included and a data structure that serves those functions. The functions areit’s likelyas the object’s methods,tackled any kind ofinstance programming pr If you’ve its data structure fields of ever and the difficult variables. The over a specific functional area. It can play a full-fledged modular roleare its a larger program designm within groups its data structure are on a particular kind of The methods “objects” without groups variables and work program, as Figure 3-1 illus fields ofof functions that work its instance variables. data—implicitwrap around the instanceof functions that of theon a particular kind of data— hidelanguage support. the them from the rest Object-oriented programming program, as function groups explicit and permits you to think in terms programming makes these function group hide them from the rest of the makes these Figure 3-1 illustrates. Object-oriented of the Terminology: Object-oriented terminology variesratherlanguage to language.The only way to an objec group, from than its components. For example, in C++, m group, rather than its components. The only way to an object’s data, the only interface, is through its methods. Figure 3-1 are called member functions and instance variables are knownobject members. This document uses An as data Figure 3-1 An object By combining both state and behavior in a terminology ofobject becomes more than basis in Smalltalk. state and behavior in a single unit, an o single unit, an Objective-C, which has its either alone; the whole By combining both The insighta kind of self-sufficient “subprogram”m combinethan the sum of its parts. An object is a kin really is greater than the sum of its parts. An object is of object-oriented programming is to et h ojurisdictionand behavior—data and operations really is greater state with d et h o d over a specific functional area. It can play a full-fledged modular rolean object, and toover a specific functional area. It can play a full-fledged fun m data—in a high-level unit, within a larger program design. support. An object is a group of related mo give it language me m et h o d For example, if you were to write a program that The functions are known as the object’s methods, a and a data structure that serves those functions. modeled home water usage, you might invent obje me m et h o d data thod data fields of its data structure are its instance variables. The methods wrap around Faucet object that represent the various components of the water-delivery system. One might be a the instance variable thod Terminology: Object-oriented terminology varies from language and stopprogram, ofTerminology:methods hide methods to start to language. flow as water, set the rate of have them from the rest of the the For example, in3-1 illustrates.flow, return the amount of water con Figure C++, Object-oriented terminology varies from lan m et h o d are called member functions and instance variables are known as so on. To do this work, acalled member functions and instance variables to keep m et h o d in a given period, and data members. This document uses the would need instance variables are kno are Faucet object terminology of Objective-C, which has its basis in Smalltalk. is open or shut, how much water is being used, andwhich has its basis in Smalltal of whether the tap object terminology of Objective-C, where the water is coming fr Figure 3-1 An Clearly, a programmatic Faucet object can be smarter than a real one (it’sof difficult programming pr analogous to a mechanical For example, if you were to write a program thatm et h o d problem,water usage, you mightexample, if you to anyto write a program that modeled modeled home it’s likely that your design has includedwere kind If you’ve ever tackled any kind of difficult programming If you’ve ever tackled For invent objects with lots of gauges and instruments attached). But even a real faucet, like any system component, ex represent functions that work on a particular kind of data—implicit “objects”be a Faucet language support. work on a particular kind of data— groups of the various components of the water-delivery system. One might without groups of functions that represent the various components of the water-delivery sy the object that would me m et h o d both state and behavior. To effectively model a system, you need programming units, like objects, th have methods toprogramming makes thesewater, data rate of flow, return the amountthink in terms of theand stop the flow of function the ra Object-oriented programming makes thesewater, set group Object-oriented start and stop the flow ofcombine state and behavior. permits you to of methods to start set the have water consumed thod function groups explicit and in a given period, and so on. To doThe only wayFaucet object would need instance variables toperiod, and so on. To doThe only wayFaucet ob group, rather than its components. this work, a to an objec group, rather than its components. this work, a to an object’s data, the only interface, is through its methods. in a given keep track of whether the tap is open or shut, how much water is being used,network of interconnected objects that open or shut, how much water part o A program consists of a and where the watercombining from.is calland behavior in a single unit, an o of whether the tap is coming is bei both state upon each other to solve a m et h o d By By combining both state and behavior in a puzzle unit, an objectin Figure 3-2 (page 16)). Each greater has a the sumrole to play in the overall des single (as illustrated becomes more than either alone; thethan specific of object whole Clearly, a programmatic Faucet its parts. An object is athan a real one (it’s analogous really is a programmatic Faucet its parts. An object is atha really is greater than the sum of object can be smarter kind of self-sufficient “subprogram” with jurisdiction Clearly, to a mechanical faucet object can be smarter kin the program and is able to communicate with other objects. Objects communicate through messages over a specific functional area. It can play a full-fledged mo with a specific functional area. It can attached). But evenmodular role within a larger program design. over lots of gauges and instruments play a full-fledged to perform methods. systemwith lots of gauges and instruments attached). But even a a real faucet, like any component, exhibits are requests both state and behavior. To effectively model a system, you need programming units, like objects, that also it’s likely that your design has inclu If you’ve ever tackled any kind of difficult programming problem, To effectively model a system, yo both state and behavior. combine state and behavior. groups of functions that work on a particular kind ofstate Object-oriented terminology varies from lan combine data—implicit “objects” without the language su Terminology: and behavior. Terminology: Object-oriented terminology varies from language to language. For example, in C++, methods and permits youvariablesin terms Object-oriented programming makes these function memberexplicit and instance to think are kno are called groups functions 28 are called member functions and instance variables are known ascall upon each otherdocument part of the a network interface,basis in Smalltal data members. This A programuses Objective-C, only ofhas its is through its me group, rather than its terminology of the of A program consists of a network of interconnected objects thatcomponents. The onlyto solvean object’s data, the which interconnected object way to a consists
  • 64. Active Object + State Machine Figure 3-1 An object mailbox m et h o d me et h o d data thod m m et h o d 29
  • 65. Active Object + State Machine Figure 3-1 An object mailbox m et h o d me et h o d data thod m m et h o d 29
  • 66. Active Object + State Machine Figure 3-1 An object mailbox m et h o d me et h o d data thod m m et h o d 30
  • 67. Active Object + State Machine Figure 3-1 An object mailbox m et h o d me et h o d data thod m m et h o d 30
  • 68. box empty full(X) 31
  • 69. box empty {‘put’,X} full(X) 31
  • 70. box empty {‘put’,X} {‘take’,From} / send(From, X) full(X) 31
  • 71. box() ➞ empty(). empty() ➞ box receive {‘put’, X} ➞ full(X) end. empty full(X) ➞ {‘put’,X} {‘take’,From} / send(From, X) receive {‘take’, From} ➞ full(X) From ! X, empty() end. 32
  • 72. box() ➞ empty(). empty() ➞ box receive {‘put’, X} ➞ full(X) end. empty full(X) ➞ {‘put’,X} {‘take’,From} / send(From, X) receive {‘take’, From} ➞ full(X) From ! X, empty() end. {‘peek’,From} / send(From,{‘ok’, X}) 33
  • 73. box() ➞ empty(). empty() ➞ box receive {‘put’, X} ➞ full(X) end. empty full(X) ➞ {‘put’,X} {‘take’,From} / send(From, X) receive {‘take’, From} ➞ full(X) From ! X, empty(); {‘peek’, From} ➞ {‘peek’,From} / send(From,{‘ok’, X}) From ! {‘ok’, X}, full(X) end. 34
  • 74. box() ➞ empty(). empty() ➞ box receive {‘put’, X} ➞ full(X) end. empty full(X) ➞ {‘put’,X} {‘take’,From} / send(From, X) receive {‘take’, From} ➞ full(X) From ! X, empty(); {‘peek’, From} ➞ {‘peek’,From} / send(From,{‘ok’, X}) From ! {‘ok’, X}, full(X) end. 34
  • 75. box() ➞ empty(). empty() ➞ receive {‘put’, X} ➞ full(X) end. full(X) ➞ receive {‘take’, From} ➞ From ! X, empty(); {‘peek’, From} ➞ From ! {‘ok’, X}, full(X) end. 35
  • 76. box() ➞ empty(). Box = spawn(fun box/0), empty() ➞ receive {‘put’, X} ➞ full(X) end. full(X) ➞ receive {‘take’, From} ➞ From ! X, empty(); {‘peek’, From} ➞ From ! {‘ok’, X}, full(X) end. 35
  • 77. box() ➞ empty(). Box = spawn(fun box/0), empty() ➞ Box ! {‘put’, 27}, receive {‘put’, X} ➞ full(X) end. full(X) ➞ receive {‘take’, From} ➞ From ! X, empty(); {‘peek’, From} ➞ From ! {‘ok’, X}, full(X) end. 35
  • 78. box() ➞ empty(). Box = spawn(fun box/0), empty() ➞ Box ! {‘put’, 27}, receive {‘put’, X} ➞ Box ! {‘take’, self()}, full(X) receive end. Value ➞ print(Value) end full(X) ➞ receive {‘take’, From} ➞ From ! X, empty(); {‘peek’, From} ➞ From ! {‘ok’, X}, full(X) end. 35
  • 79. Interface Objects Fixed API Protocol Actors API changes with internal state 36
  • 80. ma ly A no Interface Objects Fixed API Protocol Actors API changes with internal state 36
  • 87. But isn’t this expensive? 38
  • 88. But isn’t this expensive? ... heard in the ‘90s Use Objects! 38
  • 89. But isn’t this expensive? ... heard in the ‘90s 100.000’s of objects, Use Objects! are you crazy? 38
  • 90. But isn’t this expensive? ... heard yesterday Use Actors! 38
  • 91. But isn’t this expensive? ... heard yesterday 100.000’s of processes, Use Actors! silly you! 38
  • 92. fields of its data structu hide them from the rest Effect Containment 3-1 Figure An obje m et h o d ■ Functional languages me et h o d disallow effects data thod ■ Many object-oriented m m et h o d styles encourage side effects. ■ Actors confine effects If you’ve ever tackled an groups of functions tha Object-oriented program 39 group, rather than its co
  • 93. From C++ to Java Garbage Collection From Java to Erlang State Containment 40
  • 94. Activity Composition The Object Model The Object Model The insight of object-oriented programming is to combine state and behavior—data and operations on The insight of object-oriented programming is to combine state and data—in a high-level unit, an object, and to give it language support. An object is a group of related functions give it language support. data—in a high-level unit, an object, and to and a data the object’s methods, and the and a data structure that serves those functions. The functions are known asstructure that serves those functions. The functions are k fields of its data structure are its instance variables. The methods wrap around the instance variables and variables. The methods w fields of its data structure are its instance hide them from the rest of the program, as Figure 3-1 illustrates. hide them from the rest of the program, as Figure 3-1 illustrates. Figure 3-1 An object Figure 3-1 An object m et h o d me spawn m et h o d me m et h o d m et h o d data data thod thod m et h o d m et h o d If you’ve ever tackled any kind of difficult programming problem,If you’ve ever tackled any kind included programming problem, it’ it’s likely that your design has of difficult groups of functions that work on a particular kind of data—implicit “objects” without the language a particular kind of data—implicit “ groups of functions that work on support. Object-oriented programming makes these function groups explicit and permits you to think in terms ofthese function groups explicit Object-oriented programming makes the group, rather than its components. The only way to an object’s data, the only interface, iscomponents. The only way to an object’s data, th group, rather than its through its methods. By combining both state and behavior in a single unit, an object becomes more than eitherand behavior in a single unit, an object bec By combining both state alone; the whole really is greater than the sum of its parts. An object is a kind of self-sufficient “subprogram”sum of its parts. An object is a kind of self-s really is greater than the with jurisdiction over a specific functional area. It can play a full-fledged modular role within a larger program design. play a full-fledged modular role over a specific functional area. It can Terminology: Object-oriented terminology varies from language to language. For example, in C++, methods varies from language to Terminology: Object-oriented terminology are called member functions and instance variables are known as data members. Thisfunctions and instance variables are known as da are called member document uses the terminology of Objective-C, which has its basis in Smalltalk. terminology of Objective-C, which has its basis in Smalltalk. For example, if you were to write a program that modeled home water usage, you might invent objects to that modeled home wa For example, if you were to write a program represent the various components of the water-delivery system. One mightthe a Faucet object thatof the water-delivery system. On represent be various components would have methods to start and stop the flow of water, set the rate of flow, return the amount and stop consumed water, set the rate of flow have methods to start of water the flow of 41 in a given period, and so on. To do this work, a Faucet object would need instanceand so on.to keep track in a given period, variables To do this work, a Faucet object woul
  • 95. Activity Composition The Object Model The Object Model The insight of object-oriented programming is to combine state and behavior—data and operations on The insight of object-oriented programming is to combine state and data—in a high-level unit, an object, and to give it language support. An object is a group of related functions give it language support. data—in a high-level unit, an object, and to and a data the object’s methods, and the and a data structure that serves those functions. The functions are known asstructure that serves those functions. The functions are k fields of its data structure are its instance variables. The methods wrap around the instance variables and variables. The methods w fields of its data structure are its instance hide them from the rest of the program, as Figure 3-1 illustrates. hide them from the rest of the program, as Figure 3-1 illustrates. Figure 3-1 An object Figure 3-1 An object m et h o d me link m et h o d me m et h o d m et h o d data data thod thod m et h o d m et h o d If you’ve ever tackled any kind of difficult programming problem,If you’ve ever tackled any kind included programming problem, it’ it’s likely that your design has of difficult groups of functions that work on a particular kind of data—implicit “objects” without the language a particular kind of data—implicit “ groups of functions that work on support. Object-oriented programming makes these function groups explicit and permits you to think in terms ofthese function groups explicit Object-oriented programming makes the group, rather than its components. The only way to an object’s data, the only interface, iscomponents. The only way to an object’s data, th group, rather than its through its methods. By combining both state and behavior in a single unit, an object becomes more than eitherand behavior in a single unit, an object bec By combining both state alone; the whole really is greater than the sum of its parts. An object is a kind of self-sufficient “subprogram”sum of its parts. An object is a kind of self-s really is greater than the with jurisdiction over a specific functional area. It can play a full-fledged modular role within a larger program design. play a full-fledged modular role over a specific functional area. It can Terminology: Object-oriented terminology varies from language to language. For example, in C++, methods varies from language to Terminology: Object-oriented terminology are called member functions and instance variables are known as data members. Thisfunctions and instance variables are known as da are called member document uses the terminology of Objective-C, which has its basis in Smalltalk. terminology of Objective-C, which has its basis in Smalltalk. For example, if you were to write a program that modeled home water usage, you might invent objects to that modeled home wa For example, if you were to write a program represent the various components of the water-delivery system. One mightthe a Faucet object thatof the water-delivery system. On represent be various components would have methods to start and stop the flow of water, set the rate of flow, return the amount and stop consumed water, set the rate of flow have methods to start of water the flow of 42 in a given period, and so on. To do this work, a Faucet object would need instanceand so on.to keep track in a given period, variables To do this work, a Faucet object woul

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n
  136. \n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. \n
  143. \n
  144. \n
  145. \n
  146. \n
  147. \n
  148. \n
  149. \n
  150. \n
  151. \n
  152. \n
  153. \n
  154. \n
  155. \n
  156. \n
  157. \n
  158. \n
  159. \n
  160. \n
  161. \n
  162. \n
  163. \n
  164. \n
  165. \n
  166. \n
  167. \n
  168. \n
  169. \n
  170. \n
  171. \n
  172. \n
  173. \n
  174. \n
  175. \n
  176. \n
  177. \n
  178. \n
  179. \n
  180. \n
  181. \n
  182. \n
  183. \n
  184. \n