macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Good Books, Smalltalk, and Squeak
Pages: 1, 2

Annual object fest at OOPSLA

I'm an OOPSLA newbie. I've now been to two of their annual meetings. OOPSLA is Object-Oriented Programming, Systems, Languages and Applications, and you can check out their Web site at http://oopsla.acm.org. OOPSLA is often thought of as an academic conference, but I've gotten a lot of real insight into real programming there. Next year's meeting is in Seattle in early November.



Kristen Nygaard delivered a keynote address to the educators symposium. As co-creator of Simula, he is credited with inventing object-oriented programming (although he didn't call it that at the time). Fundamental concepts such as encapsulation were included in the early Simula and inheritance was later added. Smalltalk was a child of Simula.

As an aside, think about your Mac. You have a mouse and a screen that contains windows and a dock and a menubar. You can click on these various items and they react the way they should. You expect that when you click on the apple in the menubar, the apple menu will drop down. You expect that when you click on the finder in the dock, a finder window will appear. These objects know how they respond to a mouse click and they behave appropriately. In a way, this is why kids understand object-oriented programming so much better than we do. They've spent their lives interacting with GUIs where they send messages to objects and the object handles the messages appropriately.

Many years ago, I saw Alan Kay speak at an all girls school (that's what they were called in those days) in Cleveland. He showed a video of a two year old turning on a computer, popping in a floppy, and then opening and using an application. The audience gasped. And yet, now that computers are ubiquitous, this is common place. Each of my daughters was comfortable on a computer at age two. This isn't special. Almost every kid's show has its own Web site. My five year old will ask permission to go to sites to print out character coloring pages for my two year old.

It makes total sense that the Learning Research Group at Xerox PARC, led by Kay, was developing this object-oriented language called Smalltalk at the same time they were creating a user environment that included windows, menus, icons, and a mouse. By Smalltalk-80, many Java-like features were part of the environment.

Smalltalk was a cross-platform language because Smalltalk code was compiled into bytecode that was interpreted by a virtual machine. Everything in Smalltalk is an object (no primitives) and objects are garbage collected. The goal of the core team was to create an environment that would allow children and educators to build compelling applications.

At OOPSLA, there is a core of Smalltalk folks who gather in what is called Camp Smalltalk. I thought I'd wander by and see if there was any support for Smalltalk on Mac OS X. I'd already stopped by the Visual Age for Smalltalk booth and they looked at me like I was nuts. But there at Camp Smalltalk, I saw a guy working on a Ti PowerBook. I quickly approached and asked him what he would recommend for using Smalltalk on Mac OS X. He suggested Squeak. For now, he said, use the Carbon version; soon the Cocoa version would be ready.

Beck's best Java book

This brings me to my second recommendation. One of the best books I've ever read about programming in Java is a collection of articles, most of which were written before Java 1.02 was ever released. Even though the syntax of the code examples is a bit foreign, the advice in Kent Beck's Guide to Better Smalltalk is modern and immediately applicable. Of course, you'll see the roots of Extreme Programming (XP) in these articles. In "Clean Code: Pipe Dream or State of Mind," Beck takes you through a refactoring and he explains the code smells that he detects and he shows you how to fix them. Even without knowing Smalltalk, you can recognize the repeated use of a conditional being replaced by a state pattern.

Several articles concern CRC (Class Responsibilities Collaborators) cards. Invented by Ward Cunningham, these cards involve more upfront design than Cunningham and Beck probably champion today. They do provide a nice way to think about the way objects interact. A class consists of what they know, what they do, and who they know. This tool captures information about the latter two categories. Although Cunningham and Beck presented CRC cards as a technique for teaching OO to newbies, they learned quickly that experienced developers were using their tool to better understand complex systems.

Much of the book concentrates on Patterns, including an article cowritten with GoF member Ralph Johnson. The patterns here are more concisely presented than those in the GoF book, but they're no less useful. In his "Short Introduction to a Pattern Language" published in 1993, he recommends architect Christopher Alexander's books: The Timeless Way of Building and A Pattern Language. It's now almost cliche to mention Alexander's work when teaching or writing about design patterns. Alexander has probably sold more books to software designers than to architects. Beck referenced Alexander's books in a JOOP article for 1989 called "Constructing Abstractions for Object-Oriented Applications" that is reprinted in this book.

You'll recognize what later became JUnit described in the article "Simple Smalltalk Testing." It describes writing Unit Tests in the context of Smalltalk, in much the same way the article "Test Infected" (available with the JUnit download from http://www.junit.org) described the process for Java years later. Beck, together with Erich Gamma, wrote the first iterations of JUnit. At OOPSLA, Gamma demonstrated the refactoring capabilities of the open source, cross-platform IDE Eclipse, but with refactoring of some of the JUnit code. I would post the Eclipse Web site, but part of the GUI is based on platform-specific code and there are no plans to release this IDE for Mac OS X.

As a final point about this book, I almost didn't buy it. I didn't know any Smalltalk, so what would a guide to better Smalltalk teach me? As often happens, there is more to be learned by broadening experiences. Relevancies don't always reveal themselves early. As Kimmy-the-wonderwife reminds me, I learned more about collaborative learning by working in a professional kitchen than I did by attending education seminars about the topic. Again, stop in your local bookstore and read a quick article or two to decide if this book is for you.

Downloads and Invitations

Also in Java Programming on a Mac

A Rendezvous with Java

Integrating Ant with Xcode

Transforming iCal Calendars with Java

Apple Releases Java 1.4.1 for Mac OS X

The remainder of this article is brief. First, I want to urge you to download Squeak. Squeak is the current implementation of Smalltalk by Alan Kay and his team. Kay's name keeps surfacing in interesting places on interesting projects. You can read about the Vivarium project in Stewart Brand's The Media Lab and about Playground in Beck's Smalltalk book, which I recommended in the last section. There's a good amount of background in the third book I'm recommending, Mark Guzdial's Squeak: Objected-Oriented Design with Multimedia Applications from Prentice Hall. The Squeak team moved from Apple to Disney where Kay is a Disney Fellow.

Go to http://www.squeak.org and download the software. Follow the links to the download area. Under the Mac options, you'll find that you can download a Classic version, a Carbon version, or a Cocoa version. The Cocoa version isn't quite ready yet. The Carbon version is strong but you need files that don't come with that distribution. So first download the Classic version and unzip it. Then download the Carbon version and start it up. When you are directed to find an image file, browse to the .image file that was part of the Classic download. Click on the tab along the left side and choose to update your software. Once the software has properly updated, your Squeak window should look something like this.


Click image to enlarge

 

Play with it. Open up the games and play Tetris or Solitaire. Open up the Sound and play with the music application. As you explore the different worlds, you can hear the development tool calling to you, "Hey, what cool educational application would you like to develop today?" Guzdial's book is a great introduction to developing applications with Squeak, and it includes examples that apply to object-oriented programs in general. The Squeak team, however, has been careful to add very cool features that suggest interesting possibilities to developers with imagination. Be careful; you may be sucked in.

Another great way to learn about Squeak is by checking out the Swiki.


Click image to enlarge

 

The Swiki is a Squeak Wiki. If you don't know about Wikis, you may want to begin by wandering around the Big Wiki. Why don't you start at http://c2.com/cgi/wiki?CategoryPattern. A Wiki is a Web site where every page is editable by everybody. Please be courteous: It's an awfully cool idea that depends on somewhat well behaved participants. The Swiki allows portions of the page to be locked by the author.

The Wiki is yet another idea invented by Ward Cunningham. As a bonus book this month, you might want to check out The Wiki Way: Quick Collaboration on the Web that he cowrote with Bo Leuf. The book includes sample starter Wikis on the CD. You should go to the Web site and pick up the corrected files.

A Swiki is actually even easier to run. You can download it and have it up and running in about ten minutes. You'll find the information and links that you need at the Swiki Web site at http://pbl.cc.gatech.edu/myswiki. The spirit of a Swiki is similar to that involved in collective code ownership in XP. You'll find Cunningham's fingerprints on a lot of the XP practices.

Daniel H. Steinberg is the editor for the new series of Mac Developer titles for the Pragmatic Programmers. He writes feature articles for Apple's ADC web site and is a regular contributor to Mac Devcenter. He has presented at Apple's Worldwide Developer Conference, MacWorld, MacHack and other Mac developer conferences.


Read more Java Programming on the Mac columns.

Return to the Mac DevCenter.