The Birth of a Pioneer

In the 1970s, at the legendary Xerox PARC, a team of visionary developers led by Alan Kay, Dan Ingalls, and Adele Goldberg created a programming language that would change the face of software development forever. This language, known as Smalltalk, was initially designed to teach programming to children, but it quickly evolved into a powerful tool that would influence the entire field of object-oriented programming (OOP).

The Philosophy of Smalltalk

Smalltalk is built on a simple yet profound philosophy: everything is an object. Yes, you read that right – everything. From integers to classes, every entity in Smalltalk is an object, and the only way to interact with these objects is by sending them messages. This concept is so fundamental that it’s often summarized as “all values are objects.”

Objects and Classes

In Smalltalk, an object is an instance of a class. Classes serve as blueprints that define the properties and behaviors of their instances. For example, a Window class might have properties like label, position, and visibility, and methods like open, close, move, and hide. Each window object would have its own set of these properties and could perform the methods defined by its class.

classDiagram class Window { - label: String - position: Point - visibility: Boolean + open() + close() + move(Point) + hide() } class WindowInstance { - label: "My Window" - position: (100, 100) - visibility: true } Window --* WindowInstance : "instance of"

Message Passing

Message passing is the heart of Smalltalk. There are three types of messages: unary, binary, and keyword messages.

Unary Messages

Unary messages are the simplest form of message passing. They consist of a message name and are sent to an object without any additional parameters.

Date tomorrow.
1 asString.
"hi" show.

In these examples, Date, 1, and "hi" are the objects, and tomorrow, asString, and show are the message names.

Binary Messages

Binary messages are used for arithmetic, comparison, and logical operations. They involve a special character (like +, -, *, etc.) and are sent to an object with one parameter.

a + b.
a >= b.

Here, a is the object, and + or >= are the message names with b as the parameter.

Keyword Messages

Keyword messages are more complex and involve multiple named arguments. They are used when you need to pass more than one parameter to a method.

display drawFromX: 1 fromY: 1 toX: 50 toY: 100.
lassie eat: "lasagne" drink: "milk".

In these examples, display and lassie are the objects, and the messages are drawFromX:fromY:toX:toY: and eat:drink:, respectively.

Blocks and Control Structures

In Smalltalk, functions are known as blocks. These are executable routines that can be passed around like any other object. Blocks are used extensively in control structures such as conditionals and loops.

4 < 5 ifTrue: [ Transcript print: '4 is less than 5!' ].

Here, the block [ Transcript print: '4 is less than 5!' ] is executed if the condition 4 < 5 evaluates to true.

Integrated Development Environment (IDE)

One of the unique aspects of Smalltalk is its integrated development environment. Unlike many other languages, where the IDE and the program are separate entities, in Smalltalk, the IDE and the program are part of the same environment. This means that the entire system, including the IDE, can be extended and modified using Smalltalk itself.

sequenceDiagram participant Developer participant IDE participant Program Developer->>IDE: Write and execute Smalltalk code IDE->>Program: Run and interact with the program Program->>IDE: Reflect changes and updates in real-time Developer->>IDE: Extend and modify the IDE using Smalltalk

Syntax and Simplicity

Smalltalk’s syntax is remarkably simple. The entire language specification can fit on a postcard, which is a testament to its elegance. Here’s a simple example of a Smalltalk program that prints “Hello World” to the Transcript:

Greeter new sayIt

To run this program, you would open the Playground in the Smalltalk environment, enter the code, select it, right-click, and choose “Do it.”

Conclusion

Smalltalk is more than just a programming language; it’s a philosophy of how software should be developed. Its influence can be seen in many modern OOP languages like Objective-C, Java, Python, and Ruby. Despite its age, Smalltalk remains a powerful tool for developers who appreciate its simplicity, flexibility, and the unique way it blurs the lines between the program and the environment.

So, if you’re looking for a programming language that will challenge your conventional thinking and offer a fresh perspective on software development, Smalltalk is definitely worth exploring. As Alan Kay once said, “The best way to predict the future is to invent it.” With Smalltalk, you’re not just coding; you’re inventing.