Live data from Hacker News

Ask HN: Why do people consider Ruby better than Perl or vice versa?

news.ycombinator.com

11–20 of 32 posts

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#11

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. Perl is kind of the "C of scripting languages". It's been around for a very long time (late-eighties/early-nineties)…

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.

Perl seems like such an old language...it's hard to believe it's only been around 23 years. It goes to show you how quickly things change in the tech world.

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#12

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: $foo is a scalar @foo is an array $foo[0] is the first element of @foo, instead of @foo[0] 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 appl…

Why is this difficult to understand? my @foo = qw(1 2 3); $foo[0] = 1;

you are referencing an array and returning a scalar. the sigil represents a scalar which is what is returned. A list isn't being returned, so why should the sigil represent that?

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#13
People naturally compare Ruby and Perl because of the well-known similarities and influence that Perl had on the development of Ruby.

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).

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.

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#14
post #10
post #7

What you are seeing is probably more sibling rivalry (or plain old fanboyism) than genuine hatred. From the Ruby FAQ: "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." http://www.rootr.n…

But to the question of whether a language can be intrinsically "illegible", I'd say that it is easier to write "hard-to-read" code in some languages than others. The conventions that a language community shares often lead to easier or harder to read code. In the Perl community, clever code which solves a problem is highly valued. In the Python community (as the Python Cookbook famously says) "To describe something as…

> I don't know enough about Ruby's community to say whether they have their own view about the relative merits of the clever/clean approaches or if they value something else entirely.

Although I think some groups are starting to pick up an anti-clever view of these (the Merb movement probably helped), but you can almost pick any random ruby github project and there will be some custom magic under the hood.

Not saying that's good or bad, just sayin.

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#15
post #12

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: $foo is a scalar @foo is an array $foo[0] is the first element of @foo, instead of @foo[0] 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 appl…

Why is this difficult to understand? my @foo = qw(1 2 3); $foo[0] = 1; you are referencing an array and returning a scalar. the sigil represents a scalar which is what is returned. A list isn't being returned, so why should the sigil represent that?

Why require context-dependent sigils when you don't need to?

Eliminate the unnecessary.

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#16
post #2

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. I usually say Ruby is everything I loved about Perl with none of what I disliked/hated.

I'm an old Perl hacker but do most of my work in Ruby these days -- and love it. I'll always have a soft spot for Perl, and will never forget how it helped build the Internet. But to me, Ruby makes Perl look like Java.

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#18
post #12

Earlier quoted context omitted.

Why is this difficult to understand? my @foo = qw(1 2 3); $foo[0] = 1; you are referencing an array and returning a scalar. the sigil represents a scalar which is what is returned. A list isn't being returned, so why should the sigil represent that?

Why require context-dependent sigils when you don't need to? Eliminate the unnecessary.

for the same reason strcmp() returns not just a -1,0, or 1, but a "distance" between the two strings being compared. A function or syntax has multiple uses if additional information is available to the programmer.

Example:

@array = qw(1 2 3); $length = @array;

print $length;

By allowing a non scalar to take an implicit scalar form, we have an extremely useful and quick way to get the length of an array. Nothing that difficult to replace with a len() call, but it's language features like these that make perl ($length = @_ may be the most useful of all) so handy for quick hacks.

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#19
Switched from Perl to Ruby in 2006. Things I like off the top of my head:

One variable type. This makes references unnecessary. Also, everything that can be stored in a variable is an object.

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.

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.

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.

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 |.

Ruby blocks.

Ruby 1.9 has the Fiber class (rough equivalent to Python generator).

Ruby IO operations throw exceptions when they fail. Hence you don't need the '|| or die "could not open!"' idiom.

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#20

Earlier quoted context omitted.

Why require context-dependent sigils when you don't need to? Eliminate the unnecessary.

for the same reason strcmp() returns not just a -1,0, or 1, but a "distance" between the two strings being compared. A function or syntax has multiple uses if additional information is available to the programmer. Example: @array = qw(1 2 3); $length = @array; print $length; By allowing a non scalar to take an implicit scalar form, we have an extremely useful and quick way to get the length of an array. Nothing that…

I guess my problem with something like that is that conceptually it doesn't make much sense. There's no obvious reason why assigning an array to a scalar variable would give its length – it doesn't really feel clear or elegant, just unexpected.
Post reply on HN