How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python?

Joe Mason joe at notcharles.ca
Wed Feb 25 06:28:14 CET 2004


In article <c1h1sb$1it26i$1 at ID-169208.news.uni-berlin.de>, Greg Ewing (using news.cis.dfn.de) wrote:
> * Ruby makes heavy use of passing code blocks around as
> parameters, to implement iteration constructs and so forth.
> Ruby is very much like Smalltalk in this respect. Python
> uses a different mechanism (the iteration protocol) to achieve
> these things. Python's way is both more and less powerful
> than Ruby's. Ruby makes it easy to define new control
> structures which look just like the built-in ones, which
> you can't do with Python. On the other hand, Python has
> its amazingly powerful generators, for which there is no
> direct equivalent in Ruby.

Not built in, but you can implement them in Ruby using continuations
pretty easily.  See http://www.rubygarden.org/ruby?RubyFromPython for an
example.  The only problem I can see is maybe performance issues, but
the performance characteristics of the languages are pretty different
apart from that, I'd assume.

> * In Python, functions are first-class, and
> methods are implemented in terms of functions. In Ruby,
> methods are the fundamental concept, and there are no
> first-class functions. The result is that Python lets
> you obtain a bound method from an object and use it like
> any other function. You can't do that in Ruby. You can
> get a method object in Ruby, but you can't call it using
> normal calling syntax.

I don't see the distinction.  "normal calling syntax" in ruby involves
an object, so "unbound function" isn't a meaningful concept.  I mean, if
you get a method the begins with the self parameter, you still need an
object to call it, right?  Even if you're calling it as "foo(obj,
params)" instead of "obj.foo(params)".  I don't see what the ability to
use the other syntax gets you, except the ability to pass functions
around independantly of objects, which I'm pretty sure you can do with
methods in Ruby anyway.

Joe



More information about the Python-list mailing list