Friday, November 2, 2007

RubyConf 2007: Advanced Ruby Class Design

Jim Weirich, creator of Rake, starts his talk asking the room about a few languages. When he mentions lisp, a small contingent, in my corner of the room, erupts in hoots and applause. "Yes, these are your father's parentheses".

"A real programmer can write Fortran code in any language". He then queries the audience for how many people came to Ruby from Java (a fair amount). Some concepts will transfer over, like OO and loose coupling. Bringing other concepts over would limit you to the java way of thinking. There are some things in ruby that are inconceivable in other languages.

Examples that were used:
  • Rake::FileList
  • Builder::XmlMarkup
  • Dynamic Expressions
He goes through the evolution of these different bits of code and how they were made better through features of ruby classes.

The Dynamic Expressions example is about building SQL for ActiveRecord from objects, instead of specifying SQL in find statements. He would like to use select for this. In the first cut, he pulls all records from the database, and then uses select on it (Laughter erupts). "Premature optimization is the root of all evil" (quote from Donald Knuth). It improves as the slides pass, but he says that this example isn't realistically usable. He suggests taking a look at Amibtion.

Unusual solutions are sometimes needed, but not all the time.

No comments: