Smalltalk (programming language)
|Publishing year:||1972 (development from 1969)|
|Designer:||Alan Kay , Dan Ingalls , Adele Goldberg|
|Developer:||Alan Kay , Dan Ingalls , Adele Goldberg , Ted Kaehler, Scott Wallace, Peter Deutsch|
|Current version||ANSI small talk|
|Important implementations :||Pharo , Squeak , GNU Smalltalk, VisualWorks, Dolphin Smalltalk, Smalltalk / X, VA Smalltalk, OOVM|
|Influenced by:||Lisp , simula|
|Affected:||Objective-C , Java , Ruby , Self , PHP 5, Logtalk , Dylan , AppleScript , NewtonScript , Python , Groovy , Scala , Raku , Common Lisp Object System , Falcon , Io , Ioke , Fancy , Strongtalk|
|Operating system :||Windows , Linux , Mac OS X , and many more.|
Smalltalk is a collective term on the one hand for a dynamic , originally untyped object-oriented programming language and on the other hand for a complete development environment that was developed in the 1970s at the Xerox PARC research center by Alan Kay , Dan Ingalls , Adele Goldberg and others. It was generally released under the name Smalltalk-80 and has influenced the development of many later programming languages such as Objective-C , Java and Ruby . Smalltalk was influenced by Lisp with its automatic garbage collection and Simula with its class concept and is one of the first object-oriented programming languages alongside Simula-67 .
In contrast to languages such as C ++ or Java, Smalltalk is a purely object-oriented programming language, i.e. data such as integers, characters and similar, which are sometimes represented as elementary data types in other object-oriented languages , are also implemented in Smalltalk via objects and associated classes. The Smalltalk development environment contained many ideas that were later disseminated with the Macintosh - and Atari TOS / GEM - and then later also the Windows user interface. A graphics screen with movable windows, drop-down menus and fonts of various sizes was used. A mouse with three buttons - red, blue and yellow - served as an additional input device for the first time. The Model-View-Controller ( MVC ) concept played an essential role in the Smalltalk 80 development environment.
Important characteristics of small talk
- Everything in Smalltalk is an object, including strings , integers , Boolean values , classes (definitions), executable code, stack frames, the memory, code blocks etc.
- Objects are activated by sending them messages. This results in the corresponding method (function) of the object being executed.
- The entire source code is usually open and can therefore be changed. Very few methods use real 'primitives' of the virtual machine.
- Dynamic binding - it is only determined at runtime which method is actually called. An early ("static") link, as provided for in static typing , was deliberately left out in the Smalltalk programming language.
- Inheritance: Each class (except for the root class
Object) is derived from exactly one superclass, the behavior of which it inherits and can expand as required (no multiple inheritance).
- Garbage collection (English garbage collection that can not be influenced by the programmer). An object exists as long as it is referenced by other objects .
- Smalltalk programs are compiled into bytecode which is translated by a virtual machine . Originally, the bytecode was interpreted as native machine code; commercial environments now work almost exclusively with dynamic translation.
- The programming environment allows changes in the source code while the program is running and implements these immediately during runtime.
- The source text is entered in a class browser . Modern refactoring browsers are gradually asserting themselves against simple class browsers because they support automated refactoring functions and thus increase productivity again considerably, similar to how Eclipse has established itself in the Java world.
- A typical property compared to non-object-oriented languages is that control structures such as if-then-else , for , while are not built into the language. For example, an IF statement is executed by sending an ifTrue: message to a Boolean object. A block (instruction sequence) is transferred as a parameter.
TrueThis block is only executed in the class .
FalseThis method is also implemented in the class , but it does not execute the block.
There are only three built-in executable functions:
- Sending a message to an object
- Assigning an object to a variable
- Deliver an object as the return value of a method
History and meaning of small talk
During this time the development of the first versions of Smalltalk-71, Smalltalk-72, Smalltalk-74 and Smalltalk-76 up to the standard Smalltalk-80 at the research center Xerox PARC took place.
The programming with the class browser and the use of a virtual machine for execution placed certain minimum requirements on the hardware from the start. This happened at a time when affordable computers did not have graphical user interfaces and the computing power was insufficient for one. Smalltalk was ahead of its time and at first could only be used effectively on workstations. As a result, there were only a few Smalltalk developers - but all the more C programmers. With the advent of graphical user interfaces in the microcomputer arena, object-oriented C ++ emerged, and since most developers were already familiar with C, C ++ spread very quickly, so Smalltalk remained a niche programming language. In contrast to C and C ++, Smalltalk did not attach particular importance to high execution speeds (Alan Kay: "It's still fast enough for our neurons").
In the early and mid-1990s, small talk became popular in many areas where it was important to master complexity (e.g. expert systems ). Various large providers such as IBM began to strongly support Smalltalk and use it in large customer projects. There has been a surge in various implementations of Smalltalk. With the Internet boom and Java that benefited from it, Smalltalk lost its newly emerging popularity at the end of the 1990s.
In Java, some concepts were adopted from Smalltalk (such as the virtual machine and the garbage collector ). However, the syntax was based on C again. Again, non-object-oriented means were used, such as the mixing of object orientation with simple data types and imperative structures, low self-reference and the edit-compile-test-debug cycle with source code as a pure text file, etc. Java offered standardization, advancement paths for C -Programmers and last but not least alliance possibilities against MS-Windows dominance. It was also made available free of charge by Sun Microsystems.
The end of the short Smalltalk boom was underscored by the decline of the ParcPlace company , which, as a spin-off of Xerox PARC with VisualWorks (now at Cincom ), offered the direct successor to the original implementation, which was the most powerful Smalltalk development environment at the time: applications created with VisualWorks ran Bit-compatible (through VM) under Windows , Mac OS Classic , Solaris (and other Unix systems) as early as 1991 and was able to simulate their various user interfaces with "Camelon View" independent of the runtime system from 1994 onwards.
Although Smalltalk is very easy to learn (only a few language constructs) and to debug (it seldom requires time-consuming explicit recompilation and creation and a restart of the program) and the problem with the execution speed - partly through more effective implementations, partly through more powerful hardware - has since been resolved, Smalltalk is still used in a few areas today. One of the reasons for this can be seen in the lack of uniformity in the program libraries of different implementations, none of which has so far developed a “natural dominance” (like that of Sun Microsystems for Java).
After ParcPlace had left the player, IBM had discontinued its Smalltalk involvement in favor of Java and various initially promising Smalltalk implementations had been discontinued (e.g. Dolphin Smalltalk 2007), there were only a few convinced supporters who wanted a major breakthrough believed. Small talk continued to be an insider topic.
In recent years there has been a kind of renaissance of small talk with the establishment of free implementations . In particular, the cross-platform Squeak, developed by the original Smalltalk inventors, and the croquet based on it, are receiving growing support from science, the IT industry and a large free developer community . Squeak was first published in September 1996 as the first free small talk. Dan Ingalls, Ted Kaehler, John Maloney, Scott Wallace and Alan Kay write that what happened here in 1980 was successful.
Alan Kay's concept of an interactive, computer and network-mediated interaction, the Dynabook , is part of the software development for the One Laptop per Child project. EToys , modules based on Squeak, are installed as standard on the student laptops .
With Croquet, with the background of today's knowledge, an answer to the general question of the optimal computer-human interface is sought again. In the 1980s, this was the two-dimensional graphical user interface - first implemented with Smalltalk - that was spread by Apple and Microsoft. Today Alan Kay and others see it as a three-dimensional, platform-independent, networked multi-user environment in which objects can be exchanged fluently between the various participating computers. In the opinion of the members of the Croquet project , which was started in 2001 and published in 2007, Squeak Smalltalk , in particular, has the properties necessary for this , which therefore replaced the Java originally intended for implementation.
In 2008 the Pharo project started, which offers a free, stable small talk platform based on Squeak in order to reach further areas of application with free small talk.
Typical variant of Smalltalk
Smalltalk does not have a static type system. In particular, there are no type definitions and type annotations for variables or for the input / output parameters of methods. Accordingly, there are no type checks for value assignments, as is usual for typed languages, neither dynamically (at runtime) nor statically (at compilation time). Smalltalk's class hierarchy must not be confused with a subtype hierarchy - even if modern object-oriented programming languages often regard type and class definitions as a single process, these are different concepts and also different components of the translator and the runtime system of a language. Smalltalk has no such component when it comes to the formation and testing of types.
However, there are variants of Smalltalk that have a static type system, such as Strongtalk . Strongtalk enables the class-independent definition of types in its own type hierarchy and consequently also the annotation of such types to variables and methods.
Expressions have the following form:
That is, you send a message to an object. The object responds with a response object. Expressions must be separated with a period.
There are three types of messages, unary messages, binary messages, and keyword messages.
Unary messages have no parameters and consist of an identifier:
A binary message has exactly one parameter and consists of one or more special characters. Four examples:
1 + 3 100 @ 200 vorname , nachname 10 // 3
Most of the arithmetic operations in Smalltalk are implemented as binary messages.
A keyword message has one or more parameters, with colons in front of the parameters.
objekt nachricht: parameter
This keyword message is named
nachricht:and has one parameter
objekt nachricht: parameter1 nachricht: parameter2
This keyword message is called
nachricht:nachricht:and has two parameters. I.e. For keyword messages, parameters can be inserted in the middle of the message. This special feature makes it possible to write programs that are particularly easy to read in Smalltalk:
collection copyFrom: 1 to: 10
That sounds like a sentence. In Java it would be written like this:
Expressions can be combined and nested with brackets. Without parentheses, expressions are executed in the following order: unary messages before binary messages before keyword messages. In the case of “equal” messages, the evaluation is carried out from left to right.
If several messages are to be sent to an object in succession, it is possible to concatenate these messages with a semicolon ( ; ):
objekt nachricht1; nachricht2; nachricht3
An assignment has the following form:
variable := ausdruck
In Smalltalk, only the reference to an object is assigned.
Blocks are sequences of assignment statements and expressions. They are enclosed in square brackets. Blocks can be parameterless or have parameters.
blockEins := [ Anweisungen ] blockZwei := [ :einParameter | Transcript show: einParameter ]
Blocks are first class objects. They can be passed as an argument or as the return value of a method call or a block evaluation. Blocks hold a reference to their context so that surrounding variables can be reached when they are executed (according to their static visibility). Blocks thus correspond to closures as they are known from many functional languages (e.g. Scheme). To execute a block, a variant of the value message is sent to it, whereby the number of parameters given must correspond to the number of block arguments:
blockEins value blockZwei value: 'Test'
The control structures are implemented with Boolean expressions and blocks. A Boolean expression returns a Boolean object after evaluation. This is then sent a message that has an executable block as a parameter. The program text looks similar to that of other programming languages, so that you can simply use certain control structures as given.
aBoolean ifTrue: [ "ein Block mit Anweisungen" ]
( einAusdruck ) ifTrue: [ "ein Block mit Anweisungen" ]
The else known from other programming languages looks like this:
aBoolean ifTrue: [ ... ] ifFalse: [ ... ]
10 timesRepeat: [ Transcript show: '.' ]. 1 to: 10 do: [ :i | Transcript show: i printString ]. [ "ein Block, der ein boolesches Objekt zurückgibt" ] whileTrue. [ "ein Block, der ein boolesches Objekt zurückgibt" ] whileFalse. [ "ein Block, der ein boolesches Objekt zurückgibt" ] whileTrue: [ "Block mit Schleifenrumpf" ]. [ "ein Block, der ein boolesches Objekt zurückgibt" ] whileFalse: [ "Block mit Schleifenrumpf" ]
The small talk environments are equipped with a large class library. An important general object type (class) are the collections , i. H. Collections of objects. The Collection class is at the root of a whole hierarchy of classes.
One important piece of work that can be done with a Collection object is to do a block of statements for each element of the Collection. Other programming languages need special constructs ( iterators ) for this.
aCollection do: [ :einElement | einElement auszuführendeArbeitFürDiesesElement ]
It has become common to refer to the parameter as each , so that it is immediately clear what is meant here. When using several collections, you should add an exact description. For example, if you iterate over all x and y values from two different collections:
xWerte do: [:eachX | yWerte do: [:eachY | map addPoint: eachX withY: eachY]]
The HelloWorld example looks like this:
Transcript show: 'Hello World!'.
Transcript is a predefined global variable in every Smalltalk environment, which contains an object on which things can be logged (an output window).
The following message is sent to this object:
An already somewhat more complex example:
'Hello World' do: [ :eachChar| Transcript show: eachChar asString; cr. ].
outputs the text "Hello World" vertically. 'Hello World' is a string. The class of this object is a subclass of Collection. A string is a collection of characters. By sending the message to the String object
aString do: [ :eachChar | OperationenMitDiesemBuchstaben ]
send, let's go through each letter (element) of the string one by one.
The dictionary (in Perl Hash , in Java Map ) is a data structure often used in Smalltalk:
d := Dictionary new. d at: 'grün' put: 'green'. d at: 'blau' put: 'blue'. d at: 'rot' put: 'red'. Transcript show: (d at: 'blau').
Alternatively, the messages can be chained as already described:
d := Dictionary new. d at: 'grün' put: 'green'; at: 'blau' put: 'blue'; at: 'rot' put: 'red'. Transcript show: (d at: 'blau').
The dictionary is also a subclass of Collection . This data structure corresponds to the associative array in other programming languages.
Smalltalk is written with a lowercase t . The wrong spelling SmallTalk is often found , even on the official IBM websites, even if not consistently.
- Cincom Smalltalk - Smalltalk dialect from the Cincom company. The following environments are offered:
- Cuis Smalltalk - free Smalltalk system trimmed for clarity.
- Dolphin Smalltalk - Smalltalk environment for Windows.
- GNU Smalltalk - free small talk by the GNU Project.
- LittleSmalltalk - free implementation based on Timothy A. Budds ideas.
- LSW Vision-Smalltalk - proprietary Smalltalk for Windows.
- Pharo (programming language) - a spin-off from Squeak developed according to software engineering standards.
- StepTalk - GNUstep and Mac OS X scripting framework.
- Squeak - free, platform-independent implementation.
- Syx - another free Smalltalk implementation.
- Smalltalk / X - Smalltalk from eXept Software AG (available free of charge, also for commercial projects).
- Smalltalk MT with Object Connect or Smalltalk MT with Genify - a C ++ - like Smalltalk dialect.
- Strongtalk - free (open source) Smalltalk implementation for Microsoft Windows.
- VisualAge for Smalltalk - Smalltalk environment from IBM (discontinued, successor is VAST ).
- OOVM ( Memento from March 6, 2005 in the Internet Archive ) by Lars Bak et al. Smalltalk implementation for embedded systems that works without an underlying operating system and can be updated during operation.
- Adele Goldberg: Smalltalk-80, The Interactive Programming Environment. Addison-Wesley, 1983, ISBN 0-201-11372-4 .
- Glen Krasner: Smalltalk-80, Bits of History, Words of Advice. Addison-Wesley, August 1, 1983, ISBN 0-201-11669-3 .
- Johannes Brauer: Basic Smalltalk course · Object orientation from the start. An introduction to programming Springer Vieweg, 4th edition 2014, ISBN 978-3-658-00630-3 .
- Sherman R. Alpert, Kyle Brown, Bobby Woolf: The Design Patterns Smalltalk Companion. Addison-Wesley Professional, February 10, 1998, ISBN 0-201-18462-1 .
- Mark J. Guzdial: Squeak: Object-Oriented Design with Multimedia Applications. Prentice Hall, December 20, 2000, ISBN 0-130-28028-3 .
- Mark J. Guzdial, Kimberly M. Rose: Squeak: Open Personal Computing and Multimedia. Prentice Hall, August 2, 2001, ISBN 0-130-28091-7 .
- Günther Vinek: Object-oriented software development with small talk. Springer Verlag, April 24, 1997, ISBN 978-3-540-62558-2 .
- Simon Lewis: The Art and Science of Smalltalk. Prentice Hall, March 1, 1995, ISBN 0-133-71345-8 .
- Chamond Liu: Smalltalk, Objects and Design. iUniverse, 2000, ISBN 1-583-48490-6 .
- Peter P. Bothner, Wolf-Michael Kähler: Smalltalk: Introduction to object-oriented programming. Vieweg + Teubner, 1998, ISBN 3-528-05700-9 .
- STIC is the manufacturer-independent lobby organization
- Alan Kay talked at the O'Reilly Etech 2003 Presentation
- Smalltalk books as PDF documents for download
- See Alan C. Kay: The early history of Smalltalk . In: »ACM SIGPLAN notices« (conference journal), vol. 28, no. 3, March 1993, Association for Computing Machinery, New York, p. 69 ff. - 2004-0924-2355 (1999-0802-2121) ( Memento from February 5, 2012 in the Internet Archive ) (PDF; 3.9 MB) .
- VisualWorks in the English language Wikipedia
- Cincom in the English language Wikipedia
- Back to the Future: The Story of Squeak ( Memento from January 27, 2007 in the Internet Archive )
- Alan Kay: The $ 100 Laptop and Powerful Ideas , Windleys Technometria, Feb. 23, 2006
- 008 JSJ V8 and Dart with Lars Bak and Kasper Lund ( Memento from March 15, 2014 in the Internet Archive ), WOODY2SHOES on March 14, 2012