Why Squeak? Part I
In this series of articles, I will highlight the advantages of using Squeak/Smalltalk to develop educational software. At some point and based on my experience, I will compare with other development languages. The focus of this article is for educators and developers interested in software programming education applications. In these articles, don't expect to learn about Smalltalk/Squeak programming, my goal is simply to give an overall picture, based on real experience. Feedback is of course very welcome.
Have you noticed in my title I wrote development platform and not programming language. Indeed Smalltalk, and Squeak particularly, is not only a language it is also an environment to write code. This aspect is rooted to the whole history of Smalltalk in the 70s at the Xerox Parc, where Alan Kay's team created several versions of Smalltalk in a specific graphical user interface environment with a mouse and windows. It came with unique features such as a virtual machine and an image architecture, a full object oriented and reflexive language.
Why an educator will care about that?
Some key aspects in Squeak/Smalltalk I find the most interesting when writing educational applications are:
- the GUI, called Morph
- the Smalltalk image, an unique environment to test your ideas and instantly save the state of your work
- your application is portable to many OS architectures
- a nice integrated development environment (IDE)
- an unique way to debug your application
- a rich set of interactive and multimedia classes
- a skilled community
I will develop these points with concrete examples. One point per article. I will first discuss the Morph GUI system.
The Morph GUI
In this GUI framework, a Morph is a graphical unit. It can be a bitmap, a geometric object as a segment, an ellipse, a polygon, a character, a string, a video canvas, etc. A Morph can be inserted into another one, with or without layout. All the graphical objects in Squeak are assembled Morph. Morph can be manipulated interactively by the user. One helper for such manipulation is the halo system.
The first special feature a user meets with Morph is the halo system. Within the Morph GUI, Halo is a collection of object handles surrounding any kind of graphical objects such as windows, button, graphic, text strings, etc. The halo can be called on demand.
There are various functions like duplicating, resizing, rotating, repainting, etc. I won't be explaining further, several starter guides are doing it. The halo strong point, is being able to let the user manipulate the object freely. If you design an educational application with Squeak, keep in mind the user will be empowered by the halo system, so be sure to consider the halo effect when designing your software.
As I just explained, Morph can be physically manipulated, assembled or disbanded by the user. But this is not the end of the story, Morph can be logically manipulated and interlinked through a graphical scripting system.
In the halo, one handle is responsible for opening the viewer (the blue eye on the left). A viewer presents a set of graphical commands. Commands are about physical or logical characteristics regarding a Morph. Command work is input or output.
Not only can the user assemble various commands from one Morph, but he can also put together commands from several Morphs. So it it possible to link their behaviors.
In Dr. Geo II, I decided to use Morph as my graphical canvas underneath. Indeed, I wanted to take advantage of the Morph features for: inter-inclusion of Morph external to Dr. Geo II into it, and vis-versa, and also to give the freedom to the user to use Squeak Scripting with Dr. Geo II. It really empowers your application to do so.
In the screen shot bellow, Squeak scripting is used to attach the y-axis position of a Dr. Geo II Moprh point to a Morph slider: when the user moves the slider, the Dr. Geo's point moves accordingly. Not only do the point and the slider not know about each other, but this logical relation is performed at the user level.
Programming the Morph
What we described in the two previous sections was about how the Morph GUI empowers the end user. On the other hand, the Morph GUI programmer is able to:
- reuse existing Morphs to fit his needs. Reuse, can be: aggregate several Morphs in a new type of Morph, extend the behavior of a Morph,
- write from scratch a new Morph. Writing a new Morph is fun because you are completely free to decide how it will behave and look (with drawOn: method).
Bellow are a few examples of Morph I wrote through reuse and modification of previous ones, or from scratch.
A few years ago, Python was becoming my favorite programming language to write educational application. I wrote a few articles on this topic (article 1, article 2, article 3) . The biggest advantage was the ease of use of the programming language. Using GTK+ with Python was pretty easy once you knew about it. However as the documentation about the GTK+ Python binding was mostly inexistent, I had to read the GTK+ C documentation and the Python source code binding then guessed about how to use it in Python. It was pretty do-able but quite time consuming. Funnily enough, I happened to do the same thing with Squeak and the Morph GUI as the documentation was also very thin, but thanks to the Smalltalk reflective nature, it is so much easier to find, to test and to understand the necessary features. This is another advantage which empowers the programmer this time. I will explain it later when discussing the Smalltalk IDE.