Live data from Hacker News

Differences Between Perl 5 and Perl 6

design.perl6.org

31–40 of 127 posts

Re: Differences Between Perl 5 and Perl 6

#31
post #18

Earlier quoted context omitted.

this is a typo error actually: Now: my $len = $string.length; http://doc.perl6.org/type/Str#method_length EDIT: I don't see any contact section on their page to let them know

length is gone. See: http://design.perl6.org/S29.html#Obsolete_Functions "length() This word is banned in Perl 6. You must specify units. In practice, this probably means you want Str.chars(), although it could be Str.bytes(), or even something else. See S32-setting-library/String for details."

That's an interesting design decision, and I suppose it solves the Python problem of "I want to operate on any iterable, except for strings which are technically iterables but I want to treat them as atomic elements."

(Incidentally, does Python 3 have a solution to this problem?)

Re: Differences Between Perl 5 and Perl 6

#32

>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.

  >>> "1" + 1
  Traceback (most recent call last):
    File "", line 1, in 
  TypeError: cannot concatenate 'str' and 'int' objects
  >>> 1 + "1"
  Traceback (most recent call last):
    File "", line 1, in 
  TypeError: unsupported operand type(s) for +: 'int' and 'str'

Re: Differences Between Perl 5 and Perl 6

#33
post #15

To reuse the recent slogan, the only thing that changed is everything. It's a new language with its own internal logic. I used (and still use) Perl 5 because it made some specific things easy to make (various processing of data). I still don't know for which kind of tasks Perl 6 is the best choice. But maybe the language is simply too young for it to be obvious?

Perl6 is really a strict supserset of Perl5 in this way. Perl6 is at least as good as Perl5 for everything Perl5 is good at. But Perl6 is way, way more than that.

> Perl6 is really a strict supserset of Perl5 in this way.

How? And can you cite any sources that I can read? Thanks.

Re: Differences Between Perl 5 and Perl 6

#34
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.

This shows a profound unawareness of how Perl 5 was actually used in practice.

Re: Differences Between Perl 5 and Perl 6

#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 graphemes. At certain points, you may want one or the other of these.

When asking for the length of a string, what are you really asking for? The number of characters? Visible characters, or unicode combining characters? What if it's really the number of bytes in the string you need? Perl 6 makes it easy to determine all of these things in a clear manner. In doing so, it becomes obvious that "length" is ambiguous due to both its common specific role in other languages, and it's meaning when viewed in the context of these different needs.

If you want individual characters, you split the string, if you want access to the underlying data, you call .encode to get the encoding you expect, or you stick it into a Buf or Blob type if you don't actually need string semantics.

(Corrections welcome, I could be wrong at any number of points above).

Re: Differences Between Perl 5 and Perl 6

#36

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.

Re: Differences Between Perl 5 and Perl 6

#37
post #33

Earlier quoted context omitted.

Perl6 is really a strict supserset of Perl5 in this way. Perl6 is at least as good as Perl5 for everything Perl5 is good at. But Perl6 is way, way more than that.

> Perl6 is really a strict supserset of Perl5 in this way. How? And can you cite any sources that I can read? Thanks.

Well, I made a pretty grand statement there, which means it will be demonstrably wrong in at least some cases.

I don't have time to find supporting sources right now, but I'll just say a couple of things, regarding Perl6 and string manipulation.

Less concretely, Perl6 is still Perl. What does 'Perl' mean? "manipulexity and whipuptitude" :) To me, those things are about being highly pragmatic in as many real-life situations as possible.

More concretely, even though Perl6 has an amazing type system, it's almost all optional. Use it incrementally, as it becomes more useful.

Also, the tight and powerful integration between language and regex still exists.

So, again, regarding string processing, these elements, to me, show that Perl6 is a 'strict supserset' of Perl5.

And, without any citations, I feel like that 'strict superset' is mostly true for things other than string processing!

Re: Differences Between Perl 5 and Perl 6

#38

>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…

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

Re: Differences Between Perl 5 and Perl 6

#39
post #2

One thing that bugs is that perl5 code could potentially run with perl6. Is there any mitigation for that?

You should declare the version of your code. 'use v6;' for Perl 6 code (more specific versions will come up soon), and "use 5.014" for Perl 5.14, for example.

This will give good error messages when trying to run your code with the wrong compiler.

Re: Differences Between Perl 5 and Perl 6

#40
post #26

Earlier quoted context omitted.

Perl6 is really a strict supserset of Perl5 in this way. Perl6 is at least as good as Perl5 for everything Perl5 is good at. But Perl6 is way, way more than that.

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: Perl6 delivers a LOT MORE than Perl5 even though there's 'less to it'!

Post reply on HN