View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Discussion 4 - Lee Crippen

Java to Smalltalk Guide

The most important thing to remember when first beginning Smalltalk after coming from a Java background is patience. Smalltalk is different. You will undoubtedly have some trouble at first trying to not only understand the syntax, but have it well enough in your head to write code yourself. You will also have trouble knowing where to begin. The class libraries for Smalltalk (actually Squeak, in my experience) are huge but badly documented. Given these points, you will probably have a difficult time when you first start using Smalltalk. You will need to have patience, and the rest of this guide will hopefully make things easier as well.

First off, the syntax hurdle. The good news is that Smalltalk syntax is remarkably simple and intuitive. The bad news is that it's still different from Java. Smalltalk is one of the most object-oriented languages out there and it shows. There are no primitives at all; all the code you write is some kind of messaging between objects, messages that in turn call the methods on the objects. Take, for example, the statement 5 + 5. In this case, the first object, 5, is sent the + message with the second object, another 5, as its argument. The + method then returns the result, which would be the object 10. This may seem a little screwy at first, but it enables you to do some complicated things in a few lines of code. The best way to get the hang of it is to sit down and try it, and this is where the patience part comes in.

The second difficulty with moving to Smalltalk from Java is its poorly documented class library. There are many classes you will find useful when coding in Smalltalk, but finding them can be difficult. I suggest using any and all materials that are available to you when you first start out. Lecture slides, a book (required for the class or found on your own), or searching on the internet. When it comes to making use of the class library, experience is the only real tool. You will not start out knowing where everything is, but after some time you will have a good enough knowledge of the classes to accomplish whatever you need to.

Link to this Page