I've seen a lot of anti-perl, pro-ruby speak recently on HN and am curious for what reasons people find Ruby to be superior (esp. from people who have experience with both)<p>I'm personally a fan of both (and continuously delighted by learning new things in both languages). I'm spending more time with Ruby lately because it looks like it's where the community is going and is fashionable these days, but I have no real major issues with perl itself.<p>Perl is often a stereotyped as unreadable, but it's largely up to the writers of the code itself to make it _that_ illegible; it's not a consequence of the language.
I tried both for a while when I was getting into programming, and one huge thing that has always bothered me about Perl is the strange behavior with changing sigils. Here's what I mean:<p>$foo is a scalar<p>@foo is an array<p>$foo[0] is the first element of @foo, instead of @foo[0]<p>As far as I know, Larry Wall's rationale as a linguist was that in English, one would say "this apple" and "these apples", but "this third apple" instead of "these third apple". The problem is that code isn't a human language, and obeying these rules doesn't make sense and puts additional cognitive strain on the programmer. Basically, having different syntax quirks for scalars, arrays, hashes, and file handles makes code unnecessarily weird, especially when combining them for things like multi-dimensional arrays.
I believe the Ruby community is very pro-Perl. I enjoyed Perl myself and Ruby seems to have a lot of the same soul to it.<p>I usually say Ruby is everything I loved about Perl with none of what I disliked/hated.
I've used perl for over 15 years and ruby for over 5.<p>I prefer ruby just because, I tend to be able to read and understand other people's ruby code easier than other people's perl code.<p>Maybe that is something about the language, maybe it is something about the people who use each, maybe it is something about their cultures or something about me.
In the end it doesn't matter much to me.
Ruby owes much of its popularity to Ruby on Rails. I don't think Ruby would be as popular (or "hip") if it hadn't been for Rails.<p>Ruby on Rails also appeared around the time webapp development was gaining a lot of momentum, so that might be a part of the reason.<p>I myself don't find Ruby superior, for me Ruby (on Rails) and Perl solve problems in different domains.
Ruby is great for web development. Perl is great for system administration and scripting, and it's preinstalled on most Unix-like systems (although Python has replaced Perl for the most part in my case).
Anti-perl speak? I must have missed it. I'm not sure why someone would hold a poor opinion of perl, unless it were simply personal taste. To say you don't like a language is not the same as saying a language is bad. I don't like to program in ASP.NET C#, but I don't think it's a bad framework/language.<p>Perl is kind of the "C of scripting languages". It's been around for a very long time (late-eighties/early-nineties). The fact that modern languages, like Ruby, borrow from a language that was invented in the late-eighties says a lot about that language.
What you are seeing is probably more sibling rivalry (or plain old fanboyism) than genuine hatred.<p>From the Ruby FAQ:<p>"If you like Perl, you will like Ruby and be right at home with its syntax. If you like Smalltalk, you will like Ruby and be right at home with its semantics. If you like Python, you may or may not be put off by the huge difference in design philosophy between Python and Ruby/Perl."<p><a href="http://www.rootr.net/rubyfaq-2.html" rel="nofollow">http://www.rootr.net/rubyfaq-2.html</a>
People naturally compare Ruby and Perl because of the well-known similarities and influence that Perl had on the development of Ruby.<p>Ruby followers can rightly claim advantages over Perl (for me, the fact that you can do OO in Ruby without feeling that you're doing some kind of black magic is the big one).<p>But Perl devs could be justified in feeling that Ruby is doing nothing new - many of the libraries that make Ruby so useful have equivalents (predecessors in some cases) in Perl.
Switched from Perl to Ruby in 2006. Things I like off the top of my head:<p>One variable type. This makes references unnecessary. Also, everything that can be stored in a variable is an object.<p>I can remember the Ruby syntax for defining a class. In Perl I had to look it up every time. Also Perl has two competing class systems.<p>Methods by default take a fixed number of arguments and there are no implicit conversions between strings and numbers. This catches a lot of errors.<p>Good Perl practice involves boilerplate such as 'use strict'. I hear about lint tools and such and it makes me think the situation has gotten worse since 2006.<p>The Ruby Array class and the Enumerable module are good. I've become dependent on methods that aren't as readily available in Perl: include? each_with_index all? any? permutation. Also the intersection and union operators: & and |.<p>Ruby blocks.<p>Ruby 1.9 has the Fiber class (rough equivalent to Python generator).<p>Ruby IO operations throw exceptions when they fail. Hence you don't need the '|| or die "could not open!"' idiom.
<i>"Perl is often a stereotyped as unreadable, but it's largely up to the writers of the code itself to make it _that_ illegible; it's not a consequence of the language."</i><p>Well, one argument is that the language (and community) should encourage good/readable/maintainable code.