Python v Ruby

Although I have not read this comparison paper[pdf] in detail, I found looking at their example code side-by-side to be most illuminating. Ruby’s pureness (mainly in object-orientation) may give it a theoretically superior (“cleaner”) syntax, but from a practitioner’s point of view, the Python’s syntax appears to be refreshingly uncluntered and easy to use. Whether you come from an imperative or functional background, Python appears familiar—and with computing, conquering the fear of the unknown is half the battle!

An example:

Ruby Python

p = proc do |x|
       print "Hello ",x ,"\n" 
    end 
p.call "Fred!"

p = lambda x:
         print "Hello ", x
p("Fred!")

Ruby’s pure object syntax leads to the ugly p.call ... while Python’s p("...") looks pleasing to the imperative and functional camps. Object-orientation is a great paradigm, but as anyone who has tried to “knock-up” a quick program in Java will know, trying to shoe horn objects into a small program is a waste of effort.

The paper concludes:

Overall there is not much different between Ruby and Python, though Ruby offers some cleaner syntax due to its object oriented model. […] The disadvantage of Ruby is the fact that it is very poorly documented. Our advice is that you choose Ruby, if you are new to both the languages, otherwise weigh the option of continuing with language you are using.

So, in other words, Ruby has little to offer over Python except its theoretically purer syntax, and at the same time it is poorly documented which is likely to mean that the learning curve is a steep and painful climb. My advice: choose Python [1].

[1] This discussion has been entirely free of Rails. I haven’t used it and the paper I am responding to here doesn’t mention it—but I hear it’s a strong contender in the web app arena.