I’ve been using Python for a while and really like it. I’d heard a lot of good stuff about Ruby so decided to have a go to see what all the fuss was about. The list of differences between Python and Ruby on ruby-lang.org was useful in writing this post. Here are my first impressions:
This doesn’t really set it apart from Python, but it does seem to have good consistent coding conventions, which I think are important for a language. And I like the fact that capitalised class names and lowercase variables are enforced by the language.
I used to think it sounded dangerous, but I like the fact that parentheses are optional for function calls. I can see how this can make Ruby a very expressive language.
I’ve never understood why in Python objects have a
__len__()method, but the standard way is to use the
len()function to access it. Why not treat objects like objects and use method calls?
One type of array, not lists and tuples. Minor headache resolved!
Parsed and unparsed strings like in PHP, making use of the distinction between single and double quotes. Useful.
Private methods – thank you!
0as a truthy value – not sure about this. Although I suppose it’s clearer to say
if count > 0rather than
elif. That’s going to cause me a lot of typos.