Recently in Perl 6 Category

Perlbuzz news roundup for 2010-08-27

| No Comments

These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com.

Vim 7.3 supports Perl 6, adds Perl 5 improvements

| 1 Comment

Vim 7.3 has just been released today. From the announcement:

This is a minor release of Vim. It consists of Vim 7.2 plus all patches, updated runtime files and some more, see below. It has been two years since the 7.2 release, thus it's not that "minor". But not "major" either. Something in between, don't know how to call that.

The most notable additions since 7.2:

  • Persistent undo and undo for reload
  • Blowfish encryption, encryption of the swap file
  • Conceal text
  • Lua interface
  • Python 3 interface

However, to the Perl programmer, this is a significant upgrade from 7.2, because of updates of all the Perl-related support files. Vim has language specific plugins for syntax highlighting, indenting and other filetype-related behaviors. Every one of these Perl-related support files has been updated. For example, syntax/perl.vim has not been updated since 2006. Now, Perl 5.10 keywords like given, when and state are properly highlighted.

For the Perl 6 hackers out there working with Rakudo Star, Vim now includes support for Perl 6. Until now, if Perl 6 programmers wanted Vim to support Perl 6, they had to use a perl6.vim file that got passed around from person to person. Now, it comes installed automatically as part of Vim 7.3.

Perl 6 detection is primitive, so you may have to explicitly add it to your modeline in your file, such as

# vi: filetype=perl6:

All of these changes are from the vim-perl project hosted on Github. In that project, I've aggregated syntax, indent and filetype plugins for the Perl and Perl 6 support files that get fed back to the Vim project. It's also got support for other filetypes like Template Toolkit that are not part of the vim distribution. I'm not making many changes to the Vim code directly. Like many of my other contributions to open source, my role is one of wrangler and coordinator and less of programmer and technologist.

If you're interested in Vim support for Perl 5 and Perl 6, I encourage you to check out the vim-perl project and join the vim-perl mailing list. Now that Vim 7.3 is out, we have some room to stretch out and make Vim do incredible things for Perl in the next release.

What's on your to-do list?

| 3 Comments

What's on your to-do list for Perl projects these days? Here's mine.

  • Test::Harness
    • Testing PHP code with Perl's prove program. I wrote code to do this under Test::Harness 2.x, but 3.x has an entirely different way to do it.
  • vim-perl
    • Just gave Bram the latest files for inclusion in vim 7.3
    • I want to have a test suite and a packaging system and to distribute it on CPAN
    • Write an FAQ and intro to let people know about cool tricks like "set equalprg=perltidy"
  • Rakudo Perl 6
    • Learning more Perl 6
    • Want to make perl101.org have parallel examples for Perl 5 and Perl 6.
  • Parrot patches
    • Fixing dependency problems in the Makefile
    • Checking regularly for errors that GCC's super-strict and persnickity warning settings turn up.
  • Updating links and articles on http://bobby-tables.com
    • I want bobby to be the canonical source to turn to help newbies know how to avoid SQL injection
  • Perlbuzz
    • Review of Effective Perl Programming
    • Aggregate information about Plack
    • Create a sitemap for Google's benefit
  • WWW::Mechanize
    • Making a ->text() method that caches its results, so that I can then...
    • Make Test::WWW::Mechanize's ->text_contains() method use it and not recalculate the same page contents over and over

I'm glad to hear "Rakudo is slow!"

| 4 Comments

I'm pretty tired of the sniping and punditry about the recent release of Rakudo Star. However, David Golden has put together a great article about what the Rakudo Star release means both to the team and to the public.

Key points from his article:

  • Rakudo Star is the first prototype of an end-user distribution tarball
  • There is no way reactions to Rakudo Star can possibly live up to the hopes and dreams of those involved the project (and I say that it can't live up to the expectations of those outside the project, either)
  • Rakudo Star still is a significant step forward for Perl 6
  • If anyone was waiting for Perl 6 to rescue Perl, then they'll need to keep waiting.

And then, down in the comments, Moritz Lenz points out something I'd overlooked:

Yes, people now say "Rakudo is slow as $funny_metaphor", but that's much better than "Rakudo is vapourware". Once we speed up Rakudo, we can simply post benchmarks and say "look, it's now $n times faster than before". "Rakudo is slow" implies "Rakudo is", and that's a big step forward.

Thanks for the reminder, Moritz. Next it will be "Rakudo is faster, but not fast enough." And then maybe "Rakudo doesn't have enough documentation," and then "Rakudo doesn't have all the modules it should." All of it is progress.

Perlbuzz news roundup for 2010-08-09

| No Comments

These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com.

What to respond to "Perl 6 isn't Perl any more"

| 23 Comments

Now that Rakudo Star is out, and people are able to easily install and work with an early implementation of Perl 6, the pundits and cranks have to put aside their tired Duke Nukem jokes and talk about how different Perl 6 is from Perl 5. They gripe that everything is different and scary, "it shouldn't be called Perl any more." I'm tired of it, and it makes no sense.

I bet none of those cranks remember Perl 4 and the shift to Perl 5.

  • Perl 4 didn't have lexical (my) variables
  • and there were no scalar filehandles
  • and you couldn't pass filehandles as parameters to functions except with typeglobs
  • and the package separator was ', not ::
  • and really nobody used packages anyway
  • and there was no object support whatsoever
  • and that meant no modules to speak of
  • and you couldn't pass around regexes as scalars (qr// operator)
  • and on and on.

Even with all those differences, we survived. In fact, we thrived.

The Pink Camel, first edition of Programming Perl, covering Perl 4, was only 450 small pages long, and a third of that was a section called "Real Perl Programs." (Imagine! Actual programs!) The Blue Camel, the 2nd edition, covering Perl 5, was over 600 bigger pages.

You know what I thought when I got my copy of the Blue Camel? It wasn't "Boy, this sure isn't Perl any more." No, I thought "Holy shit, look at all the stuff I can do." I couldn't even read the book straight through, because I kept skipping around, my mind amazed at the possibilities in front of me.

There are those who will read this and say "Yeah, but Perl 5 could still pretty much run any Perl 4 program, but Perl 6 won't be able to run Perl 5." And that's true. And it's irrelevant.

Perl 6 is still Perl, and is still called Perl, for many reasons, but only one that matters.

Larry Wall says that Perl 6 is still Perl.

Larry has his reasons. Some he's mentioned in past State of the Onion addresses. Maybe you don't agree with his reasons, or his decisions. But it doesn't matter one damn bit what you think. It's his decision. All arguments are a waste of time and brain cycles.

So when someone says "Perl 6 should have been named something else," I suggest a response of "OK, whatever you say. Now, isn't it cool that you can use list reduction to say my $sum = [+] @list;?"

Perl 6 has data dumping built in

| 2 Comments

Any Perl 5 programmer who's worked with Perl 5 more than a few months has learned about how invaluable the Data::Dumper module is. The ability to say

use Data::Dumper;
print Dumper( \%hash );

is a godsend to debugging data structures of any complexity.

Perl 6 has this dumping built in.

uniqua:~/rakudo/lab $ cat dumper
#!/usr/local/bin/perl6

use v6;

my %hash = (
    'this'     => 'that',
    'year'     => 2112,
    'matcher'  => regex { ^ M(r|rs|s)\. \s+ (\w+) \s+ Wall $ },
    'rational' => 0.5,
    'num'      => (0.5).Num,
);

say %hash.perl;
# Or %hash.perl.say

uniqua:~/rakudo/lab $ ./dumper
{"num" => 0.5, "this" => "that", "year" => 2112,
"rational" => 1/2, "matcher" => { ... }}

Regex dumping does not display the actual regex yet, but Patrick Michaud says it's coming soon.

Diving into Perl 6

| 7 Comments

I'm officially diving into Perl 6.

I wrote my first real Perl 6 from scratch today. It's a prime number tester, where we test both via checking factors iteratively, and also using the magic prime number tester regular expression. I was inspired by a blog post about how PHP can't always handle regexes with lots of backtracking, and I thought it would make a good stress for Perl 6.

My program as it stands now looks like this:

#!/usr/local/bin/perl6

use v6;

# Perl 5 @ARGV is now @*ARGS
my Int @candidates;
if ( @*ARGS ) {
    for @*ARGS -> $n {
        push @candidates, $n.Int;
    }
}
else {
    @candidates = 2 .. 100;
}

for @candidates -> Int $x {
    my $via_factors = is_prime_via_factors($x);
    my $via_regex   = is_prime_via_regex($x);

    if $via_factors && $via_regex {
        say "$x is prime";
    }
    elsif $via_factors xor $via_regex {
        say "Difference in opinion on $x :",
            "factors says $via_factors, regex says $via_regex";
    }
}


sub is_prime_via_factors( Int $n ) returns Bool {
    my $top = sqrt $n;

    for 2..$top -> $i {
        return False if $n %% $i;
        # %% is the divisible-by operator
    }
    # Could also use:  $n %% none(2 .. $top)

    return True;
}


sub is_prime_via_regex( Int $n ) returns Bool {
    my $str = 'x' x $n;

    # First capture is $0, not $1 or \1 as in Perl 5
    return False if $str ~~ regex { ^ x $ | ^ (xx+?) $0+ $ };

    return True;
}

I'm sure there are ways that are more Perl 6ish to do what I've done above, but I was glad to learn along the way. Big thanks to the #perl6 IRC channel for help. Some important lessons:

  • Command-line args are in @*ARGS, not @ARGV.
  • The old chestnut ($x mod $y == 0) is now ($x %% $y) with the %% divisible-by operator.
  • The first capture group in a regex is $0, not $1 or \1 as in Perl 5.

There's a document about the differences between Perl 5 and Perl 6 which I updated based on tonight's fun, and will keep adding to along the way.

My goal is to have all of perl101.org include examples in both Perl 5 and Perl 6, both for people new to Perl and for those moving to Perl 6. If you'd like to help in this effort, let me know or work on the perl101 github project.

Rakudo Star, for early adopters of Perl 6, now available

| No Comments

By Patrick Michaud, release manager for Rakudo Perl 6

On behalf of the Rakudo and Perl 6 development teams, I'm happy to announce the July 2010 release of "Rakudo Star", a useful and usable distribution of Perl 6. The tarball for the July 2010 release is available from http://github.com/rakudo/star/downloads.

Rakudo Star is aimed at "early adopters" of Perl 6. We know that it still has some bugs, it is far slower than it ought to be, and there are some advanced pieces of the Perl 6 language specification that aren't implemented yet. But Rakudo Perl 6 in its current form is also proving to be viable (and fun) for developing applications and exploring a great new language. These "Star" releases are intended to make Perl 6 more widely available to programmers, grow the Perl 6 codebase, and gain additional end-user feedback about the Perl 6 language and Rakudo's implementation of it.

In the Perl 6 world, we make a distinction between the language ("Perl 6") and specific implementations of the language such as "Rakudo Perl". "Rakudo Star" is a distribution that includes release #31 of the Rakudo Perl 6 "compiler, version 2.6.0 of the Parrot Virtual Machine, and various modules, documentation, and other resources collected from the Perl 6 community. We plan to make Rakudo Star releases on a monthly schedule, with occasional special releases in response to important bugfixes or changes.

Some of the many cool Perl 6 features that are available in this release of Rakudo Star:

  • Perl 6 grammars and regexes
  • formal parameter lists and signatures
  • metaoperators
  • gradual typing
  • a powerful object model, including roles and classes
  • lazy list evaluation
  • multiple dispatch
  • smart matching
  • junctions and autothreading
  • operator overloading (limited forms for now)
  • introspection
  • currying
  • a rich library of builtin operators, functions, and types
  • an interactive read-evaluation-print loop
  • Unicode at the codepoint level
  • resumable exceptions

There are some key features of Perl 6 that Rakudo Star does not yet handle appropriately, although they will appear in upcoming releases. Thus, we do not consider Rakudo Star to be a "Perl 6.0.0" or "1.0" release.

In many places we've tried to make Rakudo smart enough to inform the programmer that a given feature isn't implemented, but there are many that we've missed. Bug reports about missing and broken features are welcomed.

See http://perl6.org/ for links to much more information about Perl 6, including documentation, example code, tutorials, reference materials, specification documents, and other supporting resources. Rakudo Star also contains a draft of a Perl 6 book -- see in the release tarball.

The development team thanks all of the contributors and sponsors for making Rakudo Star possible. If you would like to contribute, see http://rakudo.org/how-to-help, ask on the perl6-compiler@perl.org mailing list, or join us on IRC #perl6 on freenode.

Rakudo Star releases are created on a monthly cycle or as needed in response to important bug fixes or improvements. The next planned release of Rakudo Star will be on August 24, 2010.

Perlbuzz news roundup for 2010-07-27

| No Comments


These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com.

« Perl 5 | Main Index | Archives | Perl Foundation »