| « Apple Aluminum Keyboard Firmware Update 1.0 Fixes Control Key | I hate parsers » |
The biggest reason I don’t use Ruby is that it’s hard to learn real functional programming. There are two reasons: first, it’s a Lisp-2 with redundant and messed up scope rules (because of blocks), and second, the culture is more strongly OOP and people don’t do a lot of functional programming. The second reason is more important, of course, because it makes it hard to find good examples online.
Of course once you know a language well, it’s easy enough to shoehorn in whatever style you like, but Python and Ruby are so similar that my only reason for switching would be a substantial increase in elegance or else having to use something Ruby-specific, like Rails. Given that the comp ling group at IU uses mostly Python and C++, the latter is not likely to happen. And Ruby is marginally more elegant, but not enough to make it worth the pain of figuring out how to do functional programming in it.
But! Just in case, here is a set of pointers to Raganwald’s writing on functional programming in Ruby. Here is probably the most important piece of code up front:
class Symbol
# Turns the symbol into a simple proc, which is especially useful for enumerations.
def to_proc
Proc.new { |*args| args.shift.__send__(self, *args) }
end
end
# use like this:
(1..100).inject(&:+)
So even though you have to quote your methods, you don’t have to lambda-lift them because of the blocks=syntax design. Still a Lisp-2, but probably easy to remember when you need to quote than in Common Lisp. I can’t this to work with functions (methods on the global object or whatever they are in Ruby), but I guess it’s probably not too hard. And you probably shouldn’t be using them much anyway. Ruby! OOP! Remember?
I probably missed some. This is a start, and if I really do need to get going in Ruby, I can come back here later and add the rest.