Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Downloaded it for a quick experiment. Points I've noticed so far:

* It needs perl5 to build.

* Hello World still works.

* Perl can now compete with Java for slow startup.

* One of my pet perl hates, the inability to write "sub foo($a, $b, $c) {" is fixed.



> One of my pet perl hates, the inability to write "sub foo($a, $b, $c) {" is fixed.

I think you're in for a good surprize there, you can even do

subset Even of Int where { $_ % 2 == 0 };

sub foo(Even $a) {say $a;}

foo(2); # prints 2

foo(3); # Constraint type check failed for parameter '$a'


One of my favorite examples of cool Perl 6 code right now is Perl 6 in Perl 6: http://github.com/masak/yapsi/blob/master/lib/Yapsi.pm


One perl6 project that looks very interesting is http://github.com/krunen/xml/

XML parser defined using perl6 grammar rules: http://github.com/krunen/xml/blob/master/lib/XML/Grammar/Doc...


I think I'm falling for perl all over again <3


oh God that looks absolutely delicious.


Yep very scrummy! And its also been available (for methods) in Perl5 for a while as well: http://news.ycombinator.com/item?id=1040614

Here is the perl6 example using MooseX::Declare (http://search.cpan.org/dist/MooseX-Declare/) in perl5:

    use 5.012;
    use MooseX::Declare;

    class Foo {
        use MooseX::Types -declare => [ qw(Even) ];
        use MooseX::Types::Moose qw(Int);

        BEGIN {
            subtype Even, as Int, where { $_ % 2 == 0 };
        }

        method bar ( Even $a ) { say $a }
    }

    my $foo = Foo->new;

    $foo->bar( 2 );  # => prints 2
    $foo->bar( 3 );  # => throws error


This is a cool capability. But I have to admit, it's lacking in the syntactic sugar that made the previous example look so appealing. I just simply read the code out loud in English and immediately knew what it meant. This is a bit more of a tongue twister. This notion of defining subsets of symbols like this could make code correctness for many cases a trivial thing.


Well, can you reasonably expect much else? It's a backported feature from perl6, constrained by the existing syntax of perl5. Of course it won't have the syntatic sugar.

One of the other cool capabilities of perl6 is the rules system, expanding on regexs so you can work with full on grammars. The perl6 grammar, written in perl6:

http://svn.pugscode.org/pugs/src/perl6/STD.pm6


No, I'm simply stating that I really like what they're doing with Perl 6 so far. I'm excited by the new grammar system immensely.

It's clear that doing it in an older syntax is clearly less elegant. However, it's very impressive though that the back ports of Perl 6 features to Perl 5 are proceeding relatively nicely though. The work on Perl 6 has definitely been a boon to 5.


The BEGIN { subtype ... } code is just pure perl/Moose. So its possible for the MooseX::Declare developers to add some extra sugar there.


It goes away as soon as you put the MooseX::Types declaration into its own package. Which one does pretty often, since reusing types and coercions produces more maintainable code in general. The title of that library isn't "Organise your Moose types in libraries" without reason :)


Perl can now compete with Java for slow startup.

That's my next area of focus for Rakudo optimizations.


That pet Perl hate was solved a while ago. See http://search.cpan.org/dist/MooseX-Declare/lib/MooseX/Declar...


See also http://search.cpan.org/dist/Function-Parameters for plain function signatures and http://search.cpan.org/dist/Method-Signatures-Simple for non-Moose method signatures.


Function::Parameters looks like more or less what I was looking for, although I continue to think the perl6 option is a little cleaner.


I built it two weeks ago and I noticed the slow startup too. I'm pretty sure this will improve. It needs to improve because it matters for shell glue. For the rest of the code I'm writing, startup time is a total non-issue.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: