
There's been a longstanding jest that says "You'll have Perl 6 for Christmas" but goes on to add "but of course we won't tell you
which Christmas."
Christmas may have arrived early this year ... for this morning I downloaded Rakudo Star - the November 2010 release that's been out for about a week ... according to Github 200 people had got there before me, so perhaps I'm still a bit leading edge. The Rakudo team describe it as
"a useful and usable distribution of Perl 6" ... I haven't thrown enough at it yet to be sure but first impressions are that their claims are valid.
Rakudo Star unpacked, and built easily from source on my Mac (MacBook Pro with Developer's Xcode, running OS X 10.6.4) ... in a nutshell:
cd /usr/local
sudo tar xf ~/Downloads/rakudo-star-2010.11.tar
sudo chown -R graham rakudo-star-2010.11
cd rakudo-star-2010.11/
perl Configure.pl --gen-parrot
make
make install
cd /usr/local
sudo ln -s /usr/local/rakudo-star-2010.11 perl6
and into my ~/.bash_profile file add
export PATH=/usr/local/perl6:$PATH
then (
in a window that's freshly creates to check the new path ...)
wizard:dec10 graham$ perl6
> print "Hello World\n";
Hello World
> exit
wizard:dec10 graham$
(
Goodness - it's nice to have the interactive shell come up like that)
Let's try a real (Perl 5) program and - yes - that's going to throw up the compatibility issues:
sub ladder {
$plen = sqrt($_[0] ** 2 + $_[1] ** 2);
}
print "Hello World\n";
$moat = ladder(5,12);
$building = ladder(3,4);
print "Ladder lengths needed are $moat and $building\n";
wizard:dec10 graham$ perl oldperl.pl
Hello World
Ladder lengths needed are 13 and 5
wizard:dec10 graham$
but
wizard:dec10 graham$ perl6 oldperl.pl
===SORRY!===
Symbol '$plen' not predeclared in ladder (oldperl.pl:3)
wizard:dec10 graham$
And - straight away - you see the first "fix" - variables are no longer default global, even without the "use strict;".
Thank Goodness!
Let's rewrite that code, but pull in another of the Perl 6 new features - named parameters:
sub ladder($width, $height) {
my $plen;
$plen = sqrt($width ** 2 + $height ** 2);
}
print "Hello World\n";
my $moat = ladder(5,12);
my $building = ladder(3,4);
print "Ladder lengths needed are $moat and $building\n";
Of course, that fails with Perl 5:
wizard:dec10 graham$ perl newperl.pl
Malformed prototype for main::ladder: $width,$height at newperl.pl line 8.
wizard:dec10 graham$
but it runs sweetly on Rakudo Star:
wizard:dec10 graham$ perl6 newperl.pl
Hello World
Ladder lengths needed are 13 and 5
wizard:dec10 graham$
There's a second of the big potential criticisms of Perl 5 wiped out -
Wow!
Now - you should NOT consider that Rakudo Star is Perl 6.0.0 or anything like that - there are still some features to be tested and implemented; they're listed in more detail at
http://rakudo.org/announce/rakudo-star/2010.11, but it is an excellent step and something that's becoming very practical indeed to start using. And I have to say I have been very impressed this morning - it downloaded, unpacked, compiled, ran my little tests flawlessly.
The Mac I used is the presentation machine. So Perl 6 (Rakudo Star) will be available for use on forthcoming courses. That's not to say that we'll switch straight over - we will NOT - but we will be able to add flesh to an introductory talk about Perl 6 by running it, and we'll be able to delve in deeper as and if our delegates require / request us to do so.
I think I'm going to have a good Christmas this year (although I may be slightly inseparable from my keyboard) ... and I go forward with a new spring in my step; it now looks much more likely that Perl will still be one of our major training language even in 2020.
Now if you'll excuse me, I'm off to play with the samples, and write a lot more code of my own.
The 'story' behind this application / sample program is told
[here] (and that also tells you why there's a picture of Edinburgh Castle illustrating the article)
The Perl 5 source of the example above is
[here]
The Perl 6 source of the example above is
[here] (written 2010-12-02, updated 2010-12-04)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P256 - Perl 6 Look Ahead [89] When will Perl 6 be available - (2004-10-15)
[113] A Parallel for Perl 6 - (2004-11-09)
[550] 2006 - Making business a pleasure - (2006-01-01)
[582] DWIM and AWWO - (2006-01-30)
[995] Ruby's case - no break - (2006-12-17)
[1215] An update on Perl - where is it going? - (2007-06-03)
[1417] What software version do we teach? - (2007-10-31)
[1721] Perl 6 - When will we have a production release? - (2008-07-26)
[2559] Moving the product forward - ours, and MySQL, Perl, PHP and Python too - (2010-01-01)
[2815] switch and case, or given and when in Perl - (2010-06-17)
[2816] Intelligent Matching in Perl - (2010-06-18)
[2817] Setting a safety net or fallback value in Perl - (2010-06-19)
[2967] Multiway branches in Perl - the given and when syntax - (2010-09-22)
Some other Articles
wxPython - simple example to add GUI to a server log file analysisSanta Special - rather more special than usual - December 2010TransWilts Rail News ... Melksham (Santa Special) Edition ... 5th December 2010Royal Wedding. How William and Catherine have changed our schedulePerl 6 - significantly nearer, and Rakudo looks very goodPython through the SnowChange of balance, of attitude, and of work methodRunning a course ... what if the tutor isn't well?Customer Service - the boundaryFinding elements common to many lists / arrays