Live data from Hacker News

Differences Between Perl 5 and Perl 6

design.perl6.org

41–50 of 127 posts

Re: Differences Between Perl 5 and Perl 6

#41
post #4

Note that its more or less "how to write perl 5 in perl 6" Sorta like the old F2C, Fortran to C, converter. You don't get idiomatic C, but you do get a fortran program that compiles and runs as a C program, more or less. Some parts of perl6 are annoyingly urbit-y, come on, you guys just had to rename ARGV and rename scalar and the for-foreach transition is ridiculous. I suspect at least a decade of people pointing at…

In Perl 5, for and foreach have been aliases for eachover for a very, very long time.

    # perl -E 'foreach (my $i=0; $i
I never use foreach in Perl 5, and that's what I'm paid to write in. This is just a reaffirming that "for" is the preferred syntax (and this isn't a TMTOWTDI thing, this is two reserved words for the exact same code construct thing).

Moose, interestingly enough, is based on backporting the then-proposed Perl 6 object system, so a lot of the concept sand terminology will be the same.

But it sounds like you are talking about transitioning from Perl 5 to Perl 6. Why? The naming is confusing, but most people are not expected to convert codebases to Perl 6. It's not an upgrade, it an also. If you want both, use Inline::Perl5[1] and just call back and forth between the interpreters.

1: https://github.com/niner/Inline-Perl5

Re: Differences Between Perl 5 and Perl 6

#42
post #38

Earlier quoted context omitted.

It gets worse. "Hey, let's double down on weak typing!": http://examples.perl6.org/categories/cookbook/01strings/01-0... print +"" ; # a num-ified empty string evaluates as 0 print "1" + 1 ; # 2 The opportunity for insidious bugs (for the benefit of not having to type 'int("1") + 1' those times when you really need to do that) is a terrible tradeoff, in my opinion. In before "but Python...!". Python is strongly typed…

print "1" + 1 ; # 2 This isn't new, is it? '+' is for addition, '.' is for concatenation.

In Perl 5, yes. In Perl 6, ~ is for concatenation, '.' is for methods.

Re: Differences Between Perl 5 and Perl 6

#43
Do the changes to the regular expression syntax seem woefully under-publicized here?

    Was:    $str =~ m/^\d{2,5}\s/i
    Now:    $str ~~ m:P5:i/^\d{2,5}\s/ # :P5 indicates Perl5-compatibile regex syntax

    Was:    $str =~ s/(a)/$1/e;
    Now:    $str ~~ s:P5/(a)/{$0}/;    # $1 is now $0
I actually find the change from $1 to $0 particularly disturbing, since that is well standardized and group 0 normally refers to the whole matched pattern (though Perl had to give it a different name and for some reason has always discouraged its use).

They also provide no information here on the non-"Perl5-compatible" regexes, but they do talk about it a bit in Specification 5: http://design.perl6.org/S05.html There are some really interesting changes there, and we'll see what comes of this -- PCRE has become a de-facto standard, so I'm curious to see what happens as Perl moves away from "PCRE-compatible" syntax.

Re: Differences Between Perl 5 and Perl 6

#44

In multiple organizations I have primarily seen Perl applied to very large, complex and established code bases that also make significant use of things like reading/writing Perl data structures. Simply put, there will not be any grand push to re-sigil every stored data structure and make massive, sweeping changes to nearly every line to end up with the same program that looks, if anything, arguably less intuitive. Th…

Perl 6 developer here. Perl 6 is not an automatic upgrade path from Perl 5. We don't expect anybody to rewrite huge amounts of Perl 5 code in Perl 6. Perl 5 is going to be maintained separately. We do provide tools to augment Perl 5 code with Perl 6 code, and the other way around. There's Inline::Perl5 for Perl 6, and Inline::Perl6 for Perl 5.

IMHO Perl 6 will not catch on / be even mildly successful without a clear upgrade path from Perl 5.

The ask for people to use Perl6 is a huge one given it's basically a completely different beast that just resembles Perl5.

Without pointing out where Perl6 excels (in comparison to Python/Ruby not Perl5) this will probably be a non-starter for most people.

(this is from somebody who did his fair share of Perl5 in the old days and would not go back to Perl5 / try Perl6 unless there would be an extremely clear differentiator that would make it worth it.

Re: Differences Between Perl 5 and Perl 6

#45
post #35
post #11

Was: my $len = length($string); Now: my $len = $string.chars; My intuitive interpretation of that syntax would be "given a string, return a sequence containing its characters, in order". Or is that overlading on return type, and do you get the behavior I would find intuitive if one assigns to an array? Even if that is true, I find that ugly. I would prefer more explicit code, for example my $len = $string.chars.#; Si…

There's a specific reason why length was deprecated, and the error, which gives alternatives, may give some insight: # perl6 -e 'my $string = "foo"; say length $string;' ===SORRY!=== Error while compiling -e Undeclared routine: length used at line 1. Did you mean 'elems', 'chars', 'graphs', 'codes'? Perl 6 tries to get unicode right. In doing so, it makes a distinction between characters, elements, codepoints and gra…

That does shed some insight into why a generic Length is missing, but I agree with the sentiment that it is counter intuitive. It does not read right on a quick scan, and I think this is especially important in softly typed languages.

If I see string.chars I expect to see a bucket of char, and not the count of chars. That name needs to be more explicit.

Re: Differences Between Perl 5 and Perl 6

#46

>any two valid identifiers may be joined with a single ' to form a longer identifier Oh no.

It gets worse. "Hey, let's double down on weak typing!": http://examples.perl6.org/categories/cookbook/01strings/01-0... print +"" ; # a num-ified empty string evaluates as 0 print "1" + 1 ; # 2 The opportunity for insidious bugs (for the benefit of not having to type 'int("1") + 1' those times when you really need to do that) is a terrible tradeoff, in my opinion. In before "but Python...!". Python is strongly typed…

This is not weak typing. Perl (both 5 and 6) use operators to define type context. It's entirely unambiguous whether you want to add something or concatenate strings because they are different operators.

  "1" + "1" # 2
  "1" . "1" # 11 (~ to concatenate in Perl 6)
  1 + 1 # 2
  1 . 1 # 11
When you perform a string operation on a numeric type, it stringifies the number, when you do a numeric operation on a string, it numerifies the string (and warns if it can't be cleanly done).

This isn't a typing problem, this is a commenting on language without actually knowing how it works problem. But that's nothing new, people have been doing that to Perl for a long time now.

Re: Differences Between Perl 5 and Perl 6

#47
post #26

Earlier quoted context omitted.

I'll probably be trouted by a Perl monk for saying it, but sometimes less is more.

Ha, what happens when one is 'trouted'?? It's been a number of years, and I can't check right now, but I believe that the amount of code in Perl6 is actually less than in Perl5. The amazing power that is Perl6 naturally falls out of a whole lot of experience and fantastic design decisions. Not to mention several great implementations. I'm a big fan of 'less is more' as well. In this case, you're literally correct: Pe…

I expect it's based on the /slap emote in IRC.

Wikipedia [0] has a page on it, from which I swipe the follwing:

`When someone does something inadvisable that they had the experience and intelligence to avoid, you may likely see the suggestion that they be "trouted"`

Trout slapping originated in 1995 with internet relay chat (IRC). While in an IRC chat room, the IRC client mIRC would allow users to enter the command:

  /slap Sam
  - Steve slaps Sam around a bit with a large trout

0: https://en.wikipedia.org/wiki/Wikipedia:Whacking_with_a_wet_...

Re: Differences Between Perl 5 and Perl 6

#48

>any two valid identifiers may be joined with a single ' to form a longer identifier Oh no.

It gets worse. "Hey, let's double down on weak typing!": http://examples.perl6.org/categories/cookbook/01strings/01-0... print +"" ; # a num-ified empty string evaluates as 0 print "1" + 1 ; # 2 The opportunity for insidious bugs (for the benefit of not having to type 'int("1") + 1' those times when you really need to do that) is a terrible tradeoff, in my opinion. In before "but Python...!". Python is strongly typed…

Honestly, I think the Perl way is clearer than the Python way:

Perl: unary + is "convert to number", binary + is "convert operands to numbers and add". This is clear and consistent. String concatenation uses a different operator completely.

Python: binary + is string concatenation if the left operand is a string, and numeric addition if the left operator is a number. It fails at runtime if the right operator is inconsistent with the operation specified by the combination of the operator and the left operand.

Re: Differences Between Perl 5 and Perl 6

#49
post #44

Earlier quoted context omitted.

Perl 6 developer here. Perl 6 is not an automatic upgrade path from Perl 5. We don't expect anybody to rewrite huge amounts of Perl 5 code in Perl 6. Perl 5 is going to be maintained separately. We do provide tools to augment Perl 5 code with Perl 6 code, and the other way around. There's Inline::Perl5 for Perl 6, and Inline::Perl6 for Perl 5.

IMHO Perl 6 will not catch on / be even mildly successful without a clear upgrade path from Perl 5. The ask for people to use Perl6 is a huge one given it's basically a completely different beast that just resembles Perl5. Without pointing out where Perl6 excels (in comparison to Python/Ruby not Perl5) this will probably be a non-starter for most people. (this is from somebody who did his fair share of Perl5 in the o…

Did you actually look at Inline::Perl5[1] and Inline::Perl6? If may not be what you assume, and may change your opinion on whether an upgrade path is required. In short, Inline::Perl5 it's a way to interop cleanly with Perl 5 modules from Perl 6 using native Perl 6 syntax, and supports XS modules as well. I'm not sure I can imagine a more painless transition than what that allows.

1: https://github.com/niner/Inline-Perl5

Re: Differences Between Perl 5 and Perl 6

#50
post #46

Earlier quoted context omitted.

It gets worse. "Hey, let's double down on weak typing!": http://examples.perl6.org/categories/cookbook/01strings/01-0... print +"" ; # a num-ified empty string evaluates as 0 print "1" + 1 ; # 2 The opportunity for insidious bugs (for the benefit of not having to type 'int("1") + 1' those times when you really need to do that) is a terrible tradeoff, in my opinion. In before "but Python...!". Python is strongly typed…

This is not weak typing. Perl (both 5 and 6) use operators to define type context. It's entirely unambiguous whether you want to add something or concatenate strings because they are different operators . "1" + "1" # 2 "1" . "1" # 11 (~ to concatenate in Perl 6) 1 + 1 # 2 1 . 1 # 11 When you perform a string operation on a numeric type, it stringifies the number, when you do a numeric operation on a string, it numeri…

Ah, sorry. Despite having used Perl for years, I'd forgotten how much emphasis it puts on concepts that invoke a high cognitive load.
Post reply on HN