History of Object Orientation

Download Report

Transcript History of Object Orientation

History of Object Orientation
CSE301
University of Sunderland
Harry R. Erwin, PhD
What is Object-Orientation?
• Programming is one of the most complicated and difficult
of human activities.
• It helps a great deal if the programme being developed is
analogous to a real world solution to the problem.
–
–
–
–
requirements are easier to understand,
more realism in the expectations of others,
debugging eased by access to the real world solution, and
the system is less likely to be obsolete in the end.
• This informal approach—the design of the programme
reflecting objects and their behaviour in the real world—is
called “object-oriented programming”
• First adopted by simulation programmers ca. 1960.
Strengths and Weaknesses of
Object-Orientation
• Strengths:
– the underlying objects are usually well-defined and
unchanging
– the structure of the solution is the thing that changes.
• Weaknesses:
– It is often very hard to grasp the behaviour of the
system as a whole, and
– There is no ‘best’ object decomposition for a system of
any size.
• Given that the brain already seems to work in this
way, this has a certain attraction.
Start with Objects
• So we start with objects.
– Correspond to real things, having state and behaviour.
– Computation is performed by objects communicating with
each other (“message passing”).
– Objects have memory (“state”), consisting of other objects.
– Each object belongs to a class, which defines the behaviour
for objects in that class.
– Classes inherit behaviour from other, more general classes,
forming a hierarchy.
• Alan Kay (1993) identified these characteristics as
fundamental to object-oriented programming.
Too Simple?
• Now this is clearly too simple.
• Consider a bat colony—the objects are bats, which
communicate and have memory.
• Much of their behaviour is general for bats, rather than
specific to an individual bat, but it is also clear that bats are
individuals and do internal computation, so an objectoriented model of a bat colony misses a lot.
• Also, bats change their behaviour (‘class’) with age.
• However, a model of the bat colony that fails to deal the
bats as individual behaving objects will miss a lot.
• An object-oriented model is in the right direction.
A Definition
• Object-oriented design and programming is an
approach to defining a solution to a problem that
uses the system's natural structure as a system of
interacting, behaving objects to provide a
programming solution.
• Although it will still miss some of the constraints
that would apply to a real-world solution, it
provides an approach to design that promises to
reduce the space of alternative designs enough that
the programmer is no longer working with abstract
thought.
Ancestry of Object-Oriented
Programming
• The ancestry of the object-oriented
programming can be found in imperative
and applicative languages. (Languages that
define processing instead of state and
relations.)
• The object-oriented paradigm emerged into
the general software community from the
simulation community in the early 1970s.
Simulation Objects
• Simulation programmers have always
viewed the world as objects and semantic
relationships, and this led to a natural
programming model consisting of objects
with
– Identity (object names or references)
– Behaviour (attributes or methods) and
– State (internal data).
Formalism and Simulation
• Theoretical workers have long been aware that
object-orientation is an inadequate model,
– because formal syntax cannot express semantics fully
(Alan Turing), and
– because the discrete representation of the world implicit
in programming means that formal syntax cannot
express causal entailment fully (Robert Rosen).
• It is an adequate approximation for our purposes.
• Note this means object-oriented programming
cannot be formalized completely.
ALGOL
• ALGOL 58 and 60 were early languages designed
to express the constructs of structured
programming in a fashion that could be reasoned
about effectively.
• Ancestors of many languages, including Pascal, C,
C++, C#, Java, Ada, and the simulation language,
Simula.
SIMULA
• SIMULA 1 and 67 were defined by Nygaard and Dahl as
object-oriented extensions of ALGOL.
• Given that object orientation did not exist at the time, it is
probably more accurate to describe it as a simulation
language based on ALGOL 60 that incorporated much of
what later would become known as object-orientation.
• In addition to the features most of us would recognize, it
incorporated something elegant called the ‘coroutine’.
– This is an instantiation of a subroutine with storage for input and
local data that could interact as an object with other coroutines.
– The corresponding concept in C++ and Java is the functor.
SmallTalk
• SmallTalk (Goldberg and Robson, 1982) was a consistent
attempt to define computation as objects interfacing by
message passing.
• Everything, including primitive types, was an object, and
all function calls were implemented using messages.
• This included primitive arithmetic operations!
• Smalltalk is slow (at least ten times slower than C++) but
is easy to write in if you can understand the model of
computation.
• I developed a major simulation for NASA in Smalltalk
about 1990, and found it a delightful language to use.
Eiffel
• Eiffel was a language designed by Bertrand Meyer
(1988) to implement ‘design by contract’. (If
you're interested in exploring Eiffel, it is available
in the Metrowerks Codewarrior development
environment for the Macintosh.)
• Meyer’s work in this area was an attempt to
formalize object-oriented programming, and was
moderately successful.
• The principles of modularity (discussed later) are
from Meyer.
C++
• C++—Bjarne Stroustrup (Stroustrup, various)
designed C++ as ‘C with classes’ to support his
simulation work.
• This language has become remarkably popular,
and is, with Java, one of the two major OO
languages.
• The 1995 version is remarkably powerful.
• My primary O-O expertise is in C++—I’m a
simulation modeller—and I’ve been involved in
the standards definition for the current version.
Java
• Java—A language deliberately designed for
object-oriented programming in embedded
environments. This module uses Java 5.
• Popular for web and cross-platform independent
applications.
• Evolving towards C++.
C#
• C#—Microsoft lost a court case with SUN over its
specialization of Java for the ‘WINTEL’ environment. C#
is Microsoft's attempt to take over the niche occupied by
Java. As part of this strategy, Microsoft removed the Java
Virtual Machine from the Windows operating system,
which led to a further court case that they lost.
• Java 5 is quite similar to C#.
Ada
• Ada 95 (AARM, 1995) is the latest generation of Ada.
• Originally designed (on the basis of Pascal) to be a
high-reliability language for embedded systems, but
soon accumulated features to support almost any US
Department of Defense application.
• Not designed to be object-oriented, but during the
1980s-90s, support for object-oriented programming
was added to the wish-list.
• Named after Augusta Ada Byron, Lady Lovelace, a
daughter of Lord Byron and the first computer
programmer.
Conclusions
• Just like you can write FORTRAN in
almost any language, you can use objectorientation in almost any language, but…
• Some languages make it easier to be objectoriented.
• That’s why we are using Java.