# 10 Objects

It was amazing to me, and it is still amazing, that people could not imagine what the psychological difference would be to have an interactive terminal. You can talk about it on a blackboard until you are blue in the face, and people would say, "Oh, yes, but why do you need that?"$\ldots$ We used to try to think of all these analogies, like describing it in terms of the difference between mailing a letter to your mother and getting on the telephone. To this day I can still remember people only realizing when they saw a real demo, say, "Hey, it talks back. Wow! You just type that and you got an answer."
Fernando Corbato (who worked on Whirlwind in the 1950s)
Charles Babbage Institute interview, 1989

So far, we have seen two main approaches for solving problems: Functional programming: Break a problem into a group of simpler procedures that can be composed to solve the problem (introduced in Chapter 4).
Data-centric programming: Model the data the problem involves, and develop procedures to manipulate that data (introduced in Chapter 5, and extended to imperative programming with mutation in the previous chapter).

All computational problems involve both data and procedures. All procedures act on some form of data; without data they can have no meaningful inputs and outputs. Any data-focused design must involve some procedures to perform computations using that data.

This chapter introduces a new problem-solving approach known as object-oriented programming. By packaging procedures and data together, object-oriented programming overcomes a weakness of both previous approaches: the data and the procedures that manipulate it are separate.

Unlike many programming languages, Scheme does not provide special built-in support for objects.1 We build an object system ourselves, taking advantage of the stateful evaluation rules. By building an object system from simple components, we provide a clearer and deeper understanding of how object systems work. In Chapter 11, we see how Python provides language support for object-oriented programming.

The next section introduces techniques for programming with objects that combine state with procedures that manipulate that state. Section 10.2 describes inheritance, a powerful technique for programming with objects by implementing new objects that add or modify the behaviors of previously implemented objects. Section 10.3 provides some historical background on the development of object-oriented programming.

1. This refers to the standard Scheme language, not the many extended Scheme languages provided by DrRacket. The MzScheme language does provide additional constructs for supporting objects, but we do not cover them in this book.