How does GNU Smalltalk compare to Python or Ruby?

Tagged:

Both Python and Ruby are object oriented languages meant to provide a smooth transition from procedural to OO programming styles. Smalltalk, by contrast, is object only—you can't do anything serious without understanding objects and inheritance. By providing procedural training wheels, Python and Ruby meant to ‘fix’ one of the features that may have kept Smalltalk out of the mainstream.

However, it is actually not clear whether this is true, because the two families of scripting and object-oriented languages were strongly separated until recently. On one hand, object-oriented programming skills are (luckily) widespread nowadays, but were not when Perl and other scripting languages were introduced. On the other hand, the idea of powerful scripting languages merging advanced features (such functional and object-oriented programming) and emphasizing rapid prototyping was nowhere in sight when Smalltalk was created. In fact, most Smalltalk environments are not designed with scripting in mind.

Smalltalk (and GNU Smalltalk in particular) is much more similar to Ruby than it is to Python. Both are pure OO languages, though Ruby can masquerade as a procedural one; both have no functions, only method calls. Both have always had many features that were only recently retrofitted in Python: a unified type/class hierarchy, metaclasses, the ability to subclass everything, uniform method invocation, transparent arithmetic on large integers, and a powerful set of collection classes and iterators.

Like Python, and unlike Ruby, GNU Smalltalk's syntax and design philosophy are meant to have as few as possible syntactic variabilities. Shortly put, it was not influenced by Perl. No optional syntax elements (including keywords, since Smalltalk has only a couple of operators and five reserved variables—the only keyword could be said to be super). This also means a little fewer commodities (here documents, for example), but in general means cleaner code.

If you like Perl, you will like Ruby and be right at home with its syntax. If you like Python, you may like Smalltalk more than Ruby and be right at home with its semantics.

Nice article. Could you tell a little bit what differs GNU Smalltalk from the original Smalltalk maybe?

"If you like Perl, you will like Ruby and be right at home with its syntax. If you like Python, you may like Smalltalk more than Ruby and be right at home with its semantics."

I think such statements are silly and are somewhat trivial as a programmer will coop with most syntaxes. This (as I see it) comes down to pure psychology and how positive and motivated your are to learn a new language. :) Basically you only risk that people inherit the statement without even bothering to try the language.

See another FAQ about the differences that GNU Smalltalk introduces.

I agree that most syntaxes are equivalent. However, the sentence you quoted is more related to the design of the language.

For example, the way blocks work in Ruby (you can pass it as a do ... end block or as a variable preceded by an ampersand; you can call it with yield or again by declaring a parameter preceded by an ampersand) is definitely a hack. It does produce very nice, succinct code -- but it is probably viewed as a useless complication by most Smalltalk (or Python, for that matter) programmers. Neither Smalltalk nor Python have a syntax like this. A block (a lambda in Python) is an object that you can pass just like every other object.

User login