Day 1: Getting Rakudo

There are many different partial implementations of Perl 6; at the moment, the most complete is Rakudo. There are a number of different ways to get it up and running, but if you have any interest in tracking or helping with the development, the best approach is to download directly from the source repositories and and build your own copy.

To do so, you will need Subversion (svn), git, Perl 5.8 or newer, a C compiler, and a make utility. On standard Linux-like systems (including OS X), you can build it like this:

$ git clone git://github.com/rakudo/rakudo.git
$ cd rakudo
$ perl Configure.pl --gen-parrot
$ make
$ make test
$ make install

Subversion is needed to run –gen-parrot — it actually uses svn to get the appropriate version of parrot and then compile it.  You will need to use the appropriate make command for your system.  (It’s generally nmake with MS Visual C++, I believe.)

For current Rakudo, make install doesn’t install into your path, it merely preps the system so that you can run the perl6 executable (created in the rakudo directory) from any other directory on your system. Once you have it going, you can easily play around with Perl 6 by executing perl6 with no arguments, putting you into a REPL environment where you can type commands and see what they do. This can be incredibly handy for trying to figure out how Perl 6 works. For instance,

$ ./perl6
> say "Hello world!";
Hello world!
> say (10/7).WHAT
Rat()
> say [+] (1..999).grep( { $_ % 3 == 0 || $_ % 5 == 0 } );
233168

The lines starting with $ and > are what you type; the other lines are Rakudo’s response. The first example is a simple say statement. The second creates a rational number and asks WHAT its type is (Rat). The third takes the list of numbers from 1 to 999, filters out the ones not divisible by 3 or 5, sums them, and then says the result. (This is Project Euler Problem #1, thanks to draegtun for reminding me of it.) We’ll try to explain how these things work in a future post.

One last thing. If you have any difficulties getting Rakudo working, the #perl6 channel on irc.freenode.net is usually very helpful.

Perl 6 Advent Calendar

In the grand tradition of previous Perl Advent Calendars, we are going to post something we like about Perl 6 every day in December until Christmas.  This post will be updated daily to link to each post as a sort of table of contents, or you can follow this blog in the normal way you follow blogs.

Day 1: Getting Rakudo
Day 2: The Beauty Of Formatting
Day 3: Static Types and Multi Subs
Day 4: Testing
Day 5: Metaoperators
Day 6: Going Into Hyperspace
Day 7: Looping For Fun and Profit
Day 8: .comb Your Constraints
Day 9: Having Beautiful Arguments And Parameters
Day 10: A Regex Story
Day 11: Classes, Attributes, Methods, and More
Day 12: Modules and Exporting
Day 13: Junctions
Day 14: Going to the Rats
Day 15: .pick Your Game
Day 16: We Call It “The Old Switcheroo”
Day 17: Making Snowmen
Day 18: Roles
Day 19: Whatever
Day 20: Little Big Things
Day 21: Grammars and Actions
Day 22: Operator Overloading
Day 23: Lazy Fruits From the Gather of Eden
Day 24: The Perl 6 Standard Grammar
Merry Christmas!