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,
with other programming languages and their tools. We are going to talk
something pretty different.
Smalltalk? Smalltalk is a different kind of computer. One that is not
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
execute them and such.
your computer becomes a virtual place filled with things. You can
these objects, and ask them to perform actions. You can inspect them,
their behavior and relationships. Of course, you can also modify their
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
too. Pieces of code are also Objects. In Smalltalk, even True and False
run Operating Systems. But the entities of regular Operating Systems
uniformly available for inspection, study and modification. This would
the basic ideas of Smalltalk! Therefore, while in Smalltalk, Smalltalk
the Operating System. You can interact with and modify such things as
Directories the same way you manipulate any other object.
As the whole
Smalltalk system is made with Objects, and all Objects can be studied
modified, the Smalltalk system hides no secrets from the user. Any
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
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,
can get www.jvuletich.org/Squeak/EToysFreeMorphic/NoEtoysImage-jmv.zip.
This is a reduced image I like to use.
Click on an
empty area of the screen to open the World menu. Select
There type 3+4. Select it. Right click over it and select
‘print it’. If it
shows 7, you have written your Smalltalk “hello
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
‘do it’. Voila. It works.
the second version. This one includes some real Smalltalk programming.
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
belong to some class, that defines its behavior. Please note that
Objects too (as everything else).
Open the world
menu and select ‘Open’ /
‘browser’. What you see now is the Smalltalk
main tool for reading and writing Smalltalk code. The top half of the
has four lists. From left to right we have:
- The System
Categories. The items here show groups of classes that belong together.
follows: Right click / ‘find class…’ FFT
<Enter>. The other 3 lists get
the selected Category. Class FFT is now selected.
categories. Methods in a class are grouped together in method
can create a new category if you wish, named for example
a category, in the bottom half of the browser you see a method
Replace the selected text with the magnitudes method. Right click /
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
workspace as before.
After this, you
can use the browser to see what other classes are available. Some of
interesting objects in Squeak are graphical objects,
‘Morphs’. Read about them!
Read my introductory
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
the bottom of the page, the seventies).
Well, I hope you
enjoyed this, and you are wanting to know more about Smalltalk!