Basic Squeak Development Tools
Last updated at 5:50 am UTC on 29 October 2017
Smalltalk environments have some of the best user interfaces for programmers ever devised. Those who have programmed in Lisp under Emacs have some idea, but Smalltalk is even better.
Unfortunately, just like with Emacs, the most useful tools can be hidden from view. Often they are verbally passed down from one Smalltalk programmer to the next – a slow process that doesn't work if there are not experienced Smalltalkers around! In the hopes that some programmers occasionally read English as well as reading code, this page attempts to speed that process up by directly describing the most useful aspects of the Squeak interface for programming. If you want to seriously work with Smalltalk code, you should try these tools out.
(By the way, this information is presented very nicely in Mark Guzdial's textbook, section 2.5. See Smalltalk & Squeak books, specifically Squeak: Object-Oriented Design with Multimedia Applications).
You should learn these basic tools thoroughly:
Other not-quite-as-fundamental but very useful tools are:
Code in Text Windows
Every text area in Squeak understands Smalltalk code.
This includes the usual Workspaces, along with Browsers, Inspectors, and Debuggers. Three variations are available:
These commands often make other variables available, depending on which window you run them in. Using them in a browser will give you direct access to class variables and pool variables that methods of the currently browsed class is viewing. For example, you may browse to a class, highlight one of the class variables in the, and select print-it or inspect-it to see the value of that class variable. Let deduction be your guide: what variables could that window possibly know about? Use them!
- do-it (alt-D) – execute the selected code.
- print-it (alt-p) – execute the selected code and print the result. The result will be highlighted so that you can conveniently delete it or cut (alt-x) it.
- inspect-it (alt-i) – execute the selected code and inspect the result.
Finally, a speed tip: if you run one of these commands without selecting anything, then the system will use the entire current line. Thus you can type "3+4<alt-p>" without any mousing, and get 7 back.
Exploring the Code
There are several tools available for browsing around the code.
There are two ways to do whole-system search. First is the Method Finder. Open it, learn it, use it – it allows you to search for methods by name, and even by the values the method produces.
Second, all text windows have two ways to search raw method text available on the context menus.
- There is "method source with it", which finds all methods that contain a string anywhere within their source. This tool is useful as a last resort when other approaches fail.
- There is "method strings with it", which searches the string literals of all methods and returns a list of matches. This tool is useful for finding the code responsible for a menu or a window, or finding the code that is printing out some status message on Transcript.
Semantically Relevant Code
Smalltalk browsers understand the structure of the code they are browsing. This allows the browsers to implement several little queries; this system might be viewed as dynamic hypertext – the links are automatically deduced from the program text.
- browse-it (alt-b). In most browser windows, you can "browse it" to open the most obvious class in a new System Browser. For example, doing browse-it in an Inspector will browse the class of the selecetd field. Note that even lowly text areas will browse the name of a class you have selected; typing "Point<alt-b>" is a fast way to open a browser on class Point, for example.
- implementers-of and senders-of (alt-m and alt-n). Whenever a message is selected in a tool, you can search the system for implementers and senders with these tools. Senders-of will show you which methods might call a currently viewed method. Depending on how you use it, implementors-of will tell you either possible responders to a message send, or alternative implementations of of a method. Note, these are available from text areas as well as from full-blown tools; type in a selector, select it with the mouse, and then hit alt-m or alt-n.
- variable users and definers. Most browsers allow you to search the system for users and definers of a variable. The menus usually offer to search for instance variables directly. Searching for other variables is performed using the "references to it" (alt-N) function.
- two invaluable packages make use of this feature are Shout which gives live syntax highlighting, and eCompletion which gives context-sensitive, interactive tab-completion.
Other Basic Browsers
There are other browsers available in Squeak besides the usual 5-paned green Browser. Here are two of them.
Class Hierarchy Browser
If you select a class in a 5-paned browser and select "spawn hierarchy" (alt-h) from the context menu in the second pane from the left, you'll get a class hierarchy browser. This browser will be optimized for browsing the class hierarchy above and below a particular class.
Method Hierarchy Browser
Another great view on code is found in the message list pane. Look at any method, and choose "method hierarchy" from the menu (in the message list pane). It brings up a message list window with the current method and all inherited versions. This is especially useful then the method has super in it, or when you can't remember the inheritance chain, or when you want to see how this methods is implemented more generally by a superclass.
These are some browsers written by people in the Smalltalk community which offer new features.
Written by Doug Way, this browser allows you to have multiple code panes open in one window. Highly recommended, the only disadvantage is that it does not have hooks into the Refactoring Browser engine.
Often it as interesting how you get here, as what exactly here is. Two tools are especially useful for this:
- "Browse recent submissions" from the "changes" menu will show you the last 10 or so methods you have entered.
- "Browser recently logged changes" from the "changes" menu allows you to browse the complete log of method submissions, class definitions, and do-its you have performed in the current image. Note, this works even if you haven't saved your image, so it can be useful for crash recovery! (See also What to do if Squeak crashes or freezes.)
Development Tools Overview (Monticello, SqueakSource, SqueakMap)
Squeak IDE, the list filtering feature