Do you know where your variables are? | |
PerlMonks |
Re^2: OT: Ruby On Rails - your thoughts?by tilly (Archbishop) |
on Nov 17, 2005 at 17:27 UTC ( [id://509484]=note: print w/replies, xml ) | Need Help?? |
Ruby looks like a slightly crazier syntax than Perl to me. Having used Ruby a bit and Perl a lot, I definitely prefer Ruby's syntax. It has a lot of the same shortcuts that Perl does, but is significantly more regular. With better defaults. And I find that as I go to more complex conceptual code, Perl is far more likely to get ugly on me. As a random (unfair) example. Suppose that I want to do a sort on an array of arrays based on the contents of the first column. In Ruby that's array = array.sort; In Perl that's @array = sort {$a->[0] cmp $b->[0]} @array; Suppose that I want to do a lexicographic sort (first column, then second, then...) In Ruby that's the default. In Perl that turns into truly ugly code. That is not an isolated example. Suppose that I have a hash of hashes and I want the keys of one of the subhashes. In Perl that's keys %{$hash_of_hashes{$foo}} while in Ruby that's hash_of_hashes[foo].keys. Which would you prefer to figure out in a hurry? This is not to say that there aren't warts to Ruby's syntax. For a start, I loathe optional semicolons. Secondly, I strongly dislike the lack of a variable declaration, meaning that there is no easy equivalent of strict available. Thirdly the Ruby philosophy of, "Oh, add every alias someone might expect for this" has a conceptual cost when reading someone else's code. But I still prefer it to Perl's. Significantly.
In Section
Meditations
|
|