Smalltalk Shopping
Smalltalk
Website Links For
Smalltalk
 

Information About

Smalltalk




  paradigm Object-oriented
  year Development started in 1969 <br>Publicly available in 1980
  designer Alan Kay , Dan Ingalls , Adele Goldberg
  developer Alan Kay, Dan Ingalls, Adele Goldberg, Ted Kaehler, Scott Wallace, and Xerox PARC
  latest Release Version Smalltalk-80 version 2
  latest Release Date 1980
  typing Dynamic
  implementations Squeak , VisualWorks
  influenced By Lisp , Logo Sketchpad , Simula
  influenced Objective-C , Self , Java , Dylan , AppleScript , NewtonScript , Python , Ruby , Scala


Smalltalk is an Object-oriented , Dynamically Typed , Reflective Programming Language .

A Smalltalk program is a description of a dynamic computational process. The Smalltalk
programming language is a notation for defining such programs. ''From ANSI Smalltalk standard, section 3.''


Smalltalk was created as the language to underpin the "new world" of computing exemplified by "human-computer symbiosis" {Link without Title} .

… one would compute with a handheld "Dynabook" in a way that would not be possible on a shared mainframe; millions of potential users meant that the user interface would have to become a learning environment along the lines of Montessori and Bruner; and needs for large scope, reduction in complexity, and end-user literacy would require that data and control structures be done away with in favor of a more biological scheme of protected universal cells interacting only through messages that could mimic any desired behavior.

Early Smalltalk was the first complete realization of these new points of view as parented by its many predecessors in hardware, language and user interface design. It became the exemplar of the new computing, in part, because we were actually trying for a qualitative shift in belief structures—a new Kuhnian paradigm in the same spirit as the invention of the printing press—and thus took highly extreme positions which almost forced these new styles to be invented. {Link without Title}


Smalltalk was designed and created in part for Education al use, more so for Constructivist Teaching , at Xerox PARC by Alan Kay , Dan Ingalls , Adele Goldberg , Ted Kaehler , Scott Wallace , and others during the 1970s , influenced by Lisp and Logo , Sketchpad and Simula .

The language was first generally released as Smalltalk-80 and has been widely used since. Smalltalk-like languages are in continuing active development, and have gathered loyal communities of users around them. ANSI Smalltalk was ratified in 1998 and represents the standard version of Smalltalk.


HISTORY

There are a large number of Smalltalk versions and variants, as there are with all computer languages. The unqualified word Smalltalk is often used to indicate the original Smalltalk-80 language.

Smalltalk was the product of research by a group of researchers led by (PARC); Alan Kay designed most of the early Smalltalk versions, which Dan Ingalls implemented. The first version, known as Smalltalk-71, was created in a few mornings on a bet that a programming language based on the idea of Message Passing inspired by Simula could be implemented in "a page of code." A later variant actually used for research work is now known as Smalltalk-72 and influenced the development of the Actor Model . Its Syntax And Execution Model were very different from modern Smalltalk variants.

After significant revisions which froze some aspects of execution semantics to gain performance (by adopting a Simula -like class inheritance model of execution), Smalltalk-76 was created. This system had a Development Environment featuring most of the tools now familiar including a class library code browser/editor.

Smalltalk-80 added Metaclass es, to help maintain the "everything is an object" (except variables) paradigm by associating properties and behavior with individual classes, and even primitives such as integer and boolean values (for example, to support different ways of creating instances).

Smalltalk-80 was the first language made available outside of PARC, first as Smalltalk-80 Version 1, given to a small number of companies ( Hewlett-Packard , Apple Computer , Tektronix , and DEC ) and universities ( UC Berkeley ) for "peer review" and implementation on their platforms. Later (in 1983) a general availability implementation, known as Smalltalk-80 Version 2, was released as an image (platform-independent file with object definitions) and a Virtual Machine specification.

Two of the currently popular Smalltalk languages are descendants of those original Smalltalk-80 images. later ported Hobbes to Squeak).

During the mid-1990s, Smalltalk environments — including support, training and add-ons — were sold by two competing organizations: ParcPlace Systems and Digitalk, both California based. ParcPlace Systems tended to focus on the Unix/Sun Microsystems market, while Digitalk emphasized Intel-based PCs that were running either Microsoft Windows or IBM's OS/2. Both companies, however, struggled with commercial success due to Smalltalk's substantial memory footprint, limited run-time performance, visibility of source code in distributed applications, and lack of supported connectivity to SQL -based relational database servers.

In 1995, as Smalltalk was declining commercially, the two organizations merged and were rebranded ObjectShare, located in Irvine, CA. ObjectShare (. In 1999, Seagull Software acquired the Java development lab of ObjectShare (original Smalltalk/V development team), and still owns Smalltalk/V.

ANSI Smalltalk is the standard language reference since 1998.

IBM has indicated that VisualAge Smalltalk will be supported by partner company (and VisualAge implementors) Instantiations. Cincom, Object Arts, GemStone, and other vendors continue to sell Smalltalk environments. The open Squeak implementation has a relatively active community of developers, including many of the original Smalltalk community. GNU Smalltalk is a Free Software implementation of a derivative of Smalltalk-80 from the GNU project. There is even a Smalltalk-80 like Cross-compiler {Link without Title} for the PalmPilot which runs on Windows (though it seems that development may have stagnated in recent years).

There is also a high-performance ) which supports an extended Smalltalk-like language written by David Simmons of Smallscript Corp.

More recently, Python and Ruby have reimplemented some Smalltalk ideas with more C / Java -like syntax. (From its origins as a teaching language, standard Smalltalk syntax uses punctuation in a manner more like English than mainstream coding languages.)


OBJECT-ORIENTED PROGRAMMING

See Also: Object-oriented programming



As in other object-oriented languages, the central concept in Smalltalk-80 (but not in Smalltalk-72) is that of an ''object''. An object is always an ''instance'' of a ''class''. Classes are "blueprints" that describe the properties and behavior of their instances. For example, a Window class would declare that windows have properties such as the label, the position and whether the window is visible or not. The class would also declare that instances support operations such as opening, closing, moving and hiding. Each particular Window object would have its own values of those properties, and each of them would be able to perform operations defined by its class.

A Smalltalk object can do exactly three things:
# Hold state (references to other objects).
# Receive a message from itself or another object.
# In the course of processing a message, send messages to itself or another object.

The state an object holds is always private to that object. Other objects can query or change that state only by sending requests (messages) to the object to do so. Any message can be sent to any object: when a message is received, the receiver determines whether that message is appropriate. (Alan Kay has commented that despite the attention given to objects, messaging is the most important concept in Smalltalk.)

Smalltalk is a 'pure' OO language, meaning that, unlike Java and C++ , there is no difference between values which are objects and values which are primitive types. In Smalltalk, primitive values such as integers, booleans and characters are also objects, in the sense that they are instances of corresponding classes, and operations on them are invoked by sending messages. A programmer can change the classes that implement primitive values, so that new behavior can be defined for their instances--for example, to implement new control structures--or even so that their existing behavior will be changed. This fact is summarised in the commonly heard phrase "In Smalltalk everything is an object" (which would more accurately be expressed as "all values are objects", as variables aren't).

Since all values are objects, Classes themselves are also objects. Each class is an instance of the '' Metaclass '' of that class. Metaclasses in turn are also objects, and are all instances of a class called Metaclass. Code Block s are also objects.


REFLECTION

Smalltalk-80 is a fully Reflective system, implemented in Smalltalk-80 itself. Smalltalk-80 provides both structural and computational reflection. Smalltalk is a structurally reflective system whose structure is defined by Smalltalk-80 objects. The classes and methods that define the system are themselves objects and fully part of the system that they help define. The Smalltalk compiler compiles textual source code into method objects, typically instances of CompiledMethod. These get added to classes by storing them in a class's method dictionary. The part of the class hierarchy that defines classes can add new classes to the system. The system is extended by running Smalltalk-80 code that creates or redefines classes and methods. In this way a Smalltalk-80 system is a "living" system, carrying around the ability to extend itself at run-time.

Since the classes are themselves objects, they can be asked questions such as "what methods do you implement?" or "what fields/slots/instance variables do you define?". So objects can easily be inspected, copied, (de) Serialized and so on with generic code that applies to any object in the system.

Smalltalk-80 also provides computational reflection, the ability to observe the computational state of the system. In languages derived from the original Smalltalk-80 the current activation of a method is accessible as an object named via a keyword, thisContext. By sending messages to thisContext a method activation can ask questions like "who sent this message to me". These facilities make it possible to implement Co-routines or Prolog -like back-tracking without modifying the virtual machine. One of the more interesting uses of this is in Avi Bryant's Seaside web framework which relieves the programmer of dealing with the complexity of a Web Browser's back button by storing continuations for each edited page and switching between them as the user navigates a web site. Programming the web server using Seaside can then be done using a more conventional programming style.

When an object is sent a message that it does not implement, the virtual machine sends the object the doesNotUnderstand: message with a Reification of the message as an argument. The message (another object, an instance of Message) contains the selector of the message and an Array of its arguments. In an interactive Smalltalk system the default implementation of doesNotUnderstand: is one that opens an error window reporting the error to the user. Through this and the reflective facilities the user can examine the context in which the error occurred, redefine the offending code, and continue, all within the system, using Smalltalk-80's reflective facilities.

Yet another important use of doesNotUnderstand: is intercession. One can create a class that does not define any methods other than doesNotUnderstand: and does not inherit from any other class. The instances of this class effectively understand no messages. So every time a message is sent to these instances they actually get sent doesNotUnderstand:, hence they intercede in the message sending process. Such objects are called proxies. By implementing doesNotUnderstand: appropriately, one can create distributed systems where proxies forward messages across a network to other Smalltalk systems (a facility common in systems like CORBA and RMI but first pioneered in Smalltalk-80 in the 1980s), persistent systems where changes in state are written to a Database and the like.


SYNTAX

Smalltalk-80 syntax is rather minimalist, based on only a handful of declarations and reserved words. In fact, only six keywords are reserved in Smalltalk: true, '''false''', '''nil''', '''self''', '''super''' and '''thisContext'''. (These are not actually keywords, but ''pseudo-variables''. These pseudo-variables are Singleton instances. Smalltalk does not really define any keywords.) The only built-in language constructs are message sends, assignment, method return and literal syntax for some objects. The remainder of the language, including control structures for conditional evaluation and iteration, is implemented on top of those by the standard Smalltalk class library. (For performance reasons implementations may recognize and treat as special some of those messages; however, this is only an optimization, not hardwired into the language syntax).


Literals


The following examples illustrate the most common objects which can be written as literal values in Smalltalk-80 methods.

Numbers. The following list illustrates some of the possibilities


42
-42
123.45
1.2345e2
2r10010010
16rA000


The last two entries are a binary and a hexadecimal number, respectively. The number before the 'r' is the Radix or base. The base does not have to be a power of two; for example 36rSMALLTALK is a valid number (for the curious, equal to 80738163270632 decimal).

Characters are written by preceding them with a dollar sign:



Strings are sequences of characters enclosed in single quotes:

'Hello, world!'

To include a quote in a string, escape it using a second quote:

'I said, ''Hello, world!'' to them.'

Double quotes do not need escaping, since single quotes delimit a string:

'I said, "Hello, world!" to them.'

Two equal strings (strings are equal if they contain all the same characters) can be different objects residing in different places in memory. In addition to strings, Smalltalk has a class of character sequence objects called Symbol. Symbols are guaranteed to be unique--there can be no two equal symbols which are different objects. Because of that, symbols are very cheap to compare and are often used for language artifacts such as message selectors (see below).

Symbols are written as # followed by characters. For example:

#foo

Arrays:

#(1 2 3 4)

defines an array of four integers.

And last but not least, blocks (anonymous function literals)

Some smalltalk code...

Blocks are explained in detail further in the text.

Many Smalltalk dialects implement additional syntaxes for other objects, but the ones above are the bread and butter supported by all.


Variable declarations


The two kinds of variable commonly used in Smalltalk are instance variables and temporary variables. Other variables and related terminology depend on the particular implementation. For example, VisualWorks has class shared variables and namespace shared variables, while Squeak and many other implementations have class variables, pool variables and global variables.

Temporary variable declarations in Smalltalk are variables declared inside a method (see below). They are declared at the top of the method as names separated by spaces and enclosed by vertical bars. For example:

  <source Lang "smalltalk"> index vowels </source>
  <source Lang "smalltalk"> :params <message-expressions> </source>
  <source Lang "smalltalk"> x + 1 </source>
  <source Lang "smalltalk"> x + 1 value: 3</source>
  <source Lang "smalltalk">positiveAmounts := allAmounts select: amt isPositive </source>
  Vowels : aString select: aCharacter isVowel
  A String Object Responds To The "select:" Message By Iterating Through Its Members (by Sending Itself The Message "do:"), Evaluating The Selection Block ("aBlock") Once With Each Character It Contains As The Argument When Evaluated (by Being Sent The Message "value: Each"), The Selection Block (referenced By The Parameter "aBlock", And Defined By The Block Literal " ":aCharacter" class="copylinks" target="_blank"> aCharacter isVowel "), answers a boolean, which is then sent "ifTrue:" If the boolean is the object true, the character is added to a string to be returned
  Collisions : rectangles select: aRect containsPoint: aPoint