Com S 541 - Programming Languages 1, Fall 2002


General Info.
Course Homepage
About Com S 541
Contacting Us
Syllabus

Homework & Grades
Grading Policies
Grades
Homework Directory
Exams

Reference
Q & A
Meeting outlines
Resources
Running Smalltalk
Running Java

Links
Department Homepage
Iowa State U. Homepage

Valid HTML 4.0!
Valid CSS!
 

Running Smalltalk

This page is organized as follows:

  1. Running Smalltalk on Departmental Linux Machines
  2. Running Smalltalk on Your Home Machine

Running Smalltalk on Departmental Linux Machines

The departmental Linux machines are the recommended platforms for course work, but Smalltalk should run the same everywhere, so the choice is up to you.

This section is organized as follows:

  1. Starting Squeak
  2. Starting VisualWorks Smalltalk
  3. Working with Smalltalk

We recommend using the Squeak Smalltalk interpreter in 541, since it corresponds most closely to the Goldberg and Robson book.

Starting Squeak

On the department linux machines (popeye, etc.) the Squeak interpreter is found in /opt/squeak/bin/, which is in your PATH by default. (Thus you shouldn't have to do anything special to set this up.)

To start Squeak first make a directory where the Squeak image and changes files will live. You can do this, for example, as follows, by typing the following at the shell's prompt:

$ mkdir Squeak
$ cd Squeak

Note: In code examples, green text is program output, yellow bold text is user input, and cyan text is sample code.

Then you need to initialize Squeak, by running the following command to copy the Squeak image files to your directory. You can do this by copying the files manually, but it's easier to use the following shell script from the course bin directory.

$ ~leavens/WWW/ComS541/bin/inisqueak

This should make a symbolic link for the file `SqueakV3.sources', and copies of the `squeak.changes' and `squeak.image' files from `/opt/squeak' into your directory, and will then launch Squeak for the first time.

Exiting Squeak

To quit Squeak, left click in the window that comes up in the grey background area, and select save and quit from the menu that appears.

Running Squeak after the first time

After the first time using squeak, you can start it using the command squeak command from the directory containing the image file. For example:

$ cd Squeak
$ squeak

Note that everything picks up just where you left it. This is your "session", which is saved in the image file. You can have multiple images saved, but beware that they take up a lot of space.

Basic Squeak

Don't hesitate to play around with things. The system is designed to be played with, and it's difficult to break. Even if that happens, you can always start over again, if necessary with a new copy of the standard image file.

To read and edit code in Squeak, you need a browser. To get a browser, use the `Tools' tab on the right of the Squeak window, and then drag the browser icon into the main part of the workspace. This will be (by default) a standard system browser.

To get an up-arrow (for return from a method), type a caret (^). To get an left-arrow (for assignment), type an underscore (_); you can also use := for an assignment operator (which is portable to VisualWorks).

The menu shortcuts, like (v) seem to refer to the use of the "alt" key, like Alt-v, not control keys as you might expect. See Greenberg and Black's Squeak Quick Reference page for more detail and more menu shortcuts.

If you feel like exploring the "Worlds of Squeak" window. Note that you can get back to the main window by left clicking in the unoccupied areas and choosing "previous project" from the "World" menu. Also, it seems to be helpful to go to http://www.squeakland.org/ first to get a tutorial on using all of this fun stuff. Note that the plugin you download for squeakland is not the same as the squeak smalltalk interpreter we'll use in class (although it is quite similar).

Return to Section Start

Starting Cincom's Visualworks Smalltalk

The Cincom VisualWorks Smalltalk Non-Commercial version is a Smalltalk interpreter that is also available on our Linux machines. It has some significant differences from our book, especially in terms of more modern paradigms for building graphical user interfaces, although the core (non-graphical) parts are quite similar.

To start VisualWorks Smalltalk, it is also helpful to have a directory to contain the image file. You can proceed as above, if you like, to create a directory and change into it.

$ mkdir vworks
$ cd vworks

Then you have to copy the `visualnc.im' image file from the `/opt/vworks/image' directory to your directory, as follows.

$ cp /opt/vworks/image/visualnc.im .

To run the interpreter you need to export the `VISUALWORKS' environment variable set to `/opt/vworks' and exported, and you need to pass the name of the image file on the command line. We have a shell script that sets this environment variable and checks for the command line argument, so one way to run the interpreter is to type the following at the shell's prompt:

$ ~leavens/WWW/ComS541/bin/visualworks visualnc.im

When the interpreter starts, you'll first be presented with the non-commercial license agreement. If you agree to that, you'll see a brightly colored lesson launcher window, a welcome window, and a short wide grey window which has the main menus and the transcript on it. We recommend playing with the lesson launcher, even if you're planning to use Squeak.

Exiting VisualWorks Smalltalk

To quit, use the main window's file menu, and select save and exit. If you select this, besides your image file, you will have a file `visualnc.cha' which is the changes file, in your directory.

Running VisualWorks after the first time

After the first time using VisualWorks Smalltalk, you can start it using the command visualworks command from the course bin directory, after you change into the directory containing the image file. For example:

$ cd vworks
$ ~leavens/WWW/ComS541/bin/visualworks visualnc.im

Again, everything picks up just where you left it. This is your "session", which is saved in the image file. You can have multiple images saved, but beware that they take up a lot of space.

Basic VisualWorks

Don't hesitate to play around with things. The system is designed to be played with, and it's difficult to break. Even if that happens, you can always start over again, if necessary with a new copy of the standard image file.

To read and edit code in VisualWorks, you need a browser. To get a browser, use the Browser menu in the main window. To get a standard system browser, use the "all classes" item.

To get an up-arrow (for return from a method), type a caret (^). Use := for an assignment operator.

Visual works has many helpful keyboard shortcuts you can use while editing. These are described in the Lesson Browser's lesson 01, under "short cuts" as well as other places in the documentation. Note that VisualWorks seems to use the control key instead of the alt key to make such shortcuts.

Return to Section Start

Working With Smalltalk

Saving your work

Since Smalltalk records your work in an image file, if your computer crashes, or has to be rebooted, you will lose all of your work since the start of your session or the last time you saved your image (or filed out your changed sources). Every semester, someone gets burned by this, so be warned. The best thing to do is to save your image often. It's quite important to save your image before you start any testing. Also be sure to save the image before you make any changes to the underlying Smalltalk system.

To save your image, simply select the appropriate menu item from the bottom of the left button menu in Squeak, or from the main window's File menu in VisualWorks.

On the other hand, if you do crash and burn, see the Squeak FAQ article about recovering a crash from the .changes file.

Filing out your work

A handy thing to do is to file the category or classes you are working on. In Squeak, use the right button in the browser at the level you wish to file out. It's often easiest to file out a whole category at a time.

To file in filed out code, use the file browser, and select a file and then right click it and select "file in" from the menu to file in the selected file.

Printing your work

To make a printout of your work, for example, to hand in the work, used its "printOut" function from the right button's mouse menu. This generates a HTML file you can view in a browser and subsequently print from there. The HTML file will appear in the same directory as Squeak's image file.

Smalltalk Advanced Topics

When you change the code in a browser window, and then move on to something else, Smalltalk will ask if you want to cancel the changes you made. Usually, I want the changes, so I select "no" and then go back to where I made the changes and right-click in the window where the changes were made, and then select "accept" to accept the changes. It's a good idea to get in the habit of accepting the changes before you move on...

See the course textbook for more about Smalltalk. There is a nice tutorial on Smalltalk basics available from the "lesson launcher" if you start up VisualWorks. See also the course resources page for links to more Smalltalk resources.

Return to Section Start

Return to top

Running Smalltalk on Your Home Machine

The Squeak and VisualWorks systems work the same way as on the department Linux machines on your home machines. (In fact, you can even use the same image file on different platforms with the same Smalltalk version.) However, one piece of advice is to make a copy of the original image file before you start working, so that you can easily get back to the original if you have problems. This isn't necessary on the department Linux machines, because there is already a shared copy of the image, but at home it may be helpful.

Getting Squeak for your Home Machine

The Squeak Smalltalk interpreter used for this course is available on many platforms, including Unix, Macintosh, and Windows. You can download it from squeak.org. Scroll down the page to find the appropriate things to download for your machine. For a windows machine, you just need to download a zip file and unzip it into a directory where you'll keep the image. We are using Squeak 3.2.

Getting Cincom's VisualWorks Noncommercial on your Home Machine

You can get Cincom's VisualWorks noncommercial version free from their download page. It runs on most flavors of Unix, PCs, and Macs. You'll have to fill out some information about yourself to get the download.

Return to top

Last modified Thursday, September 12, 2002.

This web page is for the Fall 2002 offering of Com S 541 at Iowa State University. The details of this course are subject to change as experience dictates and are still in draft form. Once the semester starts, students will be informed of any changes. Please direct any comments or questions to Gary T. Leavens at leavens@cs-DOT-iastate-DOT-edu.