The following is an email I got in the last year:
I like much of what you write on zenspider.com.
I’m about to take on a new programming language. Concurrently, I’m about to take on a new ‘greenfield’ development project. I’m torn between Ruby and Python. Frankly, aside from the obvious syntactical differences, they look a lot alike. Ruby looks a little ‘cleaner’. Python has better IDEs available. (I like Komodo a lot.)
In addition to simply learning a new language, I’m interested in being productive. Do you still favor Ruby over Python? If so, why? If not, why not?
Here is my response:
I do still favor ruby over python. I’m an old school OO guy and ruby was built from the ground up w/ objects in mind. Both perl and python tacked it on later more as an afterthought and it feels like it. The class libraries for ruby are clean and full. I can get a lot done right out of the box, yet because it is a real class library, I know where to look for something rather than digging through a 300+ function list.
I use emacs and it works equally well for both languages. I don’t really do IDE’s unless coding for mac os x, so I can’t help you there too much. I will say that when I was coding in python there was only one book really worth using (the new rider’s python book, forget the name but it is probably on my nerd book list online) and few tools to help. Ruby has the excellent pickaxe book (one of the best language books I’ve read hands down. It maintains a good balance between tutorial and reference, newb and advanced. Ruby also has good tools to help you along: irb is the equivalent of running python w/ no args, a basic REPL; ri is a lovely documentation reference tool like perldoc. I don’t remember one existing for python.
Finally, it just makes more sense to me and the way my brain works. I don’t struggle w/ ruby at all. I can get a LOT done in perl and python, but it is more work to do so. With ruby it is easy and a joy, and the code stays maintainable over time.
For example, join and split operations, in 3 languages:
Ruby: Perl: Python: >> s="a:b:c" $s="a:b:c" >>> s="a:b:c" => "a:b:c" >> a=s.split(":") @a=split(/:/, $s) >>> a=s.split(":") >>> a => ["a", "b", "c"] ['a', 'b', 'c'] >> a.join(", ") print join(", ", @a) >>> ", ".join(a) => "a, b, c" a, b, c 'a, b, c'
From an imperative language perspective, it makes sense to me that perl has a function that takes a regex and a string to split and a string with an array to join. That is just ingrained over the years.
From an OO perspective (in ruby’s case), it makes total sense to me that you split a string and get an array and you join an array using a string. It even looks transitive.
But in python’s case? While split makes sense, they saw fit to put the join on the string function? (and deprecate it, as I just noticed… not sure what it is being replaced with, as the doco doesn’t say anything about the deprecation–another complaint of mine about python–suck doco). That makes no sense to me and it makes me go looking for it every time I need it. Languages are complicated enough these days, they should work with me, not against me. Ruby works with me. Python doesn’t.