Python vs. Ruby

Martin v. Löwis martin at v.loewis.de
Tue Dec 31 09:58:09 EST 2002


Fred <fred_news at lrc.puissante.com> writes:

> My question is this -- what are the qualitative differences between
> Python and Ruby? Does Ruby has any strengths, either in the language
> itself or its available libraries, that are better than Python? Or are
> they pretty much even?

People often consider Ruby to have strengths in the language over
Python; they often give the "complete object orientation" and
"iterators" as advantages. 

For the object orientation, they usually give numbers as examples,
which have methods just like any other object. Python supporters then
argue that Python has the same properties: numbers have always been
objects in Python, and since 2.2, they also have methods. I believe
that this similarity is shallow, and that the Ruby advantage is
irrelevant: The similarity is shallow as Ruby's methods on integers
are used regularly, whereas Python's methods on integers are used
rarely. The Ruby advantage is irrelevant, however, since both
languages are equally expressive in that area, and it makes no
difference whether you write 'xrange(1,10)' or '1 to 9'.

For iterators, Python people point out that Python also has an
iterators protocol now; Ruby people then think Python has stolen it
from Ruby. The similarity of Python and Ruby is deeper: in both
languages, you now can iterator over arbitrary objects. However, Ruby
has still an advantage, by supporting code blocks as objects; in
Python, you can only use the for loop for iteration.

On the library side, I don't think Ruby has anything to offer that
Python does not provide out of the box.

> Also, on the issue of threading -- does Ruby have better support for
> threading than Python? Or are they pretty much equal?

Ruby's support is worse. If you invoke a long-running call (such as a
socket read), all other threads are blocked. Python releases the
global interpreter lock for such calls, allowing other threads to run.

Regards,
Martin



More information about the Python-list mailing list