Python vs Ruby

Niklas Frykholm r2d2 at mao.acc.umu.se
Mon Jan 29 04:19:09 EST 2001


>> #  Ruby is often faster than Python.
>> That I would not believe without proof.

>Some time ago I tested Ruby vs Python:
>I made a program that calculates a fibonacci numbers.
>Python was as double as fast (Win95). Maybe that is because
>in Ruby a number is a class, in Python not.

My experience is similar. I recently implemented a program in both languages
using the same algorithms. The Python program ran in 4s, while the Ruby
program took 10s. It was a mathematical program so it was quite heavy on
number-crunching and function calls.

RUBY'S WINNING POINTS (IMHO)

    - Nicer class structure. Everything can be subclassed. You do not have
      to worry about whether something is a function or a method.

    - Iterators beat list comprehension.

    - Singleton classes are nice.

    - No "magic names" for operators (__add__). No "magic naming conventions"
      for private methods.

    - "#{k+1}" beats "%i" % (k+1)


PYTHON'S WINNING POINTS (IMHO)

    - Python's print is more pragmatic.

    - Less Perl pollution -- no magic variables.

    - Parser does not choke on programs with unusual spacing. The error
      messages are usually better.

    - Excellent documentation (you don't have to learn Japanese).

    - Batteries included -- much better standard libraries.


AND I WISH THEY WOULD BOTH STOP DOING

    - Automatic promotion of integers to floats...


I'll probably keep using both languages.

// Niklas



More information about the Python-list mailing list