Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Stop suggesting to upgrade perl

by boftx (Chaplain)
on Sep 01, 2013 at 05:25 UTC ( #1051768=note: print w/ replies, xml ) Need Help??


in reply to Re: Stop suggesting to upgrade perl
in thread Stop suggesting to upgrade perl

With the understanding that this is only my personal opinion, I will attempt to make a reasonable contribution here.

One of my pet peeves is that CPAN authors will sometimes use a feature from a relatively recent version of Perl that is not backwards compatible just because the feature is "cool". One of the worst offenders of this would be the use of the defined/or operator. Yes, saying "//=" is concise and more accurate in many instances, but does it really provide any real advantage over using "||=" in the majority of use cases?

Worse still, IMO, is using Moose (and MooseX) when it is trivial to use traditional OO Perl to do the same thing.

I will be the first to agree that there are many times when using "modern" Perl idioms makes life easier, but that being said, I have found that those occasions are usually in a private environment as opposed to a public environment such as CPAN. I have often argued with myself over this when considering what version of Perl to require for my code that is intended for public consumption.

I respectfully submit that there is a vast difference between requiring a Perl upgrade because of a bug fix and the desire to use a new feature that can already be achieved by an older version, albeit in a more verbose fashion. In fact, I will go so far as to say that some of the more recent "improvements" to Perl encourage "cargo cult" programming in that new programmers adopt the new "standards" without any understanding of why these new features were introduced/requested in the first place. (I am thinking of an instance I had to deal with just yesterday that involved someone defining a new attribute with a builder without thinking about the consequences of not specifying "lazy" as well.)


Comment on Re^2: Stop suggesting to upgrade perl
Re^3: Stop suggesting to upgrade perl
by chromatic (Archbishop) on Sep 01, 2013 at 06:15 UTC
    Yes, saying "//=" is concise and more accurate in many instances, but does it really provide any real advantage over using "||=" in the majority of use cases?

    Given that it's more accurate, yes. Accuracy is a fine feature in many programs—perhaps even most. I like getting the right answers and I like having fewer bugs than more bugs.

    Besides, it's a feature of a Perl release that's nearly six years old. If you want it on a Perl that's even further out of date, you can easily get patches for Perl 5.8 and perhaps even 5.6... but if that's just too much work for you, it's trivial to replace instances of it with a combination of defined and multiple appearances of the relevant variable.

    Worse still, IMO, is using Moose (and MooseX) when it is trivial to use traditional OO Perl to do the same thing.

    I just can't see it as a terrible thing that people who volunteer to give away their code for other people to use freely choose to do things that make their volunteer work enjoyable. You might as well suggest that we stop using Perl and start using the combination of shell, awk, sed, C, and other Unix tools because that's compatible with SysV in its purest form circa 1986. (Imagine how awful it would be if POSIX features were available to people who didn't know how to use them in C, let alone implement them.)

    ... but this is all a silly argument for you to make, because you've already poisoned the well by claiming that all features in Perl newer than your personal cutoff point are merely "cool" and not useful.

      I submit that the fact that one can install Moose or code the equivalent of //= in Perl 5.8 (I am not sure just how early a version of Perl can support Moose) indicates that there is nothing fundamentally new about what is being introduced.

        But increased readability increases maintainability. IMHO the equivalence of

        sub fexists (-f $_[0] ? $_[0] : undef); my $file = fexists ($p) // fexists ("$p.exe") // fexists ("$p.sh") // +;

        would involve lexical copies and a huge chain of defined ($x) ternaries.

        So yes, many new features were doable in older versions, but they were ugly and error-prone.

        I myself do NOT like OO programming. I need to understand how perl does it when dealing with modules that have no non-OO alternative, like DBI and Tk, but I still prefer to program non-OO myself. Moose however makes the threshold to actually *use* OO in perl in a way that does not constantly irritate me a lot lower (if it does take away the threshold at all). That on itself is worth considering, as that also makes the language more open to newcommers. OO-programmers get a head-start with Moose over the available OO techniques that the CORE has available.


        Enjoy, Have FUN! H.Merijn
        ... there is nothing fundamentally new about what is being introduced.

        That's true, but what does it matter? There's nothing I can do with say I couldn't do with print, but say is more convenient. There's nothing I can do with Moose I couldn't do by hand, but it's more readable, shorter, and easier to use.

        As I see it, a feature that makes it more pleasant to write code, easier to write correct code, and simpler to understand code is a benefit, even if that feature adds nothing fundamentally new from a CS perspective or a UX perspective or whatever theoretical perspective you prefer.

        (That's part of my gripe about P6. It adds a lot of nice newish features that probably meet your criteria for fundamental newness, but it's failed to deliver anything practical directly for my uses in 13 years. It's only due to the hard work of people working on things that aren't P6 that we have anything at all practical from the effort.)

Re^3: Stop suggesting to upgrade perl
by tobyink (Abbot) on Sep 03, 2013 at 08:49 UTC

    "Worse still, IMO, is using Moose (and MooseX) when it is trivial to use traditional OO Perl to do the same thing."

    One reason to use something like Moose for answers is that you're often trying to illustrate high-level design; how to split a large problem down into discrete areas of concern. Moose's declarative syntax makes that high-level design clearer; there are fewer distractions in the code like manually-written constructors and accessors.

    In other words, if you're asking about how to use bless, I'll show you; but if you're asking how to structure a large application, I don't want to post code that looks like I'm trying to teach you how to use bless.

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1051768]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2014-09-23 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (221 votes), past polls