Home > Programming > Ruby post-Python: first impressions

Ruby post-Python: first impressions

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:

  • One of the things that always bugged me about Python is its lack of proper lambdas. Sure, you can use a locally defined function instead, but it doesn’t give you the kind of fluency you can achieve programming in Scheme or JavaScript, say. I haven’t done much Ruby yet, but it seems there are various ways to do lambdas/closure, in a more flexible way than Python. This wouldn’t have mattered to me, but since I’ve been working through SICP and using JavaScript more, I’ve been thinking in closures.

  • 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!

  • 0 as a truthy value – not sure about this. Although I suppose it’s clearer to say if count > 0 rather than if count.

  • elsif instead of elif. That’s going to cause me a lot of typos.

Categories: Programming Tags: , ,
  1. July 31st, 2010 at 21:45 | #2

    Hi Bastien, thanks. Yes, that does make sense.

  1. October 18th, 2010 at 14:21 | #1

Comments parsed as Markdown.