Here are a few of my favourite Perl 6 selling points:

    * Compactness of expression:

        say 'Hello, World!';

    * Compactness of expression + semi-infinite data structures:

        @fib = 1,1...&[+]        # The entire Fibonacci sequence

    * Junctions make comparisons much more natural:

        if $dice_sum == 7 | 11 {
            say 'Natural!'
        }
        elsif $dice_sum == 2 | 3 | 12 {
            say 'Craps!'
        }

    * Given/when takes that even further:

        given $dice_sum {
            when 7 | 11     { say 'Natural!' }
            when 2 | 3 | 12 { say 'Craps!' }
        }

    * Junctions + n-ary comparison help too:

        if 0 < all(@coefficients) <= 1 {
            say 'Coefficients are already normalized.';
        }

    * Junctive comparisons + the max operator:

        if any(@new_values) > all(@existing_values) {
            $upper_limit = [max] @new_values;
        }

    * .invert and .push makes hashes (especially hoa's) vastly more useful
    (and .perl makes debugging vastly easier):

        my %comments =
            perl6 => <Amazing Revolutionary>,
            perl5 => <Essential Amazing>,
            perl4 => <Classic>,
            perl1 => <Classic>;

        my %epithets;
        %epithets.push(%comments.invert);

        say %comments.perl;
        say %epithets.perl;

    * Unicode source and data overthrows US cultural hegemony!
    (oh, and Hinrik has the coolest name in the entire Perl community :-)

        my @recepción;
        my $Gruß  = 'olá'
        my $óvoµa = 'Hinrik Örn Sigurðsson';

        push @recepción, "$Gruß, $óvoµa!";


    * Unary method call + topicalization simplifies multiple operations
    on objects:

        for @parcels {
            .address;
            .weigh;
            .ship;
            while .shipping {
                .fold;
                .spindle;
                .mutilate;
            }
            .deliver;
        }

    * Subtypes make typing far more precise (and hence more useful):

        my $filename of Str where /\w**8 '.' \w**3/;

        my $octet of Int where { 0 <= $^value <= 255 }



    * Command-line parsing using standard language features:

        sub MAIN ($text, Bool :f($foo), Str :B($bar), *...@files)
        {
            ...
        }

        # Can then be invoked as:

        > my_prog.p6 -f  -Bbaz  'two words'  file1 file2 etc


    * Grammars built into the language:

        grammar Expr::Arithetic {
            rule Expression { <Mult> ** $<OP>=< + - >   }
            rule Mult       { <Pow>  ** $<OP>=< * / % > }
            rule Pow        { <Term> ** $<OP>=< ^ >     }

            token Term {
                <Literal>
                | '('  <Expression>  ')'
            }

            token Literal { <[+\-]>? \d+ [ \. \d+ ]?  }
        }

    * Grammar inheritance:

        grammar Expr::Algebraic is Expr::Arithetic {
            token Literal {
                <alpha>+
                | <Expr::Arithetic::Literal>
            }
        }

    * "Only perl can parse Perl 5" but "Even Perl 6 can parse Perl 6":

        given $source_code {
            $parsetree = m:keepall/<Perl::prog>/;
        }


And that's without even mentioning all the new OO features, multiple
dispatch, roles, delegation, macros, etc., etc. The problem with demo-
ing the awesomeness of Perl 6 is always running out of demo time before
running out of demo-able awesomeness.

Damian

PS: A really mean, but very effective, way of emphasizing the ease,
    expressiveness, compactness, and readability of Perl 6 code is to
    take each of the examples and show the same thing written in
    Java. >;-)

Reply via email to