Walking Big, Talking Small
There are too many programming languages. Too many of them are just different ways of saying the same thing. The ultimate example of this is VB.NET and C#.NET. As far as I know, anything you can express in one you can express in the other.
The abundance of seemingly redundant languages led me to focus on programming concepts, algorithms, and software design as the main focus of my idle curiosity. Being language-agnostic, these endeavors can apply in any environment, so this had the extra stink of productivity.
It is quite typical of an ISTJ, like myself, to focus on design efforts. Those ISTJers “do best in a career in which they can use their excellent organizational skills and their powers of concentration to create order and structure.”
So why would I want to latch on to the latest language, the latest passing fad (ironic that C tops the list)? It is unproductive brain candy. It seems like once you learn the general idea and methods of programming, you have essentially learned every language. Picking up a new one gets progressively trivial.
This is why the last language I learned was back in college (C# doesn’t count), which I believe was PHP. As the slides and slides on expressions, relational operators, method declaration, loops, etc. went on and on, I had to laugh. Haven’t I seen this before?
I’m a bit of a conservative, you see. Just like with my games and my general recreation, I lean towards utilizing my resources as best as I can. Aside from the fact that learning a new language may not be significantly different than any other that I’ve learned, the entire excursion might end up being an exercise in futility: I can’t get the run-time set up properly, I can’t compile or run my code, all the tutorials suck, and so on. I still haven’t been able to get the Java 6 source jar to work properly.
But all work and no play can turn MoffDub into a violent psychopath. And after reading the mention of the revered Smalltalk in a couple of posts, I decided it was high time to learn something that doesn’t look like Java or C#, something that was different on a programming paradigm-level.
Sure, I may not use Smalltalk at work, ever. But learning something new is a fun thing to do, and since I have never experienced a pure OO language that isn’t trying to cater to every paradigm, I might learn something that could translate into Java. Maybe.
On an impulse, I downloaded Squeak. On another impulse, I started reading a Smalltalk tutorial for Java developers.
Out of respect for tradition, one of the first things I did was the “Goodbye Cruel World” program:
Transcript show:’Goodbye, cruel world!’
Transcript cr.
Then I moved on to simple message sending:
2 raisedTo:128.
Nothing. It took me a few minutes to realize that I had to print the stupid thing out.
Transcript show:(2 raisedTo:128).
That’s better.
I knew I’d need to compile the Smalltalk I learned into Java or an equivalent for it to make sense to me. Now, is this why I can never pick up a foreign language, like Spanish? Maybe.
System.out.println(new Number(2).raisedTo(new Number(128)));
OK, I can already see why it is called Smalltalk.
I jumped to code blocks, forgoing the usual examples on math.
f := [:x | x + 1].
Transcript show:(f value:3).
Cool. In Java, this would be hairy:
interface CodeBlock { public Object run(Object args[]); }
CodeBlock f = new CodeBlock() {
public Object run(Object[] args)
{
return (int)args[0] + 1;
}
};
System.out.println(f.run(3));
This isn’t even totally equivalent because of Smalltalk’s support for closures. But it is close enough for learning.
Next I jumped to what initially scared me away from Smalltalk: if statements and loops. I already knew that there were no such built-in keywords in Smalltalk for such constructs. They were messages sent to objects. This is hardcore.
|i|
i:=5.
[i >0] whileTrue:
[
Transcript show: ((i*2) asString) ; cr.
i:=i-1.
].
As I understand it:
public static int i = 5; // pretend this is global
new BooleanExpression(new CodeBlock() {
public Object run(Object[] args)
{
return i > 0;
}
}).whileTrue(new CodeBlock() {
public Object run(Object[] args)
{
System.out.println(i*2);
i–;
}
});
Now that was a mouthful.
Finally, I got to classes, and this really made me realize that I wasn’t in Kansas anymore. Classes surely are defined in some special way right?
WRONG. Classes are defined by asking Object to create a subclass by sending a message to it:
Object subclass: #GeneralEquipment
instanceVariableNames: ‘description serialNumber eid lifecycleStatus’
classVariableNames: ”
poolDictionaries: ”
category: ‘Equipment’.
Then to define methods, you send more messages, with un-compiled code as arguments:
GeneralEquipment
compile: ‘whatIsYourId ^eid’;
compile: ‘idIs:newId eid := newId’;
compile: ‘moveTo:aRoom at:someTime eid := 122′.
I later found out the relatively user-friendly Squeak way of defining a class, but seeing the behind the scenes way really drove it home. I won’t even attempt an equivalent Java expression.
Everything is either an object or a message. No kidding.
I will try to give future code examples in Smalltalk, if possible. I’m still getting used to the Squeak environment, especially projects, images, and the best way to save Smalltalk source files. I had an interesting fight with Vista when I first tried to save my doodles.
One question I’m already thinking about: all methods are public in Smalltalk. There is no such thing, then, as package design. That, folks, is the question, and the betting windows are open on which answer over which I will obsess.
![]() |
Announcer: You’re reading the EIP web-ring. |

January 28, 2009 at 10:18 pm
Well, technically, but they serve different purposes. Visual Basic has always been aimed at non-programmers, while C# is a serious language.
January 28, 2009 at 10:29 pm
True, and I probably wasn’t even completely accurate by saying “anything.” I don’t know if VB.NET lets you write unsafe code.
February 3, 2009 at 3:28 am
Welcome to the rest of your life! I’m glad that my posting on Self helped you along. Did you look at my other posts tagged with Smalltalk? One of them (http://peripateticaxiom.blogspot.com/2007/01/its-alive-flash-of-lightning-crash-of.html) addresses in passing your concern about the best way to save Smalltalk “source files”: don’t do that.
Persist changes in your image to a repository. Monticello is a good place to start. If you start thinking that way then a big part of the magic of the Smalltalk environment will be revealed to you. You don’t write programs in Smalltalk so much as you have an on-going conversation with a long-lived object graph.
February 3, 2009 at 8:20 pm
How would checking an image in and out of a repository work in a team environment?
February 4, 2009 at 3:27 am
Checking an image in and out wouldn’t, so we don’t do that. What is shared is changes to the image. The Smalltalk way is that your image is versioned locally and at a very fine grained level, you should be able to obtain a full history of each individual method. From time to time you send a synoptic change list to a repository. Others who want to bring their image in line with yours import those changes.
Smalltalkers have been doing that distributed version control thing (not to mention continuous integration) that the cool kids are so exited about these days for decades.
Pro tip: export your “good” changes frequently even if you are working alone. Then start each day with a fresh image into which you import all the changes up until the end of your last session.