Single page description of Smalltalk
ssadams at us.ibm.com
ssadams at us.ibm.com
Tue Mar 7 18:17:45 UTC 2000
On the semantics of Smalltalk, I've always liked the "five words" set out
in the original Blue Book ("Smalltalk-80: the Language and its
Implementation", Goldberg and Robson, 1983):
"Smalltalk is based on a small number of concepts, but defined by unusual
terminology. Due to the uniformity with which the object-message
orientation is carried out in the system, there are very few new
programming concepts to learn in order to understand Smalltalk...These
concepts are presented by defining the five words...that make up the
vocabulary of Smalltalk - object, message, class, instance, and method.
These five words are defined in terms of each other, so it is almost as
though the reader must know everything before knowing anything."
I dont' recall the source of these rules, but we used them very early in
our training classes at KSC in the late '80s.
The Four Rules
1) Everything is an object.
2) All objects are instances of some class.
3) Objects get things done by sending messages.
4) Messages are implemented by methods.
I would add #5 for completeness (though not for simplicity):
5) Methods are sequences of message sends and/or variable accesses and
assignments that are evaluated within the scope of the object at runtime.
Some Blue Book definitions for the five words (plus a few others):
"An object consists of some private memory and a set of operations. The
nature of an object's operations depends on the type of component it
"A message is a request for an object to carry out one of its operations.
A message specifies which operation is desired, but not how that operation
should be carried out. The reciever, the object to which the message was
sent, determines how to carry out the requested operation. ...Computing is
viewed as an intrinsic capability of objects that can be unifromly invoked
by sending messages."
"A class describes the implementation of a set of objects that all
represent the same kind of system component. The individual objects
described by a class are called its instances. A class describes the form
of its instances' private memories and it describes how they carry out
their operations. ... Each class has a name that represents the type of
component its instances represent."
"The instances of a class are similar in both their public and private
properties. An object's public properties are the messages that make up
its interface. All instances of a class have the same message interface
since they represent the same kind of component. An object's private
properties are a set of instance variables that make up its private memory
and a set of methods that describe how to carry out its operations. The
instance variables and methods are not directly availabel to other objects.
The instances of a class all use the same set of methods to describe their
operations. ... Each instance has its own set of instance variables, but
they generally have the same number of instance variables."
"Each instance variable in an object's private memory refers to one object,
called its value." [An instance instance variable can refer to any other
object in the Smalltalk system]
"Each method in a class tells how to perfrom the operation requested by a
particular type of message. When that type of message is sent to any
instance of the class, the method is executed. ... A class includes a
method for each type of operation its instances can perform. A method may
specify some changes to the object's private memory and/or other messages
to be sent. A method also specifies an object that should be returned as
the value of the invoking message. An object's methods can access the
object's own instance variables, but not those of other objects."
"A small subset of the methods in the Smalltalk-80 system are not expressed
in the Smalltalk-80 programming language. These are called primitive
methods. ... They are invoked with messages in exactly the same way that
other methods are. Primitive methods allow the underlying hardware and
virtual machine structures to be accessed."
Some Blue Book words about Smalltalk programming and design:
"Programming in the Smalltalk-80 system consists of creating classes,
creating instances of classes, and specifying sequences of message
exchanges among these objects."
"An important part of designing Smalltalk-80 programs is determining which
kinds of objects should be described and which message names provide a
useful vocabulary of interaction among these objects. A language is
designed whenever the programmer specifies the messages that can be sent to
IMHO, a deep understanding and uniform application of these principles form
the basic semantics of Smalltalk. All of the above quotes came from the
preface and chapter one of the Blue Book, which can still be an
enlightening and inspirational read, even after all these years.
Sam S. Adams, IBM Distinguished Engineer, IBM Research
tie line 444-0736, outside 919-254-0736, email: ssadams at us.ibm.com
<<Hebrews 11:6, Proverbs 3:5-6, Romans 1:16-17, I Corinthians 1:10>>
More information about the Squeak-dev