Mar 01 Online
Volume Number: 17
Issue Number: 3
Column Tag: The Column Tag
MacTech Online
by Jeff Clites <online@mactech.com>
Smalltalk
I recently ran across a paper which describes a study comparing the productivity and
efficiency of several programming languages. While it's difficult to draw concrete
conclusions from such a comparison, the paper did make an interesting observation:
programmers of scripting languages (such as Perl, Python, and Tcl) tend to use
language features differently than programmers of non-scripting languages (such as
C, C++, and Java). Specifically, they noted that the former group used data structures
(such as arrays and dictionaries) which are built into the language, where as the
latter group consistently implemented their own data structures from scratch rather
than using those provided by their languages' standard libraries. This reminded me of
an observation that I had made of my own programming practices - namely, that
learning a new programming language influences how I program in other languages.
For example, after learning Perl I tended to use associative arrays (also known as
hashes, dictionaries or maps) more frequently in other languages, and implemented
custom objects and data structures less often. In fact, this makes a lot of sense when
you start to think about it - different languages have different design goals and
cultures, and lead you to thinking about programming from different perspectives. As
a developer, I view a programming language as a tool - albeit a rather important one.
Like most other tools, people tend to have a favorite, but you are always better off
having a variety to call upon to tackle different problems. And with programming
languages in particular, I would argue that knowing a variety of languages can make
you a better programmer in your language of choice.
So in the spirit of broadening our horizons, this month we are going to talk about the
programming language Smalltalk. The goal here isn't to convince you to use Smalltalk
for your next project, but rather to encourage you to read up on, and play with, a new
language, as an incubator for new ideas and because, frankly, it's fun.
• An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl
<http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprt_computer2000.pdf>
What Makes Smalltalk Special
Smalltalk has been around for quite a while, and in fact its genesis dates back to Alan
Kay's Dynabook project at Xerox PARC, the same project which lead to the development
of the graphical user interface (GUI). It was one of the things shown to Steve Jobs on
his famous trip to the research center, and according to the story Xerox was more
worried about letting Smalltalk out of the bag than they were about revealing the GUI.
Smalltalk was arguably the first pure object-oriented language; everything in
Smalltalk is an object - there are no primitive types. It will look a bit familiar to
Objective-C programmers - the message-passing syntax (as well as the object model)
of Objective-C was based on Smalltalk, the most obvious difference being that
Smalltalk does not enclose its message sends in brackets. (So, the Objective-C
statement "[dog fetch:stick]" would be just "dog fetch:stick" in Smalltalk.) Smalltalk
was a language ahead of its time in many ways. For instance, inherent to all Smalltalk
development systems is a class browser. You've probably seen class browsers before,
either in connection with Java, or in Apple's Project Builder, or in some other IDE.
What sets the Smalltalk Browser apart is that all development is done there -
Smalltalk source code does not live in separate text files. The plus side of this is that
the programmer doesn't have to worry about how source code should be organized, or