
What is "Modern Perl"? - fogus
http://perlgeek.de/blog-en/perl-tips/what-is-modern-perl.html
======
jaxn
I have a friend who has done some really neat stuff with Modern Perl. I think
that is the perfect name since it seems to be just using modern methods of
development with Perl.

So, here is a serious question for the Perl geeks though:

Is Modern Perl basically TMTOWTDI falling out of favor? It seems like the
article is saying "This is probably a better way" (TIPABW?)

~~~
draegtun
_Is Modern Perl basically TMTOWTDI falling out of favor?_

Instead its morphed into TIMTOWTDIBSCINABTE, which fortunately is lovingly
referred to as "Tim Toady Bicarbonate" :)

In full... _There's more than one way to do it, but sometimes consistency is
not a bad thing either_

ref:
[http://en.wikipedia.org/wiki/Theres_more_than_one_way_to_do_...](http://en.wikipedia.org/wiki/Theres_more_than_one_way_to_do_it)

~~~
jaxn
corrected link:
[http://en.wikipedia.org/wiki/There_is_more_than_one_way_to_d...](http://en.wikipedia.org/wiki/There_is_more_than_one_way_to_do_it)

That is awesome. While I don't write Perl these days, seeing things like this
is like meeting up with old college buddies.

------
Xurinos
Also, I rarely see listed Devel::REPL. Excellent, excellent tool. Run re.pl
with perl -d, and you have half the useful REPLness of CL.

~~~
viraptor
It's ok... It's better than nothing, but sometimes it can be pretty confusing
(one can argue that's correct, but it's definitely not what I'd expect).

    
    
        $ my @a=(1,2,3)
        $ARRAY1 = [
                1,
                2,
                3
              ];
        $ my $r=[1,2,3]
        $ARRAY1 = [
                1,
                2,
                3
              ];

~~~
draegtun
Thats just standard Data::Dumper output so nothing to worry about:

    
    
        $ say $_ for @a;
        1
        2
        3
        
        $ say $_ for @$r;
        1
        2
        3
    

You can switch on the _Data Dumper Concise_ plugin (Devel::REPL::Plugin::DDC).
It will still display @a has a array reference but its nicer to look at:

    
    
        $ my @a=(1,2,3)
        [
          1,
          2,
          3
        ]
        
        $ my $r=[1,2,3]
        [
          1,
          2,
          3
        ]
    
    

_It's ok... It's better than nothing_

Come on its a lot better than nothing! Checkout the plugins on CPAN because
this really makes it a very powerful tool:
[http://search.cpan.org/search?query=devel%3A%3Arepl%3A%3Aplu...](http://search.cpan.org/search?query=devel%3A%3Arepl%3A%3Aplugin%3A%3A*+&mode=module)

~~~
viraptor
I meant the array reference that looks weird even if you're listing an array.

Well... it is a usable REPL, but I'm used to running IPython+pdb as my login
shell. `re.pl` cannot be really compared there.

~~~
draegtun
I find _re.pl_ more than just an usable REPL and considering its a lot younger
project than IPython then I'd have to say its progressed/progressing extremely
well.

~~~
viraptor
No sympathy there, unfortunately. IPython started in 2005 and was very usable
shortly after. Actually, it was more usable then, than Devel::REPL is now.
Devel::REPL is now 3 years old (released first cpan version, 1.0 in 2007) and
I really can't defend it. It's just not on the same level yet. Even Zoidberg
is better in some ways, but it didn't provide nice enough access to Perl
syntax the last time I tried it.

~~~
draegtun
No need to defend or provide any sympathy because I find Devel::REPL to be a
great REPL and it fulfils all my needs. I've used REPL's in Ruby (irb), Io,
Rakudo and Clojure and IMHO Devel::REPL is no where near the bottom of this
list!

BTW, a couple of points:

* Zoidberg is a shell clone (ala Bash, Korn, csh, zsh) and is more akin to projects/products like psh (<http://sourceforge.net/projects/psh>). While there are overlaps Zoidberg isn't really a full REPL (like Devel::REPL, PerlConsole or even Perl::Shell).

* Devel::REPL started as a blog post in April 2007 ([http://chainsawblues.vox.com/library/post/a-perl-read-excute...](http://chainsawblues.vox.com/library/post/a-perl-read-excute-print-loop-repl.html)). It may have been called version 1.0 but it was just an _proof of concept_ at this time.

------
bigiain
While I quite like the article, I'm amused to note that 5 out of the 10
"aspects of Modern Perl" are things I screwed up, struggled with, and
standardised on - in a project back in the late '90s.

Tests, 3 arg open, strict and warnings were all things that came to prominence
(at least in my head) shortly after the Perl4 - Perl5 update. To a lesser
extent "best practices" (the same concept but before the book was published)
and "care and marketing" were all things being discussed and in clpm back
around the same time everybody was worried about y2k issues. Even the OO stuff
was well underway, with things like Abigail's "inside-out objects" being
experimented with and discussed well before the start of the Moose project...

~~~
draegtun
And this is all good news because it shows that Perl is progressing and
continually improving. For eg. from Perl 5.012 you can now do this:

    
    
        #!/usr/bin/env perl
        
        use 5.012;
        use warnings;
    

That _use 5.012_ now automatically switches on _use strict_ along with all the
extra Perl 5.12 features
([http://search.cpan.org/~jesse/perl-5.12.1/pod/perl5120delta....](http://search.cpan.org/~jesse/perl-5.12.1/pod/perl5120delta.pod)).

Perl + CPAN + time = programming darwinism :)

------
draegtun
Also see perl5i for a _hypermodern_ version/vision/patch of Perl 5:
<http://search.cpan.org/dist/perl5i/lib/perl5i.pm>

------
hernan7
Just one request from this old Perl hack: please make it easier to learn than
Ancient Perl. If you need to be an expert on Vanilla Perl to be able to "get"
Modern Perl, then it's going to have a hard time getting traction. Like those
Java web frameworks that you needed to be a JSP guru to be able to grok.

Oh well, back to my usual Ancient Perl hacking...

------
toddh
Python?

~~~
chromatic
What about Python do you find better than modern Perl? Besides Pygame and
NLTK, there's nothing in Python I can't do faster, easier, or more
maintainably in Perl. I much prefer Moose to Python's barely-there OO, and
nothing compares to the availability (and testing and other infrastructure) of
the CPAN.

~~~
sreque
Not having to deal with copious amounts of accidental complexity needlessly
introduced by the language? Just look at the example on the o'reilly page for
the Perl Best Practices book which is linked to by this article. In Perl,
there's more than one way of creating file handles, and one of them is the
older and less effective way. What a useless fact I have to memorize!

Perl was actually the first dynamic language I learned, and when I looked
online to see how to open a file, I found the old way first. Later on, I was
like, "Hey! How do I pass this $@($*& thing to a function!?" So I looked
online and found several competing ways to do it. I first learned of the OO
way of doing it, but that required rewriting a lot of code. Then I discovered
the syntax required to assign your file to a normal variable, which required
me only to add sigils to my code! Unfortunately, I never got so far in my
newbiedom as to learn the syntax for passing typeglobs around. This page
describes the madness so wonderfully as a "perl recipe":
<http://docstore.mik.ua/orelly/perl/cookbook/ch07_17.htm>. Yum!

And, of course, Steve Yegge describes what I'm saying much better at
[http://sites.google.com/site/steveyegge2/ancient-
languages-p...](http://sites.google.com/site/steveyegge2/ancient-languages-
perl):

"There are no rules, no heuristics, no patterns. It's pure memorization.
Commit the Perl Periodic Table of the Operators to memory, and you're
officially 1/1000th of the way down the road to Perl Zombiedom. "

~~~
chromatic
I don't know what to tell you other than if you deliberately write clunky
code, you'll have trouble understanding and maintaining it. Passing typeglobs
around isn't modern Perl; it hasn't been necessary for over a decade (to be
specific, it hasn't been necessary since 22 March 2000).

... and I know Steve and I like Steve, but I wouldn't take medical advice from
him either for much the same reason.

~~~
sreque
Steve may not be a medical doctor, but he is a programming language expert, so
I really don't get your ad hominem refutation of what he said about Perl.
Perhaps you can comment on what he actually said, not who he is?

Also, I think you missed the entire point of my post, including the example.
I'm also not sure of how else to word it to help you get it. My point was that
Perl requires you to deal with a host of issues that have nothing to do with
solving your actual computing problem. One simple example of these many
thousand idiosyncracies, which the article itself indirectly brings up, is
Perl file handles. Even if you know the "modern" way of using them, you still
had to go through the learning process to differentiate between the old and
new styles, and you still have to commit a bunch of useless facts to memory.
Worse, you may still encounter and have to deal with the old way in the wild!

I love the description of the perl5i CPAN module at
<http://search.cpan.org/~mschwern/perl5i-v2.2.2/lib/perl5i.pm>:

"perl5i - Fix as much of Perl 5 as possible in one pragma"

Why not use a language that lets you get stuff done faster, instead of a
language that's been feature-patched to death to fix the terrible design flaws
it began with?

~~~
chromatic
_Perhaps you can comment on what he actually said, not who he is?_

Certainly: that particular comment is irrelevant nonsense.

 _There should also be a CPAN module called Python. Fix as much of perl 5 as
possible in one new language!_

I expect better discussion from Hacker News.

~~~
sreque
You're right about the Python comment, and I edited it out. However, I would
also say that you've provided no discussion of value in your comments. I at
least back up my statements with correct supporting arguments, even if I
sometimes use overly strong language in making them.

~~~
chromatic
My point is simple: the past ten years of Perl development have changed the
language and its ecosystem dramatically. You can still write Perl as you did
in 2000 or 1994 or 1987, but the Perl community tends to use terms like
"Modern Perl" and "Enlightened Perl" and "Perl Renaissance" to distinguish
between code we know to be buggy and clunky and difficult to maintain and the
code we write now that we know so much better.

If you want to compare Python to Perl, compare Python 1.x to the ancient Perl
that always comes up in these comparisons. (You may or may not deduct points
from Python for breaking backward compatibility in the past near-decade.)

~~~
sreque
Then we don't have anything to argue about. I agree that modern Perl is a lot
better than older perl, and that modules that fix perl, like perl5i, Coro, and
Moose, enable you to write decent code using the language. I never tried to
say otherwise. My point was, why bother, when you can use a language that
doesn't need to be fixed in the first place? Life is so much simpler without
all the extra accidental complexity.

~~~
chromatic
_My point was, why bother, when you can use a language that doesn't need to be
fixed in the first place?_

Because I'd rather have to add on Moose (something I _can_ fix while remaining
compatible with other libraries) than use a language in which variables
automagically spring into existence (which I _can't_ fix).

Worse than that, while I'm sure that new Python 2 classes and metaclasses
allow someone to write a better object system for Python, no one would ever
use it.

Thus my main non-syntactic gripe with Python is that the things I most want
fixed either I can't fix and still have Python or no one in the Python
community would ever support, because of the peer pressure to hew to one
obvious way to do things.

