Smalltalk
Smalltalk is a purely object-oriented programming language originally created in the 1970s for educational use, specifically for constructionist learning, but later found use in business.
The language emerged from research at Xerox PARC's Learning Research Group, with key contributors including Alan Kay, Dan Ingalls, and Adele Goldberg. Development began around 1969, with public release occurring in 1972.
Historical Development
Smalltalk evolved through several versions:
- Smalltalk-71: An unpublished language design by Kay (circa 1971)
- Smalltalk-72: Created in September 1972 when Kay demonstrated a working interpreter scheme in "a page of code"
- Smalltalk-76: Featured a development environment with familiar tools including a class library browser
- Smalltalk-80: The first publicly available version (1980), introducing metaclasses to maintain the "everything is an object" paradigm
The first interpreter was implemented by Dan Ingalls in approximately 700 lines of BASIC in October 1972 for the Data General Nova computer. Smalltalk-72 was subsequently ported to the Xerox Alto in April 1973.
Core Concepts
Object-Oriented Foundation
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 language treats all values as objects. "Everything is an object" more accurately means "all values are objects," since variables themselves are not objects.
Messaging System
Alan Kay emphasized that "The big idea is 'messaging'—that is what the kernel of Smalltalk/Squeak is all about."
Message sending represents the fundamental operation in Smalltalk. The language uses three message types:
- Unary messages: Single keyword (e.g.,
class,size) - Binary messages: Arithmetic operations (e.g.,
a < b) - Keyword messages: Multiple arguments with keywords (e.g.,
a between: b and: c)
Reflection
Smalltalk-80 provides both structural and computational reflection. The system allows developers to "walk through, examine, and modify code in the running system" at runtime. The compiler itself is written in Smalltalk and can be extended during program execution.
Smalltalk-80 is a totally reflective system — the classes and methods that define the system are also objects and fully part of the system that they help define.
Syntax
The language features minimal syntax. There are only five reserved pseudo-variables: true, false, nil, self, and super.
Basic Examples
Hello World:
Transcript show: 'Hello, world!'.
Variable Declaration:
| index vowels |
Assignment:
vowels := 'aeiou'
Message Sending:
42 factorial
Blocks (Anonymous Functions):
[:x | x + 1]
Control Structures
Control structures are implemented as message sends rather than language keywords:
result := a > b
ifTrue:[ 'greater' ]
ifFalse:[ 'less or equal' ]
Development Environment
Smalltalk pioneered the Integrated Development Environment (IDE) concept. Key tools include:
- Browser: The primary code viewing and writing tool, organizing classes within system categories
- Workspace: A text editor where expressions can be evaluated interactively
- Transcript: An output window for logging and text display
- Inspector: Tool for examining and modifying object state
- Debugger/Notifier: Opens in response to unhandled exceptions, supporting live programming where methods can be defined and modified during execution
Image-Based Persistence
Smalltalk systems store entire program state—both code and data—in an "image" file. This approach allows restoration of the system to a previous state without losing development information like undo history or cursor position.
Influence
Smalltalk is one of the most influential programming languages. Subsequent object-oriented languages including Flavors, CLOS, Objective-C, Java, Python, and Ruby were influenced by Smalltalk's design.
The language environments were often the first to develop what are now common object-oriented software design patterns, particularly the Model-View-Controller (MVC) pattern for user interface design.
Standards and Current Status
ANSI Smalltalk was ratified in 1998 as the standard language reference. Modern implementations include:
- Squeak: Open source, derived from Smalltalk-80 v1
- Pharo: Cross-platform, derived from Squeak
- VisualWorks: Derived from Smalltalk-80 v2
- GNU Smalltalk: Free software implementation
- Amber Smalltalk: Transpiles to JavaScript
In 2017, Smalltalk took second place for "most loved programming language" in the Stack Overflow Developer Survey.
Key Characteristics
Live Coding: Smalltalk code can be modified while the system is running. Live coding and applying fixes "on-the-fly" is a dominant programming methodology for Smalltalk.
Pure Object-Orientation: There are no primitive types; even integers and booleans are objects responding to messages.
Dynamic Typing: Variables do not require type declarations, enabling flexible and concise code.
Accessibility: Everything in Smalltalk-80, unless customised to avoid the possibility, is available for modification from within a running program.
Source: https://www.wikiwand.com/en/Smalltalk (via https://en.wikipedia.org/wiki/Smalltalk)