ProgrammingBack to Tutorials Ruby In Steel Tutorials Programming
Ruby The Smalltalk Way
In this series, I plan to examine Smalltalk and Ruby in parallel so try to see a) just how similar they really are (or aren’t?) and b) whether or not it is possible to program Ruby “in a Smalltalk style”. In this introductory article, I’ll outline some of the themes and ideas which I’ll be considering in more depth later on and I’ll give you all the links you’ll need to download software and documentation to let you follow along with me...
As I mentioned in a recent Blog post, the idea for this series came about after reading numerous comments in books, article and Blogs which take it for granted that Ruby is closely related to Smalltalk. And yet, while Smalltalk was clearly an influence on Ruby, the experience of programming in those two languages is, in my view, very, very different.
Why should that be?
On the face of it, Ruby and Smalltalk are similar languages. They are both take a fairly rigorous approach to Object Orientation and even their syntaxes more closely resemble Algol/Pascal than C/Java.
So maybe the main difference is the programming environment? In Smalltalk, the language and the environment are so tightly bound that the IDE itself (its windows and graphics) can be manipulated in Smalltalk. Ruby, on the other hand, presupposes no environment and, even when it is provided with a dedicated IDE, the Ruby language has, so to speak, no ‘built in knowledge’ of its workspace.
In Smalltalk the IDE and the language are tightly coupled. On the plus side, this makes it possible for the language to manipulate its own environment and the environment to offer unparalleled support for the language. Programming in Smalltalk is more than just editing code into an editor. It is a process of browsing the class hierarchy and modifying the classes right inside a multi-pane Hierarchy Browser. There are tools to inspect objects, find methods and locate implementers and so on. Implementations of Smalltalk (such as Dolphin Smalltalk, shown here) are built from the ground up to support that development of the language seamlessly - it’s not easy to see quite where the IDE ends and the language begins...
Ruby, on the other hand, was never built with an IDE in mind. Many Ruby programmers write code in a plain text editor and run the resulting program from a command prompt. As a result, the development experience is far removed from that of Smalltalk. Even if you use an IDE, such as Ruby In Steel, the ‘join’ between the language and the environment won’t be as seamless as in Smalltalk. On the plus side, this means that Ruby programs are more easily portable (they aren’t ‘welded into’ their own hermetically sealed programming world) and they allow you to pick your own development style (you aren’t obliged to work inside a Class Browser and move from branch to branch in order to modify an existing class hierarchy).
Fundamentals Of Smalltalk
In this series, I’ll be looking at a number of features of the ‘Smalltalk way’ of programming. For example, I’ll be considering why, in C, Pascal and most other mainstream languages, it is normal to ‘call functions’ while, in Smalltalk, you ‘send messages’. Is ‘message sending’ just another way of saying ‘method calling’? Or is there a meaningful distinction to be made between these two paradigms?
Another thing I want to consider are the class hierarchies of Ruby and Smalltalk. Ruby, in common with other OO languages such as C#, has a shallow class hierarchy - that is, there are few branches on the family trees of most classes. Is that a good thing, a bad thing or of no real consequence?
But ultimately, the important question I want to address is: given the differences in coding styles typifying Smalltalk and Ruby, is it possible to write Ruby programs in a ‘Smalltalk style’. And, if it is possible, is it desirable?
The Smalltalk Course Book
In this series, I won’t assume any previous knowledge of Smalltalk. In order to give Smalltalk newcomers some background reading material and, moreover, to provide a structure for the series itself, I’ll be constantly referring to a little tutorial which was written for a commercial Smalltalk product, Smalltalk/V. You can think of this as the ‘course text’ of the series. The Smalltalk/V tutorial provides an easy introduction to the fundamental ideas of Smalltalk Once again, the download link is at the end of this article.
In the next part of this series, we’ll be getting down to some real work with hands-on programming and sample code in both Ruby and Smalltalk. If you want to do some preparatory ‘homework’, you might like to glance through Chapter One of the Smalltalk/V Tutorial.
If you are new to Ruby, you should first make sure that Ruby is installed. You can either use Ruby with a programming editor of your choice or, if you are a Visual Studio user, you can download a copy of the SapphireSteel Ruby IDE, Ruby In Steel. You may either use our free Personal Edition, the commercial Developer Edition or the free 30-Day Developer Trial.
For a simple introduction to Ruby programming, download our free eBook, The Little Book Of Ruby, complete with all the source code of the sample programs (available for download on the same page). If you plan to follow along with the Smalltalk code too, you may want to download the free Community Edition of Dolphin Smalltalk. If you are new to Smalltalk you may want to read my Beginner’s Tutorial on Dolphin Smalltalk which should help you to become familiar with basics of the Smalltalk language and environment.
Most of Smalltalk code which I’ll provide in this series should also work with other versions of Smalltalk such as Squeak (if you use this, you may want to read my Squeak Tutorial first) or Cincom VisualWorks. However, I’ll only be testing my code with Dolphin Smalltalk, so I don’t guarantee that it will be fully compatible with other implementations.
The Smalltalk/V Tutorial [Direct Link] (the ’course book’ for this series)
This book is hosted by Stéphane Ducasse’s :: Free Online Books, and you may want to visit that page to download other useful Smalltalk books. In particular, two other books to which I shall occasionally refer in this series are: Smalltalk An Introduction to Application Development using VisualWorks by Trevor Hopkins and Bernard Horan and Smalltalk by Example: the Developer’s Guide by Alex Sharp.
The Little Book Of Ruby my free beginner’s eBook (with source code) to the Ruby language.
Beginner’s Smalltalk Tutorials (online)
Ruby In Steel