Languages

  Mar 17, 2004

Due to the delicious Why's Poignant Guide To Ruby, I've been looking at Ruby quite a bit. What I love the most about it is the fact that it's really really object oriented. What I don't like about it is the fact that it isn't Python.

I'm a newbie to both Python and Ruby, so I can't say how the different aspects of the respective languages feel for someone who uses either of them on a daily basis. What I don't understand though, is how anyone can say Ruby is particularly easy to read. I mean, compared to what, Hebrew?

Compared to Perl, perhaps, but I find Python many times easier to read than I do Ruby. Rubyists also seem to stress that Ruby relieves you of unnecessary typing, which I can't say I understand, what with all the "begin", "end", "then" and "do", and so forth.

Not that Python is the Holy Grail of languages or anything, or perhaps it is, but it certainly isn't perfect. What I don't like about Python is that the OOP aspect of it seems like an afterthought, whereas Ruby's OOP permeats the whole language, far more so than other OOP languages like Java, C# and, well, Python.

I can only think of two reasons why Python is preferable over Ruby: 1. It's more readable, and 2. the Python community (i.e. available libraries) is larger and thereby more mature and developed. These two aspects are about the only things I think Python has going for itself compared to Ruby, which has several advantages over Python, basically all of them related to better OOP.

While it's possible to learn and use both Ruby and Python simultaneously, I'm not obsessive about either of them so I'll probably just focus on learning one properly and just develop an understanding for the other.

I'm pretty sure I'm going to focus on Python. Its readability, and perhaps something else about it, makes it feel more natural to me than Ruby does. Which do you prefer, if any, and why?

Permanent link

Comments

  1. I won't say anything about ruby, since I know nothing about it. But I will say a few things about Python, since I use it regularly.

    The main thing about Python which I like, besides the easy-to-read syntax mentioned by you, is the speed at which one can develop things. With the rich amount of modules availible, there's a good chance that you can write a script doing exactly what you want faster than you had predicted yourself. I often find myself prototyping applications in Python, before writing in C/C++. Nowadays though, if I develop some app for the Windows platform, I tend to use C# instead.

    Python is my preferred scripting language because of that very reason, the speed at which I can come up with a finished program. I use it pretty much anywhere I can find a use for it. Most often it's shell scripts.

    I don't quite understand what you mean about your OOP statement though, about it seeming more like an afterthought in Python.

    Comment by Marcus Stade at 14:23, 19 Mar, 2004 #

  2. Marcus: What I meant by that is hard to explain (in so many words, at least), but easy to understand if one takes a look at a language which is completely OOP, like Ruby. You don't have to learn it or use it, just check it out. You could also just look for "Ruby vs. Python" articles, which often summarize the differences well.

    Comment by Tomas at 18:39, 19 Mar, 2004 #

  3. well, actually you don't need 'then' in ruby ;)

    And you have to write 'end' cause everything is an expression and thus can be concatenated.
    (Yes, you can actually write
    return (class M; end.superclass)
    even if it's awful and useless)

    BTW you have to write useless stuff in python too, like the ':' after each method (no, it does not help the parser).

    Anyway, both are wonderful languages, too bad that the features I love in python (first class functions and __call__) is not compatible with the one in ruby (method call without parenteses)

    Comment by gabriele at 20:36, 24 Mar, 2004 #

The discussion has been closed on this entry. Thanks to everybody who participated.