What's TOTALLY COMPELLING about Ruby over Python?

John Roth newsgroups at jhrothjr.com
Mon Aug 18 20:11:10 EDT 2003


"Peter Hansen" <peter at engcorp.com> wrote in message
news:3F413F8C.47AAE514 at engcorp.com...
> John Roth wrote:
> >
> > "Peter Hansen" <peter at engcorp.com> wrote:
> > > What is it about code blocks that would let "save *me* a buttload of
work
> > > and make *my* life sooooo much easier"?
> >
> > It's not so much code blocks. It's that Ruby's syntax  gives you one
code
> > block for
> > free in every method call. And the Ruby library is organized so that the
> > facility
> > is useful, which Python's isn't (or at least, it isn't as useful.)
> >
> > All of the Ruby collections implement a .each method, which is
essentially
> > a version of the Visitor pattern. If I want to do something to every
element
> > in a list or a dict (or any kind of collection,) all I have to do is say
> > something
> > like (using Python syntax):
> >
> > collectObj.each(<method name>)
> >
> > In Python, that's either a lambda (which restricts what you can do with
it,)
> > or a named function (which is overkill a huge amount of the time.) And
you
> > have to worry about distinctions between functions and methods. In other
> > words, it's a mess compared to Ruby.
> >
> > Now, you can say: "We've got that with map()." Well, we've got it when
> > your inputs are either lists (or implement the correct protocol) but the
> > result is a list, it's not an internal modification to the object's
state.
> >
> > You can also say: we can do that with for. Well, duh. For is a
> > statement, not a method call.
>
> So what you seem to be saying is that Ruby has some features which
> in some cases can save some time or somewhat simplify code that when
> written in Python would take slightly longer or be slightly more
> complicated.  (This probably underemphasizes the value you place on
> such a thing, but I think that's the gist of it.)
>
> While I do acknowledge that Python is often touted as a great solution
> over other languages just because it saves time and simplifies the
> resulting solutions, I'm not clear on why these few small differences
> would amount to a *TOTALLY COMPELLING* reason, to anyone, to use Ruby
> over Python.

I don't know either. I do know of several posters on the XP
lists, however, who have switched from Python to Ruby, and
I doubt that it was corporate pressure in any of their cases.

If you're interested (which most of the posters here are not -
I'm certainly not) you might check with them. I'm sure Phlip, for
one, would be more than happy to say why he switched, and what
made the difference.

John Roth
>
> -Peter






More information about the Python-list mailing list