Concepts of Programming Languages

(Sean Pound) #1

524 Chapter 12 Support for Object-Oriented Programming


T


his chapter begins with a brief introduction to object-oriented programming,
followed by an extended discussion of the primary design issues for inheri-
tance and dynamic binding. Next, the support for object-oriented program-
ming in Smalltalk, C++, Objective-C, Java, C#, Ada 95, and Ruby is discussed. The
chapter concludes with a short overview of the implementation of dynamic bindings
of method calls to methods in object-oriented languages.

12.1 Introduction


Languages that support object-oriented programming now are firmly
entrenched in the mainstream. From COBOL to LISP, including virtually
every language in between, dialects that support object-oriented program-
ming have appeared. C++, Objective-C, and Ada 95 support procedural and
data-oriented programming, in addition to object-oriented programming.
CLOS, an object-oriented version of LISP (Paepeke, 1993), also supports
functional programming. Some of the newer languages that were designed
to support object-oriented programming do not support other program-
ming paradigms but still employ some of the basic imperative structures
and have the appearance of the older imperative languages. Among these
are Java and C#. Ruby is a bit challenging to categorize: It is a pure object-
oriented language in the sense that all data are objects, but it is a hybrid
language in that one can use it for procedural programming. Finally,
there is the pure object-oriented but somewhat unconventional language:
Smalltalk. Smalltalk was the first language to offer complete support for
object- oriented programming. The details of support for object-oriented
programming vary widely among languages, and that is the primary topic
of this chapter.
This chapter relies heavily on Chapter 11. It is, in a sense, a continua-
tion of that chapter. This relationship reflects the reality that object-oriented
programming is, in essence, an application of the principle of abstraction to
abstract data types. Specifically, in object-oriented programming, the common-
ality of a collection of similar abstract data types is factored out and put in a
new type. The members of the collection inherit these common parts from that
new type. This feature is inheritance, which is at the center of object-oriented
programming and the languages that support it.
The other characterizing feature of object-oriented programming,
dynamic binding of method calls to methods, is also extensively discussed in
this chapter.
Although object-oriented programming is supported by some of the func-
tional languages, for example, CLOS, OCaml, and F#, those languages are not
discussed in this chapter.
Free download pdf