Design Principles Behind Smalltalk Daniel H. H. Ingalls Learning Research Group Xerox Palo Alto Research Center 3333 Coyote Hill Rd Palo Alto, CA 94304

BYTE Magazine, August 1981. Reproduced with permission. (c) by The McGraw-Hill Companies, Inc., New York, NY. All rights reserved.

Build an application program within the current system (make an observation)

Based on that experience, redesign the language (formulate a theory)

Build a new system based on the new design (make a prediction that can be tested)

Personal Mastery: If a system is to serve the creative spirit, it must be entirely comprehensible to a single individual.

Good Design: A system should be built with a minimum set of unchangeable parts; those parts should be as general as possible; and all parts of the system should be held in a uniform framework.

Language

Purpose of Language: To provide a framework for communication.

Scope: The design of a language for using computers must deal with internal models, external media, and the interaction between these in both the human and the computer.

Figure 1: The scope of language design. Communication between two people (or between one person and a computer) includes communication on two levels. Explicit communication includes the information that is transmitted in a given message. Implicit communication includes the relevant assumptions common to the two beings.

Communicating Objects

The mind observes a vast universe of experience, both immediate and recorded. One can derive a sense of oneness with the universe simply by letting this experience be, just as it is. However, if one wishes to participate, literally to take a part, in the universe, one must draw distinctions. In so doing one identifies an object in the universe, and simultaneously all the rest becomes not-that-object. Distinction by itself is a start, but the process of distinguishing does not get any easier. Every time you want to talk about "that chair over there", you must repeat the entire processes of distinguishing that chair. This is where the act of reference comes in: we can associate a unique identifier with an object, and, from that time on, only the mention of that identifier is necessary to refer to the original object.

We have said that a computer system should provide models that are compatible with those in the mind. Therefore:

Objects: A computer language should support the concept of "object" and provide a uniform means for referring to the objects in its universe.

Storage Management: To be truly "object-oriented", a computer system must provide automatic storage management.

Messages: Computing should be viewed as an intrinsic capability of objects that can be uniformly invoked by sending messages.

Uniform Metaphor: A language should be designed around a powerful metaphor that can be uniformly applied in all areas.

Organization

A uniform metaphor provides a framework in which complex systems can be built. Several related organizational principles contribute to the successful management of complexity. To begin with:

Modularity: No component in a complex system should depend on the internal details of any other component.

Figure 2: System complexity. As the number of components in a system increases, the chances for unwanted interaction increase rapidly. Because of this, a computer language should be designed to minimize the possibilities of such interdependence.

This principle is depicted in figure 2. If there are N components in a system, then there are roughly N-squared potential dependencies between them. If computer systems are ever to be of assistance in complex human tasks, they must be designed to minimize such interdependence. The message-sending metaphor provides modularity by decoupling the intent of a message (embodied in its name) from the method used by the recipient to carry out the intent. Structural information is similarly protected because all access to the internal state of an object is through this same message interface.

The complexity of a system can often be reduced by grouping similar components. Such grouping is achieved through data typing in conventional programming languages, and through classes in Smalltalk. A class describes other objects -- their internal state, the message protocol they recognize, and the internal methods for responding to those messages. The objects so described are called instances of that class. Even classes themselves fit into this framework; they are just instances of class Class , which describes the appropriate protocol and implementation for object description.

Classification: A language must provide a means for classifying similar objects, and for adding new classes of objects on equal footing with the kernel classes of the system.

Note

Melody

Score

Timbre

Player

Integers

Notes

Integers

Notes

Polymorphism: A program should specify only the behavior of objects, not their representation.

SmallInteger

LargeInteger

Factoring: Each independent component in a system would appear in only one place.

Object

StreetSweeper

Vehicle

Leverage: When a system is well factored, great leverage is available to users and implementers alike.

sort

OrderedCollection

Virtual Machine: A virtual machine specification establishes a framework for the application of technology.

User Interface

A user interface is simply a language in which most of the communication is visual. Because visual presentation overlaps heavily with established human culture, esthetics plays a very important role in this area. Since all capability of a computer system is ultimately delivered through the user interface, flexibility is also essential here. An enabling condition for adequate flexibility of a user interface can be stated as an object-oriented principle:

Reactive Principle: Every component accessible to the user should be able to present itself in a meaningful way for observation and manipulation.

Operating System: An operating system is a collection of things that don't fit into a language. There shouldn't be one.

Storage management -- Entirely automatic. Objects are created by a message to their class and reclaimed when no further references to them exist. Expansion of the address space through virtual memory is similarly transparent.

File system -- Included in the normal framework through objects such as Files and Directories with message protocols that support file access.

and with message protocols that support file access. Display handling -- The display is simply an instance of class Form , which is continually visible, and the graphical manipulation messages defined in that class are used to change the visible image.

, which is continually visible, and the graphical manipulation messages defined in that class are used to change the visible image. Keyboard Input -- The user input devices are similarly modeled as objects with appropriate messages for determining their state or reading their history as a sequence of events.

Access to subsystems -- Subsystems are naturally incorporated as independent objects within Smalltalk: there they can draw on the large existing universe of description, and those that involve interaction with the user can participate as components in the user interface.

Debugger -- The state of the Smalltalk processor is accessible as an instance of class Process that owns a chain of stack frames. The debugger is just a Smalltalk subsystem that has access to manipulate the state of a suspended process. It should be noted that nearly the only run-time error that can occur in Smalltalk is for a message not to be recognized by its receiver.

Future Work

As might be expected, work remains to be done on Smalltalk. The easiest part to describe is the continued application of the principles in this paper. For example, the Smalltalk-80 system falls short in its factoring because it supports only hierarchical inheritance. Future Smalltalk systems will generalize this model to arbitrary (multiple) inheritance. Also, message protocols have not been formalized. The organization provides for protocols, but it is currently only a matter of style for protocols to be consistent from one class to another. This can be remedied easily by providing proper protocol objects that can be consistently shared. This will then allow formal typing of variables by protocol without losing the advantages of polymorphism.

The other remaining work is less easy to articulate. There are clearly other aspects to human thought that have not been addressed in this paper. These must be identified as metaphors that can complement the existing models of the language.

Sometimes the advance of computer systems seems depressingly slow. We forget that steam engines were high-tech to our grandparents. I am optimistic about the situation. Computer systems are, in fact, getting simpler and, as a result, more usable. I would like to close with a general principle which governs this process:

Natural Selection: Languages and systems that are of sound design will persist, to be supplanted only by better ones.