In November 2009 I set out on a journey to learn Erlang. And not just learn it: I wanted to immerse myself in it, get under it's skin, feel it, get to think like Erlang. I took it for a test drive, and ended up spending 18 months in Erlang's company.
This is the story of my trip. Not so much a talk about Erlang itself, but about what I realized on the way about where things are going. The systems that we build are getting increasingly integrated, distributed, and fragile. And becoming so at a disturbing rate when I think about it.
Viewing the world from behind the steering wheel of this old beauty, I'll take you on a tour of some of the significant issues we're dealing with in today's software systems: cloud, multi-core, integration, high availability, and living with the fact that our software isn't perfect.
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
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
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
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
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
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
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