Python versus Ruby. Best comparison ever.

I was googling for DRb alternatives in Python (I found pyro and dopy, but decided on pyro as it has an Ubuntu package), and came across this excellent post. Check it out, but this is the jam of the toast:

To me, from a practical programming perspective (say that 10 times
fast), Python and Ruby are *very* similar. Obvious differences are of
course, things like the indentation thing; Ruby feeling more like
object-orientated stuff was baked in rather than added on; Python being
a little faster, etc.

I went back and forth trying to decide. What finally sold me on Ruby
was a feature that I had little use for until Hal Fulton helped the
light bulb to go on above my head. Blocks! More specifically, blocks
used as closures.

Hal convinced me to rewrite KirbyBase and allow the user to specify
query syntax using blocks. When I finally figured out how easy it was
to add this functionality and how much power it gave the user to specify
queries, I was sold.

What really put me over the top was when I recently went back and
rewrote the Python version of KirbyBase and tried to duplicate all of
the functionality of the new Ruby version. Python doesn’t have blocks.
It has lambda, but it is pretty crippled. In Python, a lambda can only
be one expression and you can’t do assignment in a lambda. What’s
worse, Guido doesn’t even like lambda and he is planning on removing it
from the language.

Now, you can still do closures in Python by actually passing a named
function, but using blocks is just so much more elegant.

Before this, I had *used* blocks for things like #collect and #each.
But it was only when I started having my own user-defined methods accept
and use blocks that I really started to understand how powerful they
make Ruby.

Anyway, sorry for the long post. To make a long story short, I chose
Ruby. I still program in Python on the side. I’m hoping to soon
release a Python version of KirbyBase that is equivalent to the Ruby
version. But, without those blocks, it’s just not as much fun (although
list comprehensions are cool!). Hope this helps answer your question.

Jamey Cribbs

Acerca de Buanzo

Io que se!
Esta entrada ha sido publicada en General y etiquetada como , . Guarda el enlace permanente.

4 respuestas a Python versus Ruby. Best comparison ever.

  1. roger dijo:

    Ruby blocks make it fun. Python’s psyco makes it fast. Ugh.

  2. James dijo:

    good to also see this article that python is on the rise.

  3. It is great to hear that you are working again on the Python version (1.9). I use your product to do db lookups and to be honest nothing I have found is as easy to use as your KirbyBase!

    I simply don’t need the relational features/security/overhead.

    I have tried it on Python 3.1 and the very first thing that broke it was the backquotes on the return for the value:

    def __str__(self):
    return `self.value`

    Just thought I would see if I could show you what I noticed.

    Thank you for making the best simple flat file db handler out there. Take care, and I will look forward to seeing
    what comes.

    Douglas W. Sullivan
    [email protected]

  4. Juan Garcia dijo:

    I develop applications that must be used in languages other than English. I have to use Python instead of Ruby because Ruby has no Unicode support.

Los comentarios están cerrados.