• No results found

The term Smalltalk is often used to refer to three distinct things: a programming language; a library of classes; and a development environment. Although conceptually separate, we shall see that these three things are actually highly interdependent. Every Smalltalk on the

market, including VisualWorks, contains these three parts. There are differences between Smalltalks of course, but in general you will find

that the actual languages are almost identical, the class libraries are somewhat similar, whilst the development environments are the most diverse. So, as the diagram over the page shows,

'Smalltalk' = a Language + a Class Library + a Development Environment

The Smalltalk language itself is very small. Compared to other

languages like C, or even BASIC, there is almost nothing to it. Fundamentally, it allows you to define variables, assign objects to

those variables and send messages to objects. Chapter 4 is devoted to a

complete description of the Smalltalk language. You will see that unlike most other languages, it is relatively easy to know the entire Smalltalk language.

Almost everything in Smalltalk is an object (including numbers, strings, processes, everything), and almost everything (including arithmetic, tests, looping, input and output) is done by sending messages to objects. But the language itself does not define any of these objects or messages. Instead, all these things and many, many others are defined in the standard class library which accompanies the language.

The class library is the core of the Smalltalk system. It provides hundreds of reusable classes that you will use in each and every Smalltalk program you write. It also provides all the basic functionality

you would normally think of as being part of a computer language.

Because numbers are objects defined in the class library, arithmetic operations are done by sending messages to numbers. Because boolean

An Introduction to Smalltalk

The three components of the Smalltalk system,

Development Env Class Library

00 Language

values are also defined in the class library, conditional branches are done by sending messages to booleans. The class library contains objects which implement data structures that support looping (collections), and objects which provide input and output operations.

The Smalltalk class library is implemented using the Smalltalk language. It is built in the same way as you will build your own classes. Unlike the language itself though, the class library is very extensive. You could program in Smalltalk for years and never get to know the whole thing. This is not a problem though, because Smalltalk systems include all the source-code for the class library. This may seem like a dubious benefit. After all, the last thing most C programmers need or want is the source-code for the compiler (and, as we shall see, the editor, the debugger, the window system,...)! The presence of all this source-code makes large amounts of technicality frighteningly visible, but it also allows you to see precisely how the system works. If you can't remember what types of conditional branch are supported, you can look them up. If you need to understand some particular nuance of an operation in the class library, you can see exactly how it is implemented. Sounds frightening? Not so...

The source-code of the class library is made visible through the Smalltalk development environment. This consists of browsers, inspectors, debuggers, user-interface generators and a host of other tools. These tools can give a very clear view of how the system works—if you know how to use them. Much of this book is devoted to helping you in that respect. You use the development environment not only to look at the class library, but also to create, run and debug your own code. It is very rare in Smalltalk that you need to use a tool which

Chapter 3

is not provided as part of the development environment. The development environment is implemented using the classes in the class library. In fact, the code for the development environment is itself a part of the library. Because the source-code of the library is available to the programmer, the source-code of the development environment is also available. This has two consequences. First, it provides a perfect example of how to build an application in Smalltalk. Second, if you don't like the way something in the development environment works, you can in principle change it.

So what have we got? There is a language called Smalltalk. It's very small, and in fact does hardly anything. Written in Smalltalk is a set of classes which provide a standard library of functionality. Built using those classes is a set of tools which provide a powerful development environment for Smalltalk programmers. In a very real way, your task when programming in Smalltalk is to take that system, and extend it to turn it into what you want it to be. Unlike in other languages, there is no 'wall' between you and the system. You have all the same power and flexibility that the developers of the system itself enjoy.