Couple of things I really like about Ruby

I guess it is too early to write any more systematic opinion about the language you know less than 10 days, but after reading the Programming Ruby 2nd edition (thank you, Safari Books) I have found out that I actually do like couple of Ruby features a lot. Your mileage may vary – what speaks here is my Java/C#/C++/C/Python/Perl background and bias. Here there are my favorite Ruby-isms (so far) in no particular order:

– expressive power of the language – few lines can take you a long way
– syntax that is nice and readable, with curly brackets allowed (but not required) and without names like __something__
– classes and OOP are organic part of the language, not a hack on top of it – everything is a class
– no need to explicitly declare self in each function or bless references
– reflection which is so easy that it is almost funny – 1.class.methods – how many lines would that be in Java ? 🙂
– access level control that works, not underscore naming hacks
– text processing power of Perl, without most of cryptic Perl features
– right middle point between language style dictatorship of Python and anarchy of Perl
– ability to send messages, not call methods 🙂 – reminds me of Smalltalk and Objective-C
– almost everything I loved about Lisp is available again …
– multiple inheritance functionality without multiple inheritance mess – mixin’s are fantastic
– gem installer – it just works
– documentation and unit tests are part of the system, not optional afterthought

I have not really reached critical mass of Ruby lines written or read and have not looked into Rails framework everybody is crazy about. As a strange coincidence, on today’s Mac User’s group meeting Tobias Lütke did a presentation on their product Shopify, written in – surprise surprise – Ruby on Rails. Once again – I wish I had more time …

Advertisements

3 Responses to Couple of things I really like about Ruby

  1. natebkirby says:

    Very interesting post, I agree with it but I have one question:

    Can you please quantify the comment “almost everything I loved about Lisp is available again “?

    Thanks,
    Nate

  2. Miro says:

    What Ruby has from Lisp are equivalents of very elegant functions operating on lists (e.g. mapcar, mapcdr) and similar “functionals” – take lambda expression as parameter and do very powerful data manipulation…

    What Lisp had was extremely simple way how construct program by program – by properly constructed list of atoms and eval it. After all, everything was just a list of lists … your data could very much be your program

    In Ruby, the same task is more complicated because of the richer and less uniform syntax. therefore it requires more work than just chaining together data into list

  3. natebkirby says:

    Yes, I agree. You can do things in Ruby like what Lisp affords on lists, but Ruby is more cumbersome for them. You can do those same things in C++, Java, C# etc etc, but it is even more difficult than when doing them with Ruby.

%d bloggers like this: