Live data from Hacker News

Why I Use Perl: Reliability

modernperlbooks.com

81–90 of 196 posts

Re: Why I Use Perl: Reliability

#81
post #44
post #38

Earlier quoted context omitted.

Thanks for that. First one (not 100% sure it's constant memory, I think perl optimises the for to avoid instantiating the (1..$n) list: #!/usr/bin/perl use Modern::Perl; use bigint; say fact(5000); sub fact { my ($n) = @_; my $output = 1; for my $i (1..$n) { $output *= $i; } return $output; } (Took the value up to 5000 to get something which ran long enough to get a measurement, on my laptop it runs (including startu…

that also highlights one of my perl peeves - having to scrape function args out of @_ rather than declaring them as part of the function definition.

It's really not that different; you just end up declaring your input arguments one line lower than in most other languages. Not a big deal in practice.

And with @_, you're free to use positional arguments, named arguments, variable arity, etc. without penalty. Some languages only give you some of that.

Re: Why I Use Perl: Reliability

#82
post #49

The readability arguments need to include such modules as Method::Signatures::Simple, which replaces the old manual method (no pun intended) with: method foo ($a, $b) { $self->blargh($a + $b); }

What's been gained here? You've traded away one line of boilerplate Perl understood by all, and now everyone who touches your code has to know the semantics of 'method'.

Re: Why I Use Perl: Reliability

#83
post #66

Earlier quoted context omitted.

Does ruby not have the same level of both?

Short answer - no. CPAN has had many more years than Ruby's Gems to mature and develop. There are 2560 [edit: I was wrong. 39411 is the right number] gems on http://rubygems.org/ . There are 24,920 distributions on CPAN. Well over 100k modules. The automated testing infrastructure, documentation, etc. also makes it much easier to figure out what modules work on what systems and what versions of perl than in ruby land…

According to rubygems.org stats page[1], there are 39411 gems available. I think the number 2560 on "all gems" page[2] is the number of gems starting with letter "a".

1. http://rubygems.org/stats

2. http://rubygems.org/gems?letter=A

Re: Why I Use Perl: Reliability

#84
post #82
post #49

The readability arguments need to include such modules as Method::Signatures::Simple, which replaces the old manual method (no pun intended) with: method foo ($a, $b) { $self->blargh($a + $b); }

What's been gained here? You've traded away one line of boilerplate Perl understood by all, and now everyone who touches your code has to know the semantics of 'method'.

... now everyone who touches your code has to know the semantics of 'method'.

The same argument applies for every new symbol imported into a namespace.

Re: Why I Use Perl: Reliability

#85

For any value of $LANGUAGE, imagine this situation: your boss comes to you and say "Hey, they just released a new major version of $LANGUAGE today. Can you go upgrade it on all our production servers?" What is your emotional response to that request? For many values of $LANGUAGE, there would probably at least some element of terror (for many languages, probably much more than just "some"). But Perl is one where, depe…

> What is your emotional response to that request?

Heh the worst upgrade experience I've had with any language was with perl. The issue wasn't with changes to language features, it was chaos resulting from CPAN XS module compatibility and compilation failures. I remember one trivial module (array::compare) went from a having few core dependencies to dozens of CPAN dependencies (including all the moose OO modules). And that was just one module, there was a list of others that had issues.

To be fair, that was a Solaris environment and was the only time I had issues that serious. But I'd argue documentation of dependencies is a much bigger factor no matter what the language.

Re: Why I Use Perl: Reliability

#86
post #55
post #47

Earlier quoted context omitted.

> def Factorial(x): output = 1 for i in xrange(x): output = (i + 1) return output Umm, did you mean: def factorial(x): output = 1 for i in xrange(2, x): output *= i return output Here are the perl versions. Such trivial examples are going to look the same in languages which share the same paradigms. use List::Util qw(reduce); # This is how I would write it. sub fact1 { my $num = shift; my $output = 1; $output *= $_ f…

Based on the examples, I presume xrange(x) is every integer up to but not including x. ie 1..^$x in Perl 6, don't recall if that's the Perl 5 syntax or not.

> Based on the examples, I presume xrange(x) is every integer up to but not including x

Yes. That makes my Python example incorrect(should be xrange(2, num + 1))

> 1..^$x in Perl 6, don't recall if that's the Perl 5 syntax or not.

Perl 5 doesn have 1..^$x. I have always used 1..($n - 1) where I needed it - don't know if there is a better alternative.

Re: Why I Use Perl: Reliability

#87

7-10 years ago, Perl was my daily bread and butter. It was the language I used the most, and not only did it supplant a lot of C code, but was the optimal scripting solution. Now, for me, Ruby has supplanted Perl in nearly every conceivable way -- OO Perl was always painful, and I do not miss ever having to bless a refrent again…

I do Perl on a daily basis, and I can't remember when I last blessed a ref. use Moose;

Do you use Moose, or MooseX::Declare? Moose has a startup penalty, but when I am willing to accept that, I would rather use declare extensions as well.

Re: Why I Use Perl: Reliability

#88
post #66

Earlier quoted context omitted.

Does ruby not have the same level of both?

Short answer - no. CPAN has had many more years than Ruby's Gems to mature and develop. There are 2560 [edit: I was wrong. 39411 is the right number] gems on http://rubygems.org/ . There are 24,920 distributions on CPAN. Well over 100k modules. The automated testing infrastructure, documentation, etc. also makes it much easier to figure out what modules work on what systems and what versions of perl than in ruby land…

The thing that is really awesome about the testing environment is that is makes it immediately obvious when a module on cpan has been abandoned.

That makes it easy to use a cpan module with confidence, which imo is not valued highly enough in other language communities cpan-like structures.

Re: Why I Use Perl: Reliability

#89

Unleash the smug Lisp weenies! After all, Perl's stability is minimal compared with Common Lisp's.

Ah yes, SBCL, the runtime that manages memory with a signal handler on SEGV. Stable!

That's a feature, not a bug. Write-protecting memory areas using mprotect() and the like, and handling the resulting SIGSEGV, is a popular technique for implementing a write barrier needed for generational garbage collection.

Re: Why I Use Perl: Reliability

#90
post #75
post #73

Earlier quoted context omitted.

I actually like the explicit "I'm reading from a special list" syntax because that's what it's doing. A lot of Perl's "ugliness" comes from the language being pretty honest about what it's doing.

Actually, though I tried C++ starting in 1993, Java from 1996, I didn't really grok OO until I tried it in Perl a few years later. Because it shows its guts out, without any sugar coating, I understood what it was about.

A favorite koan of mine: objects are a poor man's closures, but closures are a poor man's objects.
Post reply on HN