DOC PREVIEW
UT Arlington CSE 3302 - The Power of Simplicity

This preview shows page 1-2-19-20 out of 20 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

To be published in: LISP AND SYMBOLIC COMPUTATION: An International Journal, 4, 3, 1991© 1991 Kluwer Academic Publishers - Manufactured in The NetherlandsSELF: The Power of Simplicity*DAVID UNGAR†([email protected])Computer Systems Laboratory, Stanford University, Stanford, California 94305RANDALL B. SMITH†([email protected])Xerox Palo Alto Research Center, Palo Alto, California 94304Abstract. SELF is an object-oriented language for exploratory programming based on a smallnumber of simple and concrete ideas: prototypes, slots, and behavior. Prototypes combine inheritanceand instantiation to provide a framework that is simpler and more flexible than most object-orientedlanguages. Slots unite variables and procedures into a single construct. This permits the inheritancehierarchy to take over the function of lexical scoping in conventional languages. Finally, becauseSELF does not distinguish state from behavior, it narrows the gaps between ordinary objects,procedures, and closures. SELF’s simplicity and expressiveness offer new insights into object-oriented computation.To thine own self be true.—William Shakespeare1 IntroductionObject-oriented programming languages are gaining acceptance, partly becausethey offer a useful perspective for designing computer programs. However, they donot all offer exactly the same perspective; there are many different ideas about thenature of object-oriented computation. In this paper, we present SELF, a program-ming language with a new perspective on objects and message passing. Like theSmalltalk-801 language [6], SELF is designed to support exploratory programming*This work is partially supported by Xerox, and partially by National Science FoundationPresidential Young Investigator Grant #CCR-8657631, Sun Microsystems, the Powell Foundation,IBM, Apple Computer, DEC, NCR, Texas Instruments, and Cray Laboratories.†Authors’ present address: Sun Microsystems, 2500 Garcia Avenue, Mountain View, CA 94043.This paper is a substantial revision of [20], originally published in OOPSLA ’87 Conference Proceedings(SIGPLAN Notices, 22, 12 (1987) 227-241).2 UNGAR AND SMITH[13], and therefore includes runtime typing (i.e. no type declarations) and auto-matic storage reclamation.But unlike Smalltalk, SELF includes neither classes nor variables. Instead, SELFhas adopted a prototype metaphor for object creation [2, 3, 4, 8, 10]. Furthermore,while Smalltalk and most other object-oriented languages support variable accessas well as message passing, SELF objects access their state information by sendingmessages to “self,” the receiver of the current message. Naturally this results inmany messages sent to “self,” and the language is named in honor of thesemessages.One of the strengths of object-oriented programming lies in the uniform accessto different kinds of stored and computed data, and the ideas in SELF result in evenmore uniformity, which results in greater expressive power. We believe that theseideas offer a new and useful view of object-oriented computation.Several principles have guided the design of SELF:Messages-at-the-bottom. SELF features message passing as the fundamentaloperation, providing access to stored state solely via messages. There are no vari-ables, merely slots containing objects that return themselves. Since SELF objectsaccess state solely by sending messages, message passing is more fundamental toSELF than to languages with variables.Occam’s razor. Throughout the design, we have aimed for conceptual economy:• As described above, SELF’s design omits classes and variables. Any object canperform the role of an instance or serve as a repository for shared information.• There is no distinction between accessing a variable and sending a message.• As in Smalltalk, the language kernel has no control structures. Instead, closuresand polymorphism support arbitrary control structures within the language.• Unlike Smalltalk, SELF objects and procedures are woven from the same yarnby representing procedures as prototypes of activation records. This techniqueallows activation records to be created in the same way as other objects, bycloning prototypes. In addition to sharing the same model of creation,procedures also store their variables and maintain their environmentinformation the same way as ordinary objects, as described in Section 4.Concreteness. Our tastes have led us to a metaphor whose elements are asconcrete as possible [14, 15]. So, in the matter of classes versus prototypes, wehave chosen to try prototypes. This makes a basic difference in the way that newobjects are created. In a class-based language, an object would be created by instan-tiating a plan in its class. In a prototype-based language like SELF, an object wouldbe created by cloning (copying) a prototype. In SELF, any object can be cloned.1Smalltalk-80 is a trademark of ParcPlace Systems. In this paper, the term “Smalltalk” will be usedto refer to the Smalltalk-80 programming language.SELF: THE POWER OF SIMPLICITY 3The remainder of the paper describes SELF in more detail, and concludes withtwo examples. We use Smalltalk as our yardstick, as it is the most widely knownlanguage in which everything is an object. Familiarity with Smalltalk will thereforebe helpful to the reader.2 Prototypes: Blending Classes and InstancesIn Smalltalk, unlike C++, Simula, Loops, or Ada, everything is an object andevery object contains a pointer to its class, an object that describes its format andholds its behavior (see Figure 1.) In SELF too, everything is an object. But, insteadof a class pointer, a SELF object contains named slots which may store either stateor behavior. If an object receives a message and it has no matching slot, the searchcontinues via a parent pointer. This is how SELF implements inheritance. Inherit-ance in SELF allows objects to share behavior, which in turn allows theprogrammer to alter the behavior of many objects with a single change. Forinstance, a point2 object would have slots for its non-shared characteristics: x andy (see Figure 1). Its parent would be an object that held the behavior shared amongall points: +, –, etc.2.1 Comparing Prototypes and ClassesOne of SELF’s most interesting aspects is the way it combines inheritance, proto-types, and object creation, eliminating the need for


View Full Document

UT Arlington CSE 3302 - The Power of Simplicity

Documents in this Course
Smalltalk

Smalltalk

11 pages

Syntax

Syntax

5 pages

Syntax

Syntax

5 pages

JAVA

JAVA

57 pages

Semantics

Semantics

41 pages

Control

Control

74 pages

Load more
Download The Power of Simplicity
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view The Power of Simplicity and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The Power of Simplicity 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?