I was preparing a talk about Smalltalk for the boys and girls at Amazon when it occured to me that it’s easy to implement Smalltalk’s MethodFinder in Ruby. So, without further ado, here’s a Ruby MethodFinder. Take the red pill, dynamic Neo!
Excerpt from the article:
I use lots of different programming languages, and they all seem to have different names for the same concepts. For example, string concatenation is “+” in ruby and java, “.” in perl, “,” in smalltalk and “^” in ocaml. After a while, this starts to drive you mad. I know that I want a method which takes “foo” and “bar” and returns “foobar” but I can’t remember which incantation I need to utter today.
Smalltalk has this neat thing called the MethodFinder. It lets you find methods by providing an example. If you’ve got the string “foo”, you can ask the MethodFinder to find all the method that, when called with argument “bar” return “foobar”. This is a very useful tool. No more scrabbling around with documentation to find the name of a method which you know exists. Stay in the red-pill world, and ask the code.
Now, ruby is basically smalltalk (without lots of the k3wl bits). So we can easily build a method finder in ruby too!
Read the full article here.
4 replies on “MethodFinder for Ruby”
So, what do you think on Objective-C ? (some issues have recently been discussed on http://theocacao.com )
frankly my dear, MethodFinder kicks ass
Wow, cool! Thx for this great code snippet. It’s really great to see that there are lots of language polyglots in the Ruby community, and they are able to enhance Ruby with fidings from other cool languages like Haskell, Smalltalk, OCAML etc. I hope some of this cool stuff will make it to Ruby after some time.
Neat. I clicked around a little late in the day, and I see that the web notes there’s nothing new under the sun – Steven Grady posted MethodFinder on Ruby-talk in 2002, and that the best of breed (re)inspired by your own post would appear to be David Tran‘s.
.what?
ho, say I.