[Tutor] Ruby Code Blocks vs. Python Lambdas

Kent Johnson kent37 at tds.net
Tue Nov 7 11:53:57 CET 2006


Carroll, Barry wrote:

> Thank you for this post.  I was in a discussion of Ruby vs. Python at
> lunch today.  The consensus was that Python was much better than Ruby in
> all ways.  Since I know very little about Ruby, I had nothing to add to
> the conversation.  

Sounds like you had a table full of Pythonistas.

I barely know any Ruby but I think there are a few areas where it has 
advantages over Python.

- Ruby blocks are much more powerful than Python lambdas and they are 
integrated pervasively into the language. They also allow interaction 
between the block and the container that I don't think you can do in 
Python, I don't understand it well enough to know. (Maybe the new 
generator features of Python 2.5 allow something comparable.)

- Metaprogramming (modifying classes on the fly) seems to be much easier 
in Ruby than in Python. Interestingly, in the Ruby community this is 
considered a powerful feature and used frequently, whereas the Python 
community tends to think of it as a last resort.

- Ruby is very good at creating domain-specific mini-languages. This is 
a consequence of the easy metaprogramming and optional parentheses on 
function calls. Take a look at a Ruby on Rails tutorial to see what I mean.

Kent



More information about the Tutor mailing list