High geek content ahead. Potentially inflammatory, but not intended as such.
I'm reading up on Ruby (admittedly egged on by the prevailing hype around Ruby on Rails). As an alternative to Perl, my current language of choice, it seems more palatable than Python to me. It's object-oriented from the ground up, unlike Perl which simulates OO through slightly contorted and easily ignored procedural conventions. Yet Ruby borrows just enough from Perl for me to feel comfortable easing myself into it—for example, it borrows Perl's powerful regular-expression syntax, and it will even permit some procedural style. It doesn't leave me feeling as disoriented as I remember Python did.
But there are at least a couple of pitfalls for dyed-in-the-wool Perl programmers like me. Return values of 0 or an empty string are regarded as Boolean true, whereas Perl treats them as false. Its syntax also has completely different meanings for some symbols than Perl's, for example $ (Perl scalar vs. Ruby global) and @ (Perl array vs. Ruby object instance variable).
Still, despite borrowing a lot of ideas from other programming languages, it feels very simple and less like a "kitchen sink" to me.
P.S. (5:44 p.m.): Silly me, I forgot one other big gotcha for Perl programmers switching to Ruby. Perl automagically converts numeric data from string form to integer form and vice-versa, depending on the context in which they're used. Ruby does not. So if you have a variable n that contains the string "20", and you try to evaluate n * 5, Perl would return 100, but Ruby returns the string "2020202020". To get the expected result in Ruby, you have to explicitly convert the string first (n.to_i * 5). Tags: geek, perl, programming, python, ruby
|