Concepts of Programming Languages

(Sean Pound) #1

538 Chapter 12 Support for Object-Oriented Programming


Smalltalk’s dynamic binding allows type errors to go undetected until run
time. A program can be written that includes messages to nonexistent methods
and it will not be detected until the messages are sent, which causes a great deal
more error repair later in the development than would occur in a static-typed
language. However, in practice type errors are not a serious problem with
Smalltalk programs.
Overall, the design of Smalltalk consistently came down on the side of
language elegance and strict adherence to the principles of object-oriented
programming support, often without regard for practical matters, in particular
execution efficiency. This is most obvious in the exclusive use of objects and
the typeless variables.
The Smalltalk user interface has had an important impact on computing:
The integrated use of windows, mouse-pointing devices, and pop-up and pull-
down menus, all of which first appeared in Smalltalk, dominate contemporary
software systems.
Perhaps the greatest impact of Smalltalk is the advancement of object-oriented
programming, now the most widely used design and coding methodology.

12.5 Support for Object-Oriented Programming in C++


Chapter 2 describes how C++ evolved from C and SIMULA 67, with the design
goal of support for object-oriented programming while retaining nearly com-
plete backward compatibility with C. C++ classes, as they are used to support
abstract data types, are discussed in Chapter 11. C++ support for the other
essentials of object-oriented programming is explored in this section. The
whole collection of details of C++ classes, inheritance, and dynamic binding
is large and complex. This section discusses only the most important among
these topics, specifically, those directly related to the design issues described
in Section 12.3.
C++ was the first widely used object-oriented programming language, and
is still among the most popular. So, naturally, it is the one with which other lan-
guages are often compared. For both of these reasons, our coverage of C++ here is
more detailed than that of the other example languages discussed in this chapter.

12.5.1 General Characteristics


To main backward compatibility with C, C++ retains the type system of C
and adds classes to it. Therefore, C++ has both traditional imperative-language
types and the class structure of an object-oriented language. It supports methods,
as well as functions that are not related to specific classes. This makes it a hybrid
language, supporting both procedural programming and object- oriented
programming.
The objects of C++ can be static, stack dynamic, or heap dynamic. Explicit
deallocation using the delete operator is required for heap-dynamic objects,
because C++ does not include implicit storage reclamation.
Free download pdf