A wiki page to accompany your venture into SqueakSmalltalk.
you := Student new.
"Wherein the humble student begins the journey"
you get: Squeak copy.
"The student obtains the software"
- Go to http://www.squeak.org/ and look around.
- Download the current release for your platform of choice from the handy download box on the main page.
- Get squeak running (usually by dragging the Squeak3.0.image file onto the Squeak executable).
- "Before you turn something on, learn how to turn it off." To quit Squeak gracefully:
- 'Quit the Squeak way': left-click on the background and select the "save and quit" or the "quit" menu item.
- Alternatively, use the "file->quit" menu item from the virtual machine's menu.
you exploreSqueak.
"The student becomes familiar with the programming environment"
When you start Squeak you will see:
- the desktop, or background, is called the "world" (at least in this tutorial).
- a few windows with text in them inhabit the world. Each window titlebar has:
- an "x" (which closes/deletes the window)
- an "o" (which collapses/zooms the window)
- strange little icon (I think it's supposed to be a window, or perhaps Paul Lynne) which opens a menu that controls the window.
- several "flaps" located along the edges of the world (similar in concept to the Mac OS X dock),
- the Squeak Mascot peers out, following your mouse,
- and "The Worlds of Squeak" project window (more on this below).
The Squeak UI is different. Familiarize yourself with it by perusing this excellent tutorial:
http://minnow.cc.gatech.edu/squeak/uploads/SqueakLanguageRef.3.html
Squeak assumes that you have a 3-button mouse (If you don't, you may have to use the modifier keys specific for your platform). The buttons (for windows users) are:
- The left-click: Does what you think (selects windows, places the insertion point, selects text) and more (opens a menu when you click on the world).
- The right-click: Does what you expect as well (opens a context-sensitive menu).
- The alt-click: When you alt-click on any object, a Halo of Buttons appear around the object. This "Halo" contains many useful ways to interact with the object (resize, rotate, duplicate, remove).
Many commands are issued through menu selections. I'll use the following shorthand in describing menu commands:
Menu: MenuNameOrLocation->MenuItem->SubMenuItem->SubSubMenuItem
Now, click into "The Worlds of Squeak" project window. This opens the project and it zooms to take over the screen. Visit the various projects to get an idea of what squeak can do. Play around and explore.
You'll actually learn quite a lot by "playing around" with the Worlds of Squeak projects. They are complete applications that demonstrate some of the advanced capabilities of the environment.
When you're done exploring, go back to the main window: Menu: World->previous project.
myLab := Project new.
"The student sets up their workspace."
- Set up a new project, so you don't mess up the fancy projects you just visited. Menu: World->open...->morphic project
- A new morphic project named "Unnamed1" will appear. Change the name by clicking on the tiny icon next to the "X" on the titlebar Menu:change title...
- Enter your brave new project
- Make a Workspace window: Menu: World->open...->Workspace
- Make a Transcript window: Menu: World->open...->Transcript
Both these windows are like text editors. You can type text into them, move around with arrow keys, and delete text. "Command-a" selects all the text in the window.
Right-click in each of these windows to see a window-specific menu.
World: hello.
"The traditional rite of passage"
Finally, we are about do to something that might actually look like programming in a regular language. We are going to type text in a window and see what happens...
Type the following into the Workspace window:
hello := 'Hello, World'.
Transcript show: hello.
- Note: this could be simplified as just "Transcript show: 'Hello, World'"
We want to execute, or 'do', this bit of code. Select these two lines. Bring up the Workspace menu (Right-click in the Workspace window)
Menu:Workspace->do it (d).
The Transcript window will show:
Hello, World
Ok, so what just happened?
I suppose I could give you a lot of language syntax rules and say "Them's the rules", but Squeak is far too elegant for that. There's one basic rule that will go a long way. Every Squeak statement follows this format:
object message.
or in English grammer...
noun verb.
Let's parse these two lines like Squeak would. We'll find out what we did, and more importantly, we'll find out what Squeak did.
When you tell Squeak to "do it", Squeak takes the contents of the Workspace and parses it into tokens.
- hello
- The first token is the object. Squeak searches its list of objects, and if it doesn't find the 'hello' object, it creates the 'hello' object.
- := 'Hello World'.
- Everything else in the statement up to the period must be the message.
- Transcript
- This is the object. Squeak searches its list and finds the Transcript object. It's the Transcript window in your project.
- show: hello.
- Everything else is the message.
(need to add how Squeak parses the message and looks into the object for the method. Should describe unary, binary, and keyword methods.)
Other Tutorials for Squeak:
Squeak-specific:
Smalltalk/Objects in general:
There is a Squeak wiki at
http://minnow.cc.gatech.edu/squeak/squeak
Some short-and-sweet lessons/examples are in the Squeak Cookbook at http://minnow.cc.gatech.edu/squeak/666
There is a long Morphic tutorial threaded through the Squeak wiki. Here are the links to follow, in order:
(Maybe this should be moved to its own topic, called LearningSqueakMorphic? or something like that.)
(I'm guessing that this will probably happen soon. This page will become a series of lessons, and the other pages will have "A Lesson from LearningSqueak" at the top. This is about the only reason why I like 1 level subpages. Of course, maybe I should just move all this stuff over to the Squeak Wiki and leave this poor wiki alone... -- SeanOleary)
Hmmm.. Maybe we should make SqueakWiki (SqueakSwiki?) one of the SisterSites?
Named Contributors: SeanOleary, KrisJohnson
See also LearningProgrammingLanguages, SmalltalkLearnersClub