Let me start out by saying I love Ruby. I've bounced around plenty of languages, and picked up a little love for each. I was a little resistant to pick up Ruby as Rails was busing on to the scene, mostly because of the Too-Good-To-Be-True hype. And, as we all have learned, when something gets such hype, it usually turns out to be not too far from the truth.
The end and beginning of the previous paragraph should conflict enough for the reader to sort out the intermediate steps without a long winded story. Below is the first little helper class I wrote in Ruby. Never mind that it's named Czaja. It's a bit terse and obtuse, but see if you can figure out its function before reading further.
class Czaja
attr_reader :czaja_data, :obj
def initialize(obj=nil, opts={})
@czaja_data = {}
@obj = obj
end
def method_missing(name, *args)
if @obj && (@obj.respond_to? name)
return @obj.send(name, *args)
end
if name.to_s[-1..-1] == '='
@czaja_data[name.to_s[0..-2].to_sym] = args.first
else
return @czaja_data[name]
end
end
end
Copy/PasteIts function is to tack variables to objects for you. I had to write a report that gave a list of users a score, so the code looks like (User does not have a score method):
user = Czaja.new( User.find(id) )
user.score = scoring_method_for_this_report( user )
...
@users.sort{|a,b| a.score <=> b.score }
Copy/PasteThen, in the view, it was as easy as:
<%= user.name %> got a <%= user.score %>!
This is what made me fall in love with Ruby. You may note how this resembles a horrible, horrible hack, and could be used for great evil, but you haven't seen all of the Czaja code. Its over twice as long in reality. The rest of the code is there to throw errors if it even thinks you're doing something gross.
But I digress. After learning such flexibility, I thought my heart would never love a language again. Then along comes someone else...someone...older. Yes, I know. I'm in tight with a young, popular one, but these days, I have eyes for the bag lady. I speak, of course, of Objective C.

Everyone pimps this book. I am now on said list. Trust me, it's amazing. On with the list. I'll try to be brief, as not not cause some kind of BanterOverflowException.
Duck Typing
Okay, this isn't earth-shattering, but it was the first glance-from-across-the-room. Here I have a language that looks an awful lot like C, and it's letting me do a bit of reflection. It has this
@selectormethod I can fiddle with that lets me send messages to objects. Pretty neat. I wasn't able to quickly find a reference to verify that Objective C is actually duck typed, but in the spirit of looks-like-a/acts-like-a, I'm going to declare it so.method_missingFunctionalityIn the example with the
Czajaobject, it was the discovery of themethod_missingfunctionality built in to the language that really made it possible and clean to use. Behold:@implementation Czaja -(void)forwardInvocation:(NSInvocation *)invocation { NSLog( @"We need to hone our Objective C chops to use %@!", invocation); } @end
This is very, very good news.
Generic Programming
So, I have yet to see how I can pull the old
echo "Fool with other people's classes" | sed "s/classes/objects"tom-foolery (via something likeinstance_eval), but in Objective C, you can fool around with classes defined elsewhere. It is essentially a dynamic language, so this is expected. But the beautiful thing about being generic in Objective C, is that you only have to be when you need it. If I have an array ofUsers, I can just say so. If I want to start getting really clever, that option's there as well. It's strongly typed when I need it, and dynamic when I need it to be.Is that a strong or coherent point? Certainly not. Do I like it? Of course.
