Modern::Perl 1.00

chromatic on 2009-01-26T23:11:49

You may or may not have noticed that Onyx Neon Press launched a site called Modern Perl Books last week. We have some works in progress behind the scenes.

My intent with the site is to gather information on what exactly modern Perl looks like, so that I can write the promised Modern Perl book. I'm working on the outline and have lots of great ideas, and of course I'll solicit feedback from everyone willing to contribute.

Today I realized the need for a simple definition of "Modern Perl" which a novice programmer could use reliably until he or she is enough of an expert to define a personal subset of the language and its ecosystem. I know that this'll start all sorts of arguments, but in 21 years no one has done this, so why not try now?

Modern::Perl is a CPAN distribution which enables all of the features of Modern Perl in any program which uses it. Please see Toward a Modern::Perl for more explanation. I'm sure I'll add more modules, but right now it collapses three lines of code in my simplest programs into one, which is definitely progress in the right direction.


Some ruminations

geoffrey on 2009-01-27T06:57:30

Modern Perl ...

* uses no deprecated or "evil" features
* freely uses features of recent Perls and recent module versions
* discards contortions used for compatibility with ancient Perls and ancient module versions
* uses newer, cleaner, more powerful modules, rather than decade-old modules generally agreed to be showing their age
* generally follows current best coding and interface practices (but may decide to ignore specific recommendations when appropriate)
* follows best security practices
* shares with others: performs decently without hogging system or network resources

North American Mammals

singingfish on 2009-01-27T11:40:56

The second Catalyst book (out for OSCON in June) will use Moose (with Squirrel acceptable for lightweight Models and Views) as it's only way of doing OO. I've noticed that Badger has appeared on the perl OO scene, which is great because it show how easy it is to bolt on decent OO into a language as expressive as Perl, but Moose (and it's Squirrel) has significant and sustained first mover advantage in this situation.

Re:North American Mammals

singingfish on 2009-01-27T11:42:22

s/it's/its/i

Wow!

educated_foo on 2009-01-27T22:20:15

"For now, this only enables the strict and warnings pragmas, as well as all of the features available in Perl 5.10." It's like "use 5.10.0" with more characters! Awesome!

Re:Wow!

chromatic on 2009-01-27T23:02:32

Which version of Perl are you running where use 5.10.0; also enables strictures and warnings? (It's certainly not the released version of 5.10, nor the packaged version in Ubuntu, nor bleadperl.)

Re:Wow!

tsee on 2009-01-28T00:13:47

Just for the record: I submitted that patch a long time ago. Last I heard from Rafael was that he's still thinking about it. I keep bugging him whenever I get a chance.

Re:Wow!

chromatic on 2009-01-28T00:41:15

I like the idea and I wish it were committed, but I fear that the forces of stagnation will win again.

Re:Wow!

tsee on 2009-01-28T13:07:59

I have moderately high hopes of having success with bribes that involve large quantities of beer or red wine, depending on Rafael's choice. If only I would meet him at some Perl event...

Re:Wow!

educated_foo on 2009-01-29T01:53:51

I don't consider implicit strict and warnings a feature. If your program is big enough for them to be useful, those two extra lines are insignificant.

Re:Wow!

chromatic on 2009-01-29T07:45:48

I don't consider implicit strict and warnings a feature.

If you find no use from this module, I don't mind. I didn't write it for people who know precise cantrips and incantations to make Perl help them instead of allowing them to get themselves into trouble. I wrote it for people who are just learning Perl and haven't figured out yet all of the magic gobbledygook incantations to let Perl help them.

You know what you're doing. I'm trying to give the other six and a half billion people a better chance.

Maybe.

educated_foo on 2009-01-30T03:00:10

"Magic gobbledygook?" Please. Don't insult your readers.

If people want Java, they know where to find it. If they don't, this Perl-as-Java jihad is a waste of time.

Re:Maybe.

chromatic on 2009-01-30T09:05:55

Please. Don't insult your readers.

Please don't quote me out of context. It's rude, and it leads you into strawman arguments which waste everyone's time.

Do you remember being a novice programmer? Have you seen how they get treated in forums such as PerlMonks? If they haven't included use strict; use warnings; in their code, someone will invariable respond "I don't know how to solve your problem, but you should always use strict; use warnings;."

Tell me -- how many novices understand what those do and why and how? For all the Perl hackers who rail against cargo-cult coding, there's sure a lot of cargo-cult recommending going on. By my estimation, you have to know about modules, pragmas, and importing before strict and warnings make any sense.

It's funny that you bring up Java, though I have no idea what your point is. I've compared "Hello, world!" in Perl to Java recently. If you want to see magic gobbledygook in another language, ask a Java neophyte to explain public or static or class Main or System.out. sometime.

At least with Perl we have the chance to abstract away some of that boilerplate so novices can't see it -- hence my confusion about what you mean about "Perl-as-Java".

Re:Maybe.

educated_foo on 2009-01-30T16:01:49

Given that what you wrote appears directly above my reply, I'm not sure how I'm "quoting you out of context." You're welcome to explain.

We're in violent agreement about the standard Perlmonks treatment -- chanting "use strict use warnings" at people in replies and sample code is unhelpful, and I've tried to make that point there in the past. Few novice programmers understand what strict and warnings do, but part of the process of becoming a non-novice is understanding these things. Simply adding boilerplate to the top of your scripts doesn't help.

As for my statement about Java, you're probably just being disingenuous, but my point is that Java is a language designed entirely to limit the amount of damage that can be done by idiots. Companies want to have clueless (therefore cheaper) people produce software, and Java is the answer. Feature-wise, it's C++ for dummies.

I don't think Perl should become "Perl for dummies." Perl is appealing because it is focused on getting the job done, and because it assumes you know what you are doing. It has never been a language for purists and pedants, and it saddens me to see it becoming one.

Re:Maybe.

chromatic on 2009-01-30T18:32:21

You're welcome to explain.

Copied and pasted code that a novice has no mental framework to understand and will not understand without also understanding several fundamental concepts is magic gobbledygook. You can say "Just copy this around and don't change it and don't worry that you don't understand it," or try to explain it or make it unnecessary. I prefer the latter option.

I don't think Perl should become "Perl for dummies."

What part of Modern::Perl makes Perl more suitable for dummies? All of the power of Perl is still available. The module only eases the first part of the learning curve a little bit.

It's difficult for me to believe that in 2009 the default behavior of perl for someone just learning Perl is not to enable helpful seatbelts such as warning about typos in variable names, symbolic references, likely wrong constructs such as numeric equality tests where string equality is probably right, and so on. I refuse to believe that trying to make the compiler help people find the bugs they will right turns Perl into a language only suitable for snobs and fools.

On the other hand, if me releasing this silly little module that's completely optional even to install chases away arrogant pseudo-macho jerks who love to heap scorn on novices and think that artificial difficulties make them Real Men, maybe it's a good thing.

Good stuff...

educated_foo on 2009-01-30T23:29:38

>

I agree, which is why Modern::Perl's syntactic disguise of the former seems counterproductive. And if believing this makes me an "arrogant, pseudo-macho jerk" and/or a "Real Man," can I at least get a card or something?

Re:Good stuff...

educated_foo on 2009-01-30T23:30:52

use.perl is even more of a bucket of FAIL than I thought -- "plain old text" sure ain't. Here's the bit I meant to include in angle quotes: "You can say "Just copy this around and don't change it and don't worry that you don't understand it," or try to explain it or make it unnecessary. I prefer the latter option."

Re:Good stuff...

chromatic on 2009-01-31T00:43:16

I agree, which is why Modern::Perl's syntactic disguise of the former seems counterproductive.

I wish it weren't necessary, but that requires either fixing p5p culture such that backwards-incompatible language improvements are possible or forking and promoting my own version of Perl 5. I'm not the person for either task.

At best, I can minimize the damage in a way that works right now with Perl 5.10 which is already out. There's no forking. There are no patches. No one has to recompile Perl. There are no non-core dependencies at the moment, and anyone who really can't install CPAN modules can reproduce the module in its entirety in ten lines of code.

Modern::Perl is the simplest, least bad improvement I can imagine for the problem I'm trying to address. Once novices have it installed, I can say "Here's one line you should add to all of your programs for now. It tells Perl to help find errors in your programs and makes sure that you can use all of the nice features I'm going to explain. You don't have to understand how it works for now."

[Can] I at least get a card or something?

No, but I can offer you an apology for that snideness.

Re:Good stuff...

educated_foo on 2009-01-31T20:57:40

I wish it weren't necessary, but that requires either fixing p5p culture such that backwards-incompatible language improvements are possible or forking and promoting my own version of Perl 5.

To be honest, that would read "changing" and "changes," not "fixing" and "improvements." You want Perl to be one thing, while the P5P regulars want it to be something else. And the module would be "Chromatic's::Perl" (apologies twice over...;-), not "Modern::Perl."

No, but I can offer you an apology for that snideness.

No problem -- these internets make douches of us all.