What is Smalltalk?

Where is the Editor? Where is the Compiler? How can I compile and run a program?

Forget for a while about Smalltalk as a programming language. Avoid, for a while, comparing it with other programming languages and their tools. We are going to talk about something pretty different.

What is Smalltalk? Smalltalk is a different kind of computer. One that is not based on the concept of program.

But wait a minute, doesn’t Smalltalk run on regular computers? Yes, it does. But Smalltalk lets you forget about a CPU that loads programs from disk to RAM, in order to execute them and such.

With Smalltalk, your computer becomes a virtual place filled with things. You can interact with these objects, and ask them to perform actions. You can inspect them, and study their behavior and relationships. Of course, you can also modify their behavior and relationships.

Everything in Smalltalk is an Object. For example, the Numbers  and Characters. But also the Editor and the Compiler are Objects. The windows and menus, with their scrollbars and buttons and stuff are Objects too. Pieces of code are also Objects. In Smalltalk, even True and False are objects.

Most computers run Operating Systems. But the entities of regular Operating Systems are not uniformly available for inspection, study and modification. This would break the basic ideas of Smalltalk! Therefore, while in Smalltalk, Smalltalk becomes the Operating System. You can interact with and modify such things as Files and Directories the same way you manipulate any other object.

As the whole Smalltalk system is made with Objects, and all Objects can be studied and modified, the Smalltalk system hides no secrets from the user. Any aspect of the system can be modified to suit the user needs.

To continue, you need a Smalltalk system. Let’s use Squeak. You can go to http://www.squeak.org/Download and get Squeak for your platform. The set of all the available object in a certain Smalltalk environment is called the ‘image’. The standard Squeak image includes really a lot of objects. Perhaps too many for a beginner. You can use it anyway, or you can get www.jvuletich.org/Squeak/EToysFreeMorphic/NoEtoysImage-jmv.zip. This is a reduced image I like to use. Launch Squeak.

Click on an empty area of the screen to open the World menu. Select ‘Open…’ / ‘workspace’. There type 3+4. Select it. Right click over it and select ‘print it’. If it shows 7, you have written your Smalltalk “hello world” program.

Now you can try the first Smalltalk example in The Weekly Juan #6. Copy and paste the code in an empty workspace. Now select it and right click ‘do it’. Voila. It works.

Now let’s try the second version. This one includes some real Smalltalk programming. This is, adding behavior to existing objects. We’ll add new behavior (methods, code) to FFT objects. This is done by modifying the FFT class. In Smalltalk all objects belong to some class, that defines its behavior. Please note that classes are Objects too (as everything else).

Open the world menu and select ‘Open’ / ‘browser’. What you see now is the Smalltalk browser. The main tool for reading and writing Smalltalk code. The top half of the browser has four lists. From left to right we have:

- The System Categories. The items here show groups of classes that belong together. Do as follows: Right click / ‘find class…’ FFT <Enter>. The other 3 lists get filled.

 - The Classes in the selected Category. Class FFT is now selected.

 - Method categories. Methods in a class are grouped together in method categories. You can create a new category if you wish, named for example ‘extras’.

 When you select a category, in the bottom half of the browser you see a method template. Replace the selected text with the magnitudes method. Right click / ‘accept’. We have added a new method to the class. Add the remaining 4 methods.

All the methods appear in the fourth list, the methods list.

Now you can try the second Smalltalk example, that uses the newly added methods. Do it in a workspace as before.

After this, you can use the browser to see what other classes are available. Some of the most interesting objects in Squeak are graphical objects, ‘Morphs’. Read about them! Read my introductory article on Morphic.

You can also check the other links below Other Squeak Projects in http://www.jvuletich.org/.

If you want to better understand the ideas, read http://users.ipa.net/~dwighth/smalltalk/byte_aug81/design_principles_behind_smalltalk.html. In Spanish at http://www.smalltalking.net/Papers/stDesign/stDesign.htm.

Other great links for beginners are:

To know more about the history of Smalltalk, read

http://www.parc.xerox.com/about/history/default.html(at the bottom of the page, the seventies).

Well, I hope you enjoyed this, and you are wanting to know more about Smalltalk!

   2006-2007 Juan M. Vuletich