From: Dennis Decker Jensen Date: 2001-03-03T22:42:50+09:00 Subject: [ruby-talk:11935] SV: Smalltalk idioms / patterns and Ruby Guerry A. Semones wrote: > I recently obtained a copy of Kent Beck's "Smalltalk Best Practice > Patterns". I am not a Smalltalker (yet), but was intending to read > the book seeking generally applicable ideas (right now my primary > focus is Java and Ruby). I know from talking with others that my > effort will not be in vain. I've got a copy of it at my desk at home. Just like the GoF-book, it will follow me the rest of my programming days :-) Before I started dating Ruby, I also made plans to learn SmallTalk (Squeak looks very interesting). I fell in love with Ruby however, so my primary focus is on Ruby right now as well. Regarding Kent Beck's SmallTalk Best Practice Patterns (SBPP), I consider it applicable not only to SmallTalk, but to ALL programming languages. The patterns are simple (style guide kinds), but with very powerful concepts at the everyday level of programming unlike many other style guides. In short: I find them just as invaluable as the patterns in the GoF-book to be a good developer. > However, I was curious if others have read the book, and seeing as > there are some intentional similarities between Ruby and Smalltalk, > did they see common idioms and practice patterns that the languages > share? To answer your question in short: Yes. The similarities are intentional. ALL of the patterns/idioms in SBPP can be mapped directly to be used in Ruby - except for the little part on format style. You don't even need to tweak them very much! Some of them can be done in a lot more ways in Ruby than in SmallTalk. There is not much you could do in SmallTalk, that you couldn't do in Ruby (if any?) almost in the same way and other ways as well. I'm still a newbie, so I haven't noticed many differences yet, but these are the few I've found: 1) The first difference I noticed almost immediately was, that Ruby hasn't a rich set of different kinds of Collections, but takes a rather simple approach with only two kinds: Array and Hash (similar to OrderedCollection and Dictionary). Integrated with the rest of Ruby's constructs they become very powerful though. It's very easy to construct more advanced data structures based on Array and Hash in Ruby (trees, heaps, etc.). 2) Ruby's Built-In Modules/Classes and Standard Library is much smaller than SmallTalk's equavalent image. Ruby is a new language but growing fast. Many things can be found in the Ruby Application Archive (RAA). 3) Format style is very different: Ruby takes on the pragmatic approach and uses more conventional constructs - while staying faithful to the OO. This actually supports its readability (for western readers at least). As for format styles I find the style in the pick-axe book and the code-snippets given by David Thomas and others (I'm sorry I can't remember all your names) in this mailing list to be exemplary. You will find comparisons on Ruby and other languages, such as Perl, SmallTalk, Python, etc. and the RAA at www.ruby-lang.org Dennis Decker Jensen