A primer on the Squeak programming environment

Before we start actually doing anything on Seaside, it’s important to learn a bit on the environment. I’m working on the assumption that, like myself, you know next to nothing about Squeak or Smalltalk. The first thing you need to do is to download the environment from the Squeak website. You should know that Squeak consists of a ‘virtual machine’ that is specific to a platform, and an image (usually .image file). The image file is rather large (usually in tens of MB) but this should not be shocking as it is the complete environment.

Once you have downloaded your VM of choice (from now on, I’ll use Windows since I run Windows most of the time) and an image of choice (I use the one from Seaside), you’re ready to go. Double click on squeak.exe and select your image.


Once you get into the environment you’ll see a nice graphical user interface which is quite familiar but yet not familiar. To start an application, you don’t double click but drag and drop it on to the main workspace. There is an application called Workspace, which is ‘console-like’. You can type Smaltalk in it, then right-click and select ‘do it’ to run your script. The shortcut on Windows is use alt-d. For example, to run the the Komanche web server, type ‘WAKom startOn: 8080’, select this line and ‘do it’.

One of the first things you’ll see is the System Browser. You might think it strange but it’s really going to be your main development tool. There are five main panes, 4 of them in the top row and a big one at the bottom row. If you don’t see it, left click once on the desktop (to get the ‘world’ popup menu), select ‘open …’ and then ‘browser’.


Starting from the left, the first pane is the class category pane. Class categories are convenient placeholders for classes, a means of organizing your classes. To add a new class category, right click once and select ‘add item…’. Fill up the input box when it pops up and you have a new class category.

The second pane is the class pane. This pane shows a list of classes for the class category you select. To add a new class, if you expect to right-click the class pane and select ‘add class’ you’ll be dead wrong. I was stumped for a few days on this. Notice if you create a class category ‘Saush’ on the first pane and select it, you will see something like this at the bottom pane:

Object subclass: #NameOfSubclass
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Saush'

This is the class template. Change #NameOfSubclass to something else e.g. #MyFirstClass (remember to keep the hash), then right click and select ‘accept’ or alt-s to save. You will see a new class appearing at the second pane called ‘MyFirstClass’. At the bottom of the second pane are two buttons, labeled ‘instance’ and ‘class’ respectively. If you click on the instance button you’ll show the instance method categories and methods to the third and fourth panes. If you click on the class button, you’ll show the class method categories and class methods on those panes.

The third pane is the method category pane. Method categories are just means of classifing methods and have no other meaning than that. How do you add a new method category? If you guessed right clicking on the pane and selecting ‘new category’, then you’re absolutely correct! There is a method category called ‘all’ that you can click and display all methods on the right-most pane.

The fourth and last pane to the right is the method pane. If you have followed the above carefully you might have guessed that to create a method belonging to a method category you’ll select the method category, then fill up the template displayed at the bottom pane and save it. The template looks something like this:

message selector and argument names
"comment stating purpose of message"

| temporary variable names |

‘Message’ here means the class method (Smalltalk calls all methods “messages”). Comments are delimited by the ” (whereas most languages use ” for string definition. Whatever you define between the vertical bars ‘|’ are variables you will use in the method. Note that if you create a method when selecting the ‘all’ method category you’ll get a ‘as yet unclassified’ category and your new method will belong to it. To change the classification of the method just drag and drop it to the correct method category.

One of the menu items when you select from any of the panes is ‘FileOut’. If you select this you will create a file out of the item you selected. You can take the file, modify it and do a FileIn from the File List application. Just go to the ‘World’ popup menu, click on ‘open’ and then ‘file list’. Select the file you have just modified, click on the ‘file in’ button at the top of the application.

If you look carefully at the file that you generated from FileOut you’ll see the method categories are bounded with ‘!’. You need method categories. If you create a method without a method category you can’t do a FileIn anymore.

Play around a bit more with the System Browser until you’re comfortable. You’ll be using it a lot in my next post on creating a Seaside application.

9 thoughts on “A primer on the Squeak programming environment

  1. It’s interesting that you are venturing into other dynamic OOP languages like Squeak. Did you see the latest venture into Interpreting-Ruby-On-Other-VMs where Avi Bryant from DabbleDB/Smallthought used JRuby’s AST to convert Ruby code to its Squeak-equivalent? Smalltalk has a reportedly damn fast VM, so this is an interesting route to take Ruby to the fast lane versus the other efforts like YARV and Rubinius.

  2. I’ve read a bit about it though admittedly it’s not an interest area for me so I did not venture too far into it. Somehow mixing up languages doesn’t appeal to me. It’s a personal thing — so far I’ve avoided things like JRuby or the like. The only thing that I mix regularly is probably SQL :)

    1. Considerably, the article is relaly the most useful on this worthw hile topic. I concur with your conclusions and will eagerly look forward to your approaching updates. Saying thanks will not simply be sufficient, for the exceptional clarity in your writing. I will at once grab your rss feed to stay informed of any kind of updates. Genuine work and also much success in your business dealings!

  3. I liked this post about Squeak. You actually went through the same issues as I did :) Looking forward to your next Squeak/Seaside post!

  4. Caramba! Muito, mas muito legal mesmo! Esse livro tem tudo para ser uma referência bem clptoema sobre o framework. Já coloquei nos favoritos.Obrigado pelo link, Francisco!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s