In 2021 I learned Smalltalk, mostly using the lovely Pharo implementation. While the syntax of the language is quite nice, its real magic is in the image based virtual machine which includes the full IDE, debugger, compiler, and your running program state. In the past year it has become my favorite way to program.
Deciding on Smalltalk
I don’t usually bother with new years resolutions. My brain isn’t wired that way and it doesn’t motivate me. Instead I try to deep dive into some tech that I’d like to understand better (or at all).
In 2021, I decided to pick up a programming language. I looked at a number of “different” languages. I recall Haskell, Julia, and a few others. Being a seasoned developer, something like Kotlin was not super interesting to me, as it didn’t offer a different way of looking at the world. The same for Rust and Go, which were also considered.
You can probably guess by now that I landed on Smalltalk. I’ll go ahead and spoil the ending as well: In under a year it has become my favorite language. For context, I’ve been coding for almost 30 years, over 20 of those for a paycheck. I’ve loved a lot of languages, but none as much as this.
A Quick Look
At this point, you’d be expecting to see some code snippets showing off why the language is so awesome. I’ll post the classic “postcard” example which shows off every aspect of Smalltalk’s light syntax:
exampleWithNumber: x "A method that illustrates every part of Smalltalk method syntax except primitives. It has unary, binary, and keyboard messages, declares arguments and temporaries, accesses a global variable (but not an instance variable), uses literals (array, character, symbol, string, integer, float), uses the pseudo variables true, false, nil, self, and super, and has sequence, assignment, return and cascade. It has both zero argument and one argument blocks." | y | true & false not & (nil isNil) ifFalse: [self halt]. y := self size + super size. #($a #a "a" 1 1.0) do: [ :each | Transcript show: (each class name); show: ' ']. ^x < y
This is where I ran into my first hurdle when learning the language. That example is really not that cool. Sure I like a minimal syntax, but having played around with Lisp and Forth, this was nothing new. If you know Ruby, things already look familiar. Smalltalk inspired a lot of Ruby’s features and syntax.
What makes Smalltalk stand out?
The real secret sauce is in the image. Smalltalk has a virtual machine which allows you to execute your code on any platform where the VM can run. The image however is not only all your code, but the entire Smalltalk system, including said virtual machine (because of course it’s written in itself).
Again, VMs are nothing new; but Smalltalk image is unlike a collection of Java class files in that it can store your programs (both source and compiled bytecode), their data, and execution state. You can quit and save your work while some code is executing, move your image to an entirely different machine, load your image… and your program picks up where it left off.
Speaking of working on a running program; That’s often how you work here, on programs while they are executing. You can run code which calls methods that don’t even exist and create them when the exception is thrown. Resume the program and it will be happy to continue with your newly created method as if it were always there.
I find that this allows me to work differently than I do in other languages. You have to think about the actual code less than you do the problem at hand. If feels like you build the environment to match the problem, not figure out how to describe your problem on the terms of your language.
I feel like it took me a bit longer to fully understand how to work in Smalltalk than it did most languages. The IDE is different than anything I’ve used before, and probably anything you’ve seen as well. You’re not going to be opening myscript.st in your favorite text editor, and then run it from the command line as you would a Python program. It takes a little mental adjustment to start with.
That’s not the warning, however.
The warning is that once you delve into Smalltalk, you might not want to program in anything else ever again. It’s really that good.
If you are interested in learning more: