Maybe we should be spending our time deciding what to call "Perl 6," since it obviously isn't "Perl." At best, it's a language that adopted a few keywords, like my and use, but it bears no resemblance (nor compatibility) at all to its erstwhile namesake. On a boring night, maybe that would be a more productive thing to think about than bottles of beer ... or, maybe not. | [reply] |
Yes, I hear this suggestion a great deal. In fact, I've been hearing it
for 20 years now...and mostly against Perl 5 itself:
- Damian (in early 1995), commenting on a Perl 4 solution:
- Of course, nowadays I'd write
it in Perl 5.0, taking advantage of references, lexical
variables, object-orientation, ties, autoloading, threads,
better regexes, and modules.
- Anonymous Perl 4 user:
- Maybe we should be spending our
time deciding what to call "Perl 5," since it obviously
isn't "Perl." At best, it's a language that adopted a few
keywords, like local and do, but
it bears no resemblance (nor compatibility) at all to its
erstwhile namesake.
. . .
- Damian (in early 2014), commenting on a Perl 5.8 solution:
- Of course, nowadays I'd write it in Perl 5.20, taking advantage
of defined-or, switches, object filehandles, smartmatching, state
variables, postfix dereferences, subroutine parameter lists, lexical
subroutines, named captures, independent subpatterns, C3 method
resolution, and autodie.
- Anonymous Perl 5.8 user:
- Maybe we should be spending our
time deciding what to call "Perl 5.20," since it obviously
isn't "Perl." At best, it's a language that adopted a few
keywords, like my and use, but
it bears no resemblance (nor compatibility) at all to its
erstwhile namesake.
It's almost as if some people feel that the motto "There's more than one way to do it" applies
to everything about Perl...except Perl itself.
But, in my opinion, "Perlishness" isn't really about syntax, or semantics, or
even features. It's about the belief that programming languages should
be designed to be flexible and powerful, and should come with all the
useful tools and data structures built in, and should make easy things
easy and hard things possible, and should do so without getting in your
way. And by every one of those measures, Perl 6 is arguably
more Perlish than Perl 5.
And as for "no resemblance (nor compatibility) at all to its erstwhile namesake",
remember that I deliberately chose a Perl 6 approach that emphasized that language's
many new features. The following is also a pure Perl 6 version of "bottles of beer":
my @bottles_of_beer
= map {join "", "$_ bottle", $_ ne 1 && 's' || '', " of beer"},
'No', 1..99;
my $n = 99;
while ($n > 0) {
say "@bottles_of_beer[$n] on the wall,\n",
"@bottles_of_beer[$n].\n",
"Take one down, pass it around,\n",
"@bottles_of_beer[--$n] on the wall.\n";
}
I think you'd have to concede that this version bears at least some resemblance to (and
compatibility with) Perl 5, given that it differs from being executable Perl 5 by exactly one character.
Or I could have written my Perl 6 version "bottles of beer" like this:
sub bottles {
my ($n) = @_;
return "No bottles" if $n == 0;
return "1 bottle" if $n == 1;
return "$n bottles";
}
for (reverse 1..99) {
say bottles($_), " of beer on the wall,";
say bottles($_), " of beer.";
say "Take one down, pass it around:";
say bottles($_ - 1), " of beer on the wall.";
say "";
}
...which is executable Perl 6 and also executable Perl 5.
So, sure, when I use just the new features of Perl 6, it seems like a language entirely different from Perl 5.
But that's just as true when I use the new features of Perl 5.20 and it seems like an entirely different
language to Perl 5.8. Or when I use the new features of Perl 5.8 and it seems like an entirely different
language to Perl 4. That's just the nature of all programming language development.
Damian
| [reply] [d/l] [select] |