Mailing List Archive

Changed defaults - Are they best for newbies?
One of the oft-cited reasons for wanting a Perl 7 to change language
defaults (like enabling strict and warnings by default) has been the
consideration of newbie users, new people we hope to bring to the Perl
community. The idea has been asserted that new defaults would be
beneficial to them.

If we could somehow magically stop the entire world, update every
single perl installation with a Perl 7 and ensure that nobody anywhere
was running an older version and start the world again, then it might
seem that "new defaults" would be nice. It'd make simpler code.

But we can't do that. Even with the most perfect and timely execution
on a "Perl 7" release the world will continue in a mixed 5-or-7 state
for a long time. I'm not just considering installed interpreters, but
also books, tutorials, online articles, ... All those things that affect
newbies a lot more than the more entrenched experienced programmers.
There will remain for a long time many sources of learning for these
new programmers that talk about "the old ways" - i.e. Perl 5 defaults.

We may be doing those new users a disservice if we go out and create a
world in which suddenly there are "two different kinds of perl" and it
is impossible for them to look at an online tutorial and know if it's
good or not. The version of perl they're running has to match the
version the tutorial was written for, and it may not be obvious -
doubly so to the newbies it is aimed at.

Lets take for example, this tutorial snippet I just made up:

#!/usr/bin/perl

open my $fh, "<", "data.txt" or die "Cannot open - $!";

It's a reasonable example in most ways (lexical filehandle, 3arg open,
checks for failure) - but youknow, it didn't start with `use strict;
use warnings;` - that's bad right?

Well... kinda? But in the new world of new defaults for 7, that's OK.
Those are on by default. So maybe this example is fine. But how does
someone know that just by looking at the example that we're aiming at
7. The example doesn't say 7 anywhere on it.

What happens if this newbie user runs it on their existing perl 5?
They're a newbie - they don't necessarily know to check the distinction
between 5 and 7 - why would they? They just run it - and of course, it
works fine. So they'll carry on writing... maybe they'll succeed in
their task, or maybe they'll do something wrong that, had they had
strict+warnings enabled, perl would have told them about. But because
they're running on 5, not 7, those defaults didn't apply.

We've now just annoyed and confused this new user. At this point it's a
bit late to explain "Oh yes so perl didn't used to do that but we just
assumed in the tutorial you'd be running a new perl so we didn't bother
to tell you".

Perhaps then, my original tutorial example was wrong, and sent newbie
users off in the wrong direction. A far better tutorial would therefore
be:

#!/usr/bin/perl
use v7;

open my $fh, "<", "data.txt" or die "Cannot open - $!";

And hey presto - all the newbie users are now in a far better position.
Anyone running on perl 7 already doesn't notice any difference
whatsoever - all is fine. But anyone still running on an older perl 5
gets a far better result, in that the example complains

Perl v7.0.0 required--this is only v5.30.3, stopped at ...

So it would seem that in order to be nice and friendly to these new
users (who surely aren't going to bother to check `perl --version`
before they run tutorials) we all ought to be strongly encouraging the
use of a `use v7` line in all the code and examples anyway.

I'm not thinking here about seasoned professionals maintaining old
crufty installations, or mid-way maintainers of new and exciting but
well-written code. I'm purely looking at new users trying to take their
first steps into the world of Perl by reading some online examples and
tutorials.

Do folks agree here? In summary, that:

To best help newbie users coming to Perl via tutorials and examples,
it is important that we always show `use v7` at the top of all the
code to ensure that they get the right behaviour if their perl version
is too old.

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On 8/11/20 8:30 AM, Paul "LeoNerd" Evans wrote:
> One of the oft-cited reasons for wanting a Perl 7 to change language
> defaults (like enabling strict and warnings by default) has been the
> consideration of newbie users, new people we hope to bring to the Perl
> community. The idea has been asserted that new defaults would be
> beneficial to them.
>
> If we could somehow magically stop the entire world, update every
> single perl installation with a Perl 7 and ensure that nobody anywhere
> was running an older version and start the world again, then it might
> seem that "new defaults" would be nice. It'd make simpler code.
>
> But we can't do that. Even with the most perfect and timely execution
> on a "Perl 7" release the world will continue in a mixed 5-or-7 state
> for a long time. I'm not just considering installed interpreters, but
> also books, tutorials, online articles, ... All those things that affect
> newbies a lot more than the more entrenched experienced programmers.
> There will remain for a long time many sources of learning for these
> new programmers that talk about "the old ways" - i.e. Perl 5 defaults.
>
> We may be doing those new users a disservice if we go out and create a
> world in which suddenly there are "two different kinds of perl" and it
> is impossible for them to look at an online tutorial and know if it's
> good or not. The version of perl they're running has to match the
> version the tutorial was written for, and it may not be obvious -
> doubly so to the newbies it is aimed at.
>
> Lets take for example, this tutorial snippet I just made up:
>
> #!/usr/bin/perl
>
> open my $fh, "<", "data.txt" or die "Cannot open - $!";
>
> It's a reasonable example in most ways (lexical filehandle, 3arg open,
> checks for failure) - but youknow, it didn't start with `use strict;
> use warnings;` - that's bad right?
>
> Well... kinda? But in the new world of new defaults for 7, that's OK.
> Those are on by default. So maybe this example is fine. But how does
> someone know that just by looking at the example that we're aiming at
> 7. The example doesn't say 7 anywhere on it.
>
> What happens if this newbie user runs it on their existing perl 5?
> They're a newbie - they don't necessarily know to check the distinction
> between 5 and 7 - why would they? They just run it - and of course, it
> works fine. So they'll carry on writing... maybe they'll succeed in
> their task, or maybe they'll do something wrong that, had they had
> strict+warnings enabled, perl would have told them about. But because
> they're running on 5, not 7, those defaults didn't apply.
>
> We've now just annoyed and confused this new user. At this point it's a
> bit late to explain "Oh yes so perl didn't used to do that but we just
> assumed in the tutorial you'd be running a new perl so we didn't bother
> to tell you".
>
> Perhaps then, my original tutorial example was wrong, and sent newbie
> users off in the wrong direction. A far better tutorial would therefore
> be:
>
> #!/usr/bin/perl
> use v7;
>
> open my $fh, "<", "data.txt" or die "Cannot open - $!";
>
> And hey presto - all the newbie users are now in a far better position.
> Anyone running on perl 7 already doesn't notice any difference
> whatsoever - all is fine. But anyone still running on an older perl 5
> gets a far better result, in that the example complains
>
> Perl v7.0.0 required--this is only v5.30.3, stopped at ...
>
> So it would seem that in order to be nice and friendly to these new
> users (who surely aren't going to bother to check `perl --version`
> before they run tutorials) we all ought to be strongly encouraging the
> use of a `use v7` line in all the code and examples anyway.
>
> I'm not thinking here about seasoned professionals maintaining old
> crufty installations, or mid-way maintainers of new and exciting but
> well-written code. I'm purely looking at new users trying to take their
> first steps into the world of Perl by reading some online examples and
> tutorials.
>
> Do folks agree here? In summary, that:
>
> To best help newbie users coming to Perl via tutorials and examples,
> it is important that we always show `use v7` at the top of all the
> code to ensure that they get the right behaviour if their perl version
> is too old.
>

I don't agree, but I don't adamantly disagree. Which tutorials, etc.,
communicate best is something that can only be determined through
empirical experience.

We first have to get to a point where we have a Perl 7 that's usable
enough for people to try out. Some of us are working on that now, and I
hope more people join that effort.

Once we get there, we'll be able to try out different instructional
materials and make a decision informed by experience and data.

Thank you very much.
Jim Keenan
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On Tue, 11 Aug 2020 08:57:25 -0400
James E Keenan <jkeenan@pobox.com> wrote:

> We first have to get to a point where we have a Perl 7 that's usable
> enough for people to try out. Some of us are working on that now,
> and I hope more people join that effort.
>
> Once we get there, we'll be able to try out different instructional
> materials and make a decision informed by experience and data.

My point was more to think forward a few more steps from this initial
position.

1) If it turns out that in practice every Perl7-targeting tutorial,
example, guide, etc... is going to always say "use v7" anyway, then
in all likelyhood everyone is going to start their code like that
anyway.

2) At which point, it doesn't matter what the defaults are; everyone
always starts with an explicit use v7.

3) At which point, do we even need to change the defaults at all?
Everyone is going to "use v7" all the time, so the defaults don't
really matter.

So maybe "being friendly to newbies" isn't a good reason to change
defaults after all?

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On Tue, 11 Aug 2020 at 16:45, Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
wrote:

> On Tue, 11 Aug 2020 08:57:25 -0400
> James E Keenan <jkeenan@pobox.com> wrote:
>
> > We first have to get to a point where we have a Perl 7 that's usable
> > enough for people to try out. Some of us are working on that now,
> > and I hope more people join that effort.
> >
> > Once we get there, we'll be able to try out different instructional
> > materials and make a decision informed by experience and data.
>
> My point was more to think forward a few more steps from this initial
> position.
>
> 1) If it turns out that in practice every Perl7-targeting tutorial,
> example, guide, etc... is going to always say "use v7" anyway, then
> in all likelyhood everyone is going to start their code like that
> anyway.
>
> 2) At which point, it doesn't matter what the defaults are; everyone
> always starts with an explicit use v7.
>
> 3) At which point, do we even need to change the defaults at all?
> Everyone is going to "use v7" all the time, so the defaults don't
> really matter.
>
> So maybe "being friendly to newbies" isn't a good reason to change
> defaults after all?
>

This is one of motivations why newer perl5s should recognize "use v7" and
act accordingly.
It also means that "use vX" should be mandatory.

This also can be some kind of advocacy in perly.y refactoring thread - I'm
quite confident that
it is possible to create and maintain one grammar for any number of vX.


>
> --
> Paul "LeoNerd" Evans
>
> leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
> http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
>
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On Wed, 12 Aug 2020 at 00:13, Branislav Zahradník <happy.barney@gmail.com>
wrote:

> On Tue, 11 Aug 2020 at 16:45, Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
> wrote:
>
>> 1) If it turns out that in practice every Perl7-targeting tutorial,
>> example, guide, etc... is going to always say "use v7" anyway, then
>> in all likelyhood everyone is going to start their code like that
>> anyway.
>>
>> 2) At which point, it doesn't matter what the defaults are; everyone
>> always starts with an explicit use v7.
>>
>> 3) At which point, do we even need to change the defaults at all?
>> Everyone is going to "use v7" all the time, so the defaults don't
>> really matter.
>>
>> So maybe "being friendly to newbies" isn't a good reason to change
>> defaults after all?
>>
>
> This is one of motivations why newer perl5s should recognize "use v7" and
> act accordingly.
> It also means that "use vX" should be mandatory.
>

Having "use vX" be mandatory means that every old tutorial breaks - one of
many reasons why it should *not* be mandatory.

Given the sheer volume of the older tutorials out there, I would expect a
dangerously high percentage of users to give up at this point, and switch
to a language which *works* when they try one of the suggested examples.
Those languages are not hard to find!

This goes back to the original point - Perl does not exist in a vacuum!
There's a considerable amount of existing code, documentation (both
tutorial and reference) and developer teams out there. Do we really want to
insist that every Perl module and script *must* have this new line added
before it even runs?

Making old and new tutorials useful, and allowing old and new code to
continue working, is simple: "use v7" for the new features, no changes to
defaults.
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On Tue, 11 Aug 2020 14:57:25 +0200, James E Keenan <jkeenan@pobox.com> wrote:

> We first have to get to a point where we have a Perl 7 that's usable
> enough for people to try out. Some of us are working on that now, and I
> hope more people join that effort.

Is there a public todo list?

--
With regards,
Christian Walde
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On 8/11/20 3:53 PM, Christian Walde wrote:
> On Tue, 11 Aug 2020 14:57:25 +0200, James E Keenan <jkeenan@pobox.com>
> wrote:
>
>> We first have to get to a point where we have a Perl 7 that's usable
>> enough for people to try out.? Some of us are working on that now, and I
>> hope more people join that effort.
>
> Is there a public todo list?
>

https://github.com/Perl/perl5/wiki/Defaults-for-v7

Our research plan to implement the version bump and the first 14
numbered items on that wiki page takes the form of 15 objectives, for
each of which there is a ticket in
https://github.com/atoomic/perl/issues. See, for example, Objective 1:
https://github.com/atoomic/perl/issues/152

In our research, Objective 1 has been achieved and we're now working on
Objective 2.

Thank you very much.
Jim Keenan
Re: Changed defaults - Are they best for newbies? [ In reply to ]
Op 11-08-20 om 18:43 schreef Tom Molesworth via perl5-porters:
>
> This goes back to the original point - Perl does not exist in a
> vacuum! There's a considerable amount of existing code, documentation
> (both tutorial and reference) and developer teams out there. Do we
> really want to insist that every Perl module and script *must* have
> this new line added before it even runs?
>
> Making old and new tutorials useful, and allowing old and new code to
> continue working, is simple: "use v7" for the new features, no changes
> to defaults.


I was under the impression this was already the concensus?


M4
Re: Changed defaults - Are they best for newbies? [ In reply to ]
> Having "use vX" be mandatory means that every old tutorial breaks - one of
> many reasons why it should *not* be mandatory.
>

I had to add "where X > 6" (that was what I originally meant, sorry for
confusion)
"use vX" will be mandatory for new features. Without it it will be always
perl 5.

As a result, any tutorial (already existing or new with use vX) will be
valid, "forever" (quoted)


>
> Given the sheer volume of the older tutorials out there, I would expect a
> dangerously high percentage of users to give up at this point, and switch
> to a language which *works* when they try one of the suggested examples.
> Those languages are not hard to find!
>
> This goes back to the original point - Perl does not exist in a vacuum!
> There's a considerable amount of existing code, documentation (both
> tutorial and reference) and developer teams out there. Do we really want to
> insist that every Perl module and script *must* have this new line added
> before it even runs?
>
> Making old and new tutorials useful, and allowing old and new code to
> continue working, is simple: "use v7" for the new features, no changes to
> defaults.
>
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On Tue, 11 Aug 2020 22:03:58 +0200, James E Keenan <jkeenan@pobox.com> wrote:
> On 8/11/20 3:53 PM, Christian Walde wrote:
>> On Tue, 11 Aug 2020 14:57:25 +0200, James E Keenan <jkeenan@pobox.com> wrote:
>>
>>> We first have to get to a point where we have a Perl 7 that's usable
>>> enough for people to try out. Some of us are working on that now, and I
>>> hope more people join that effort.
>>
>> Is there a public todo list?
>
> https://github.com/Perl/perl5/wiki/Defaults-for-v7
>
> Our research plan to implement the version bump and the first 14
> numbered items on that wiki page takes the form of 15 objectives, for
> each of which there is a ticket in
> https://github.com/atoomic/perl/issues. See, for example, Objective 1:
> https://github.com/atoomic/perl/issues/152
>
> In our research, Objective 1 has been achieved and we're now working on
> Objective 2.
>
> Thank you very much.

Thanks to you and the information given.

Some feedback for now, because i am a little short on time:

While information and tasks lists are there, and publicly accessible, the work on them seems to not have been announced to any thorough level; and they're not usefully discoverable to a curious soul.

How do you feel about drafting an explicit call to action suitable for posting to the list, bpo, reddit, perlcom, irc channels (+ whatever i'm forgetting now) that points at the current plan and guides people who want to help towards the tasks so they can figure out how they can help?

(Also, probably wanna link to it like this: https://github.com/atoomic/perl/issues?q=is%3Aissue+label%3Aobjective+sort%3Aname-desc )

--
With regards,
Christian Walde
Re: Changed defaults - Are they best for newbies? [ In reply to ]
I’m currently doing some iOS development, and as a comparative Swift newbie, “this article has good SEO juice but is years old, and now we do things differently” is a major problem. I’ve taken to restricting my searches to the last year to avoid accidentally reading up on what best practices were in 2015.

On 11 Aug 2020, at 13:30, Paul LeoNerd Evans <leonerd@leonerd.org.uk> wrote:
[…]
> Even with the most perfect and timely execution
> on a "Perl 7" release the world will continue in a mixed 5-or-7 state
> for a long time.
[…]
> We may be doing those new users a disservice if we go out and create a
> world in which suddenly there are "two different kinds of perl" and it
> is impossible for them to look at an online tutorial and know if it's
> good or not. The version of perl they're running has to match the
> version the tutorial was written for, and it may not be obvious -
> doubly so to the newbies it is aimed at.
[…]
> So they'll carry on writing... maybe they'll succeed in
> their task, or maybe they'll do something wrong that, had they had
> strict+warnings enabled, perl would have told them about. But because
> they're running on 5, not 7, those defaults didn't apply.
[…]
> To best help newbie users coming to Perl via tutorials and examples,
> it is important that we always show `use v7` at the top of all the
> code to ensure that they get the right behaviour if their perl version
> is too old.

(1) Should sample code say use v7?

I think there are two related issues here.

The first is immediately telling apart code vintage. You can visibly tell perl4 and perl5 code apart because perl4 doesn’t say “use strict”, and perl5 declares variables by saying “my $foo = …” rather than “$foo = …”. I’d hope that newbies would recognise perl4 code, even subconsciously, fairly quickly; but, yes, if there’s no difference between perl5 and perl7 code, then adding a distinctive “use v7” would be useful.

The second is avoiding accidentally telling newbies to write bad code. We’ve been spending years saying “always use strict and use warnings”, so having a shibboleth that makes sure they’re not accidentally e.g. using their system Perl rather than the perl 7 they just installed is useful.

So on those narrow grounds, I think strongly recommending that tutorials always explicitly say “use v7”, even if the language doesn’t require that, would be a Good Thing.

(2) Should *all* code say use v7?

As I understand it, the low-hanging-fruit stage of perl 7.0 is “let’s take the features that are uncontroversial and enable them by default, because that won’t break things and we’ll avoid a lot of pointless busy-work”. So strict, warnings, features like say and state etc.. In a way this is basically the same as CPAN modules like common::sense and Modern::Perl; I’m sure that most major Perl shops similarly have their own modules that import a whole bunch of standard pragmata into the calling code.

As I understand it, the plan for perl 7 has been that we should work out which mode any given code should run in by looking at pragmata:
* If code explicitly says use v7, import all of the perl 7 features;
* If code explicitly says use v5.xxx, use that version's defaults;
* If code explicitly says use strict, assume the perl 5.32 defaults

What I’ve never properly understood is what should happen if there’s no version declaration. I *think* the assumption is that if this is code that is being run directly (e.g. perl foo.pl), we should assume v7; I don’t know whether that also applies to used modules or not. If a module says “use Moose” but doesn’t explicitly say “use strict” (because, thanks to Moose importing strict into the calling package, it doesn’t need to), what do we do? The code uses Moose so is plausibly modern Perl, but maybe it does its own thing regarding Unicode, in which case importing unicode_strings would be a bug?

I think we’ve ducked this decision by including default pragmata in perl 7.0 that shouldn’t break anything. But eventually we’re going to include new defaults in 7.2, 7.4 or 8.0 that *will* break things.

(3) Let’s make specifying a version mandatory in 7.2 onwards

Ditching boilerplate is good. Ditching *all* boilerplate is perhaps extreme. Executable Perl code starts with a shebang; Perl 7 code can start with “use v7”. The best is the enemy of the good.

We can’t break people’s code without a warning, but maybe we should have perl 7.2 explicitly warn if it doesn’t see either a mandatory Perl version, or the ancient shibboleth “use strict” that implies perl5 mode? We can promote this to a fatal warning in 7.4 or something.

(I assume that if code has said “use v7”, “no strict ‘refs'” and then “use strict ‘refs’” we’ll understand that this is still Perl 7 code.)

Sam
--
Website: http://www.illuminated.co.uk
RE: Changed defaults - Are they best for newbies? [ In reply to ]
Please get real,

There are no "perl newbies" - right now perl people are those who started with perl some years ago and haven't switched yet for some (different) reasons.

To make perl actually "modern" there are few things to be done:
- improve perception (and I see that work is started in this direction)
- AI, ML packages (see this blog http://blogs.perl.org/users/sergey_kolychev/2017/02/machine-learning-in-perl.html - the more followers on this the better)
- modern techniques - like webassembly (WebPerl effort started - but where it is?)
- colorful repl - look into modejs and Julia REPL - these are modern-looking!

Those who insist that modernizing means adding "use v7, use warnings" everywhere - leading perl to more stagnation.
This kind of modernization started some 10+ years ago, it could be considered done - finished - so it is not a modernization anymore, this is a stale 10+-year thing

Vadim.

PS. Sorry for top-posting, my mailer is too stupid.


-----Original Message-----
From: Sam Kington <sam@illuminated.co.uk>
Sent: Wednesday, August 12, 2020 5:05 AM
To: Perl5 Porters
Subject: Re: Changed defaults - Are they best for newbies?


[EXTERNAL EMAIL]

I’m currently doing some iOS development, and as a comparative Swift newbie, “this article has good SEO juice but is years old, and now we do things differently” is a major problem. I’ve taken to restricting my searches to the last year to avoid accidentally reading up on what best practices were in 2015.

On 11 Aug 2020, at 13:30, Paul LeoNerd Evans <leonerd@leonerd.org.uk> wrote:
[…]
> Even with the most perfect and timely execution on a "Perl 7" release
> the world will continue in a mixed 5-or-7 state for a long time.
[…]
> We may be doing those new users a disservice if we go out and create a
> world in which suddenly there are "two different kinds of perl" and it
> is impossible for them to look at an online tutorial and know if it's
> good or not. The version of perl they're running has to match the
> version the tutorial was written for, and it may not be obvious -
> doubly so to the newbies it is aimed at.
[…]
> So they'll carry on writing... maybe they'll succeed in their task, or
> maybe they'll do something wrong that, had they had
> strict+warnings enabled, perl would have told them about. But because
> they're running on 5, not 7, those defaults didn't apply.
[…]
> To best help newbie users coming to Perl via tutorials and examples,
> it is important that we always show `use v7` at the top of all the
> code to ensure that they get the right behaviour if their perl version
> is too old.

(1) Should sample code say use v7?

I think there are two related issues here.

The first is immediately telling apart code vintage. You can visibly tell perl4 and perl5 code apart because perl4 doesn’t say “use strict”, and perl5 declares variables by saying “my $foo = …” rather than “$foo = …”. I’d hope that newbies would recognise perl4 code, even subconsciously, fairly quickly; but, yes, if there’s no difference between perl5 and perl7 code, then adding a distinctive “use v7” would be useful.

The second is avoiding accidentally telling newbies to write bad code. We’ve been spending years saying “always use strict and use warnings”, so having a shibboleth that makes sure they’re not accidentally e.g. using their system Perl rather than the perl 7 they just installed is useful.

So on those narrow grounds, I think strongly recommending that tutorials always explicitly say “use v7”, even if the language doesn’t require that, would be a Good Thing.

(2) Should *all* code say use v7?

As I understand it, the low-hanging-fruit stage of perl 7.0 is “let’s take the features that are uncontroversial and enable them by default, because that won’t break things and we’ll avoid a lot of pointless busy-work”. So strict, warnings, features like say and state etc.. In a way this is basically the same as CPAN modules like common::sense and Modern::Perl; I’m sure that most major Perl shops similarly have their own modules that import a whole bunch of standard pragmata into the calling code.

As I understand it, the plan for perl 7 has been that we should work out which mode any given code should run in by looking at pragmata:
* If code explicitly says use v7, import all of the perl 7 features;
* If code explicitly says use v5.xxx, use that version's defaults;
* If code explicitly says use strict, assume the perl 5.32 defaults

What I’ve never properly understood is what should happen if there’s no version declaration. I *think* the assumption is that if this is code that is being run directly (e.g. perl foo.pl), we should assume v7; I don’t know whether that also applies to used modules or not. If a module says “use Moose” but doesn’t explicitly say “use strict” (because, thanks to Moose importing strict into the calling package, it doesn’t need to), what do we do? The code uses Moose so is plausibly modern Perl, but maybe it does its own thing regarding Unicode, in which case importing unicode_strings would be a bug?

I think we’ve ducked this decision by including default pragmata in perl 7.0 that shouldn’t break anything. But eventually we’re going to include new defaults in 7.2, 7.4 or 8.0 that *will* break things.

(3) Let’s make specifying a version mandatory in 7.2 onwards

Ditching boilerplate is good. Ditching *all* boilerplate is perhaps extreme. Executable Perl code starts with a shebang; Perl 7 code can start with “use v7”. The best is the enemy of the good.

We can’t break people’s code without a warning, but maybe we should have perl 7.2 explicitly warn if it doesn’t see either a mandatory Perl version, or the ancient shibboleth “use strict” that implies perl5 mode? We can promote this to a fatal warning in 7.4 or something.

(I assume that if code has said “use v7”, “no strict ‘refs'” and then “use strict ‘refs’” we’ll understand that this is still Perl 7 code.)

Sam
--
Website: http://www.illuminated.co.uk
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On 8/12/20 2:25 AM, Konovalov, Vadim wrote:
> Please get real,
>
> There are no "perl newbies" - right now perl people are those who started with perl some years ago and haven't switched yet for some (different) reasons.

Actually there are newbies. Companies whose code base is perl do bring
on new hires who are inexperienced in it, and have to be taught. Some
of those companies have been rapidly growing. My understanding is that
it was Sawyer's job to provide training for such people at his company,
and there were a lot of them coming on board, and that was part of his
motivation for changing the defaults, based on what he experienced as
what they struggled with (unnecessarily).

The bottom line is that there is real field experience with wanting to
change the particular defaults that were chosen in the initial idea.
>
> To make perl actually "modern" there are few things to be done:
> - improve perception (and I see that work is started in this direction)
> - AI, ML packages (see this blog http://blogs.perl.org/users/sergey_kolychev/2017/02/machine-learning-in-perl.html - the more followers on this the better)
> - modern techniques - like webassembly (WebPerl effort started - but where it is?)
> - colorful repl - look into modejs and Julia REPL - these are modern-looking!
>
> Those who insist that modernizing means adding "use v7, use warnings" everywhere - leading perl to more stagnation.
> This kind of modernization started some 10+ years ago, it could be considered done - finished - so it is not a modernization anymore, this is a stale 10+-year thing
>
> Vadim.
>
> PS. Sorry for top-posting, my mailer is too stupid.
>
>
> -----Original Message-----
> From: Sam Kington <sam@illuminated.co.uk>
> Sent: Wednesday, August 12, 2020 5:05 AM
> To: Perl5 Porters
> Subject: Re: Changed defaults - Are they best for newbies?
>
>
> [EXTERNAL EMAIL]
>
> I’m currently doing some iOS development, and as a comparative Swift newbie, “this article has good SEO juice but is years old, and now we do things differently” is a major problem. I’ve taken to restricting my searches to the last year to avoid accidentally reading up on what best practices were in 2015.
>
> On 11 Aug 2020, at 13:30, Paul LeoNerd Evans <leonerd@leonerd.org.uk> wrote:
> […]
>> Even with the most perfect and timely execution on a "Perl 7" release
>> the world will continue in a mixed 5-or-7 state for a long time.
> […]
>> We may be doing those new users a disservice if we go out and create a
>> world in which suddenly there are "two different kinds of perl" and it
>> is impossible for them to look at an online tutorial and know if it's
>> good or not. The version of perl they're running has to match the
>> version the tutorial was written for, and it may not be obvious -
>> doubly so to the newbies it is aimed at.
> […]
>> So they'll carry on writing... maybe they'll succeed in their task, or
>> maybe they'll do something wrong that, had they had
>> strict+warnings enabled, perl would have told them about. But because
>> they're running on 5, not 7, those defaults didn't apply.
> […]
>> To best help newbie users coming to Perl via tutorials and examples,
>> it is important that we always show `use v7` at the top of all the
>> code to ensure that they get the right behaviour if their perl version
>> is too old.
>
> (1) Should sample code say use v7?
>
> I think there are two related issues here.
>
> The first is immediately telling apart code vintage. You can visibly tell perl4 and perl5 code apart because perl4 doesn’t say “use strict”, and perl5 declares variables by saying “my $foo = …” rather than “$foo = …”. I’d hope that newbies would recognise perl4 code, even subconsciously, fairly quickly; but, yes, if there’s no difference between perl5 and perl7 code, then adding a distinctive “use v7” would be useful.
>
> The second is avoiding accidentally telling newbies to write bad code. We’ve been spending years saying “always use strict and use warnings”, so having a shibboleth that makes sure they’re not accidentally e.g. using their system Perl rather than the perl 7 they just installed is useful.
>
> So on those narrow grounds, I think strongly recommending that tutorials always explicitly say “use v7”, even if the language doesn’t require that, would be a Good Thing.
>
> (2) Should *all* code say use v7?
>
> As I understand it, the low-hanging-fruit stage of perl 7.0 is “let’s take the features that are uncontroversial and enable them by default, because that won’t break things and we’ll avoid a lot of pointless busy-work”. So strict, warnings, features like say and state etc.. In a way this is basically the same as CPAN modules like common::sense and Modern::Perl; I’m sure that most major Perl shops similarly have their own modules that import a whole bunch of standard pragmata into the calling code.
>
> As I understand it, the plan for perl 7 has been that we should work out which mode any given code should run in by looking at pragmata:
> * If code explicitly says use v7, import all of the perl 7 features;
> * If code explicitly says use v5.xxx, use that version's defaults;
> * If code explicitly says use strict, assume the perl 5.32 defaults
>
> What I’ve never properly understood is what should happen if there’s no version declaration. I *think* the assumption is that if this is code that is being run directly (e.g. perl foo.pl), we should assume v7; I don’t know whether that also applies to used modules or not. If a module says “use Moose” but doesn’t explicitly say “use strict” (because, thanks to Moose importing strict into the calling package, it doesn’t need to), what do we do? The code uses Moose so is plausibly modern Perl, but maybe it does its own thing regarding Unicode, in which case importing unicode_strings would be a bug?
>
> I think we’ve ducked this decision by including default pragmata in perl 7.0 that shouldn’t break anything. But eventually we’re going to include new defaults in 7.2, 7.4 or 8.0 that *will* break things.
>
> (3) Let’s make specifying a version mandatory in 7.2 onwards
>
> Ditching boilerplate is good. Ditching *all* boilerplate is perhaps extreme. Executable Perl code starts with a shebang; Perl 7 code can start with “use v7”. The best is the enemy of the good.
>
> We can’t break people’s code without a warning, but maybe we should have perl 7.2 explicitly warn if it doesn’t see either a mandatory Perl version, or the ancient shibboleth “use strict” that implies perl5 mode? We can promote this to a fatal warning in 7.4 or something.
>
> (I assume that if code has said “use v7”, “no strict ‘refs'” and then “use strict ‘refs’” we’ll understand that this is still Perl 7 code.)
>
> Sam
> --
> Website: http://www.illuminated.co.uk
>
Re: Changed defaults - Are they best for newbies? [ In reply to ]
> On Aug 11, 2020, at 3:15 PM, Martijn Lievaart <m@rtij.nl> wrote:
>
>
> Op 11-08-20 om 18:43 schreef Tom Molesworth via perl5-porters:
>>
>> This goes back to the original point - Perl does not exist in a vacuum! There's a considerable amount of existing code, documentation (both tutorial and reference) and developer teams out there. Do we really want to insist that every Perl module and script *must* have this new line added before it even runs?
>>
>> Making old and new tutorials useful, and allowing old and new code to continue working, is simple: "use v7" for the new features, no changes to defaults.
>
> I was under the impression this was already the concensus?
>
At this point there is no concensus.

Todd
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On Fri, Aug 14, 2020, Todd Rinaldo wrote:
>
>
> > On Aug 11, 2020, at 3:15 PM, Martijn Lievaart <m@rtij.nl> wrote:
> >
> >
> > Op 11-08-20 om 18:43 schreef Tom Molesworth via perl5-porters:
> >>
> >> This goes back to the original point - Perl does not exist in a vacuum! There's a considerable amount of existing code, documentation (both tutorial and reference) and developer teams out there. Do we really want to insist that every Perl module and script *must* have this new line added before it even runs?
> >>
> >> Making old and new tutorials useful, and allowing old and new code to continue working, is simple: "use v7" for the new features, no changes to defaults.
> >
> > I was under the impression this was already the concensus?
> >
> At this point there is no concensus.

No, but this analysis seems to cover the issue and makes a
strong case that we should 'use v7'.

https://reddit.com/r/perl/comments/i9b9yl/perl_7_by_default/

I would like to hear a response from the Perl 7 steering
committee.

We are fortunate to have such lucid and able contributors
to the language.

> Todd
>

--
Joel Roth
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On Thu, 13 Aug 2020 17:57:14 +0200, Karl Williamson <public@khwilliamson.com> wrote:

> On 8/12/20 2:25 AM, Konovalov, Vadim wrote:
>> Please get real,
>>
>> There are no "perl newbies" - right now perl people are those who started with perl some years ago and haven't switched yet for some (different) reasons.
>
> Actually there are newbies. Companies whose code base is perl do bring
> on new hires who are inexperienced in it, and have to be taught. Some
> of those companies have been rapidly growing. My understanding is that
> it was Sawyer's job to provide training for such people at his company,
> and there were a lot of them coming on board, and that was part of his
> motivation for changing the defaults, based on what he experienced as
> what they struggled with (unnecessarily).
>
> The bottom line is that there is real field experience with wanting to
> change the particular defaults that were chosen in the initial idea.

There's two answers one could make to this:

Either one can recognize that there are numerous people who have been shepherding newbies for decades, at work, on IRC and elsewhere, and came to different conclusions about the effects of changing the defaults of unversioned code, and conclude that it might be worth actually investigating different training methods.

Or match your tone of voice and go:

The bottom line is that there is decades of real field experience in many people opposing the changing of defaults on versioned code.

--
With regards,
Christian Walde
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On Fri, 14 Aug 2020 17:38:07 +0200, Todd Rinaldo <toddr@cpanel.net> wrote:

>
>
>> On Aug 11, 2020, at 3:15 PM, Martijn Lievaart <m@rtij.nl> wrote:
>>
>>
>> Op 11-08-20 om 18:43 schreef Tom Molesworth via perl5-porters:
>>>
>>> This goes back to the original point - Perl does not exist in a vacuum! There's a considerable amount of existing code, >>>documentation (both tutorial and reference) and developer teams out there. Do we really want to insist that every Perl >>>module and script *must* have this new line added before it even runs?
>>>
>>> Making old and new tutorials useful, and allowing old and new code to continue working, is simple: "use v7" for the new >>>features, no changes to defaults.
>>
>>
>>
>> I was under the impression this was already the concensus?
> At this point there is no concensus.
> Todd
>

Yo hey, answer my question in the other thread.

--
With regards,
Christian Walde
Re: Changed defaults - Are they best for newbies? [ In reply to ]
On Sat, 15 Aug 2020 17:17:03 +0200, Christian Walde <walde.christian@gmail.com> wrote:

> On Fri, 14 Aug 2020 17:38:07 +0200, Todd Rinaldo <toddr@cpanel.net> wrote:
>
>>
>>
>>> On Aug 11, 2020, at 3:15 PM, Martijn Lievaart <m@rtij.nl> wrote:
>>>
>>>
>>> Op 11-08-20 om 18:43 schreef Tom Molesworth via perl5-porters:
>>>>
>>>> This goes back to the original point - Perl does not exist in a vacuum! There's a considerable amount of existing code, >>>>documentation (both tutorial and reference) and developer teams out there. Do we really want to insist that every Perl >>>>module and script *must* have this new line added before it even runs?
>>>>
>>>> Making old and new tutorials useful, and allowing old and new code to continue working, is simple: "use v7" for the new >>>>features, no changes to defaults.
>>>
>>>
>>>
>>> I was under the impression this was already the concensus?
>> At this point there is no concensus.
>> Todd
>>
>
> Yo hey, answer my question in the other thread.

Especially, like, given you're not actually making claims about the concensus, you created parts of the current concensus by making claims i said stuff i never did.

--
With regards,
Christian Walde