Welcome to thatlinuxbox.com Wednesday, April 24 2024 @ 03:17 AM UTC

Getting Started with Perl 6

  • Wednesday, March 11 2015 @ 12:07 AM UTC
  • Contributed by:
  • Views: 8,438
Linux, Open Source, and Tech Stuff

Share
  • Google Plus
  • Facebook
  • Twitter
  • Reddit
  • LinkedIn
  • Digg

The goal of this blog post is to document the steps needed to install and run Rakudo Perl, which is a "useful and usable distribution" of Perl 6

The #perl6 IRC channel on freenode has been very active the few times I popped in with questions and I was able to get them answered very quickly. Larry Wall announced that he wants to release Perl 6 by Christmas 2015 ( http://http://blogs.perl.org/users/shadowcat_mdk/2015/02/fosdem-2015-its-christmas.html ) and at this point it seems like the Perl 6 community is moving along on its merry way towards that goal.  The Perl 6 design documents are interesting ( http://design.perl6.org/ ), especially the Apocolypse docs which talk about the various aspects compared to Perl 5 and nice tidbits such as "Larry's First Law of Language Redesign."

Perl 6 even has its own logo:

Ubuntu and Debian already contain Perl 6 in their repositories. The 'rakudo' package description on Ubuntu 14.04 is "Perl 6 implementation on top of Parrot virtual machine".  I did not test this but it should be easily installable via:

$ apt-get install rakudo

In Fedora the package is named rakudo-star.
 
$ yum install rakudo-star
 
It looks like a very old version of the package is available in EPEL 6 for RHEL / CentOS so for those distros I recommend downloading and building from source. I did not see a package for EPEL 7 nor is Perl 6 in Red Hat Software Collections. It might be a good time to poke the package maintainers for an update if you are interested in running Rakudo Perl on Red Hat flavors of Linux and want distro-maintained packages.
 
 
I chose to use MoarVM by downloading and compling the Rakudo Star Perl 6 bundle from the rakudo website. It seemed to work fine in my testing.
 

Get Rakudo Perl:

http://rakudo.org/how-to-get-rakudo/

 

I chose the most recent release at the time, Rakudo Star release 2015.02.

$ wget http://rakudo.org/downloads/star/rakudo-star-2015.02.tar.gz

$ tar -xvzf rakudo-star-2015.02.tar.gz 
rakudo-star-2015.02/Configure.pl
rakudo-star-2015.02/docs/announce/2010.07
rakudo-star-2015.02/docs/announce/2010.08
rakudo-star-2015.02/docs/announce/2010.09
...

$ cd rakudo-star-2015.02/

The build process is pretty standard for perl which means you run 'Configure.pl', 'make', and 'make install'. This is all documented in the README text file as well as some of the other build options. I first decided to only build the MoarVM (not Parrot or the JVM) and just install everything under my Downloads directory. This did not require any additional privileges or root access.

Requirements (From the README):

"To build Rakudo Star on MoarVM, you need at least a 'make' utility, a C compiler, and Perl 5.10.0 or newer. Building Rakudo on MoarVM needs a machine with a gigabyte of memory". On a bare minimal Linux install, I had to install the 'perl' and 'gcc' packages (that's Perl 5 just to be clear) before the following commands would work. I was able to complete the build ok on a machine with 512 MB of RAM but be warned, YMMV.

 

Run Configure.pl (this uses Perl 5 to do the initial work):

$ perl Configure.pl --backend=moar --gen-moar
ATTENTION: no --prefix supplied, building and installing to /home/dan/Downloads/rakudo-star-2015.02/install

Configuring and building MoarVM ...

/usr/bin/perl Configure.pl --optimize --prefix=/home/dan/Downloads/rakudo-star-2015.02/install --make-install

Welcome to MoarVM!

Configuring native build environment ................... OK
  probing whether your compiler thinks that it is gcc  YES
...
You can now use 'make' to build Rakudo.
After that, 'make test' will run some tests and
'make install' will install Rakudo.

 

Then run 'make':

$ make
== Configuring and building Rakudo
cd rakudo && /usr/bin/perl Configure.pl --prefix=/home/dan/Downloads/rakudo-star-2015.02/install --backends=moar && make
Using /home/dan/Downloads/rakudo-star-2015.02/install/bin/nqp-m (version 2015.02 / MoarVM 2015.02).
Cleaning up ...
...

 

Then run 'make install':

$ make install
cd rakudo && make install
make[1]: Entering directory `/home/dan/Downloads/rakudo-star-2015.02/rakudo'
/usr/bin/perl -MExtUtils::Command -e mkpath /home/dan/Downloads/rakudo-star-2015.02/install/bin
/usr/bin/perl -MExtUtils::Command -e mkpath /home/dan/Downloads/rakudo-star-2015.02/install/languages/nqp/lib/Perl6
...

You will now have an executable named "perl6" in the current directory. The perl6 executable is actually a shell script that starts the moar vm with the appropriate environment set. To run perl6 you can either just specify the path to the binary or add that bin directory to your PATH environment variable.

$ ./perl6 --version
This is perl6 version 2015.02 built on MoarVM version 2015.02

 

Rakudo comes bundled with panda, the perl 6 package installer. If I wanted to install HTTP::UserAgent module I would run (specifying the path to the "panda" binary since I haven't added that directory to my PATH):

$ ./install/bin/panda install HTTP::UserAgent

Note that the current version of panda that is included with Rakudo has some external dependencies. On a minimal system I needed to install the perl5 module 'Test::Harness' as well as the 'git' binary. It seems like panda has to be run twice the first time since it complains about not having a writable directory.

A list of available perl 6 modules is available:

http://modules.perl6.org/

Some of the modules are still a work-in-progress and do not yet include all of the features from the equivalent Perl 5 module. There is a nice opportunity here for participation in an open source project to improve the Perl 6 module converage.

 

To install perl6 for the system rather than just for an individual user, you can go back to the rakudo-star directory and re-run perl Configure.pl with a different set of options. Using the prefix option such as:

--prefix=/usr/local/

with sudo (or as root) is a sane install location for many Linux distributions. The higher level of privs are required for each step (not just 'make install') because the intermediate steps actually build the helper binaries, libs, and the vm and cannot be installed under /usr/local/ as a normal user on most systems.

$ sudo perl Configure.pl --backend=moar --gen-moar --prefix=/usr/local/

If you are rebuilding again from the same directory to install for the system, run 'make clean' first. Run 'make' and 'make install' with sudo. The runtime components (and panda) are then placed in subdirectories under /usr/local/ which on my system were already in my PATH.

What's so good about Perl 6? One of the nice things I noticed immediately is the color-coded compiler errors that frequently point to the exact location in the code where the problem occurred. For example, if I expand my Hello World program just a bit and forget a semicolon the output includes a pointer right to the syntax error:

After fixing the line terminator the code runs just fine.

In the example above I was using emacs cmode-perl for syntax highlighting, which is usable to get started but misses some perl6-specific things. I have not had a chance to evaluate any of the perl6 emacs modes that are available on github and elsewhere.

 

Besides IRC and the mailing lists, these projects have issue trackers. So far, almost every issue I have discovered is already reported and being tracked. One documentation question I asked in the IRC channel immediately triggered a new Issue creation. These are signs of a healthy, active community.

The Rakudo Perl project is using RT for issue tracking: http://rakudo.org/tickets/

The panda package installer is using GitHub Issues: https://github.com/tadzik/panda/

 

Getting Started with Perl 6 | 0 comments | Create New Account

The following comments are owned by whomever posted them. This site is not responsible for what they say.


User Functions

Login

Connect

thatlinuxbox.com is the home of Dan Stoner's Personal Blog, Photos, and More (opinions, rants, techno-babble, and possibly a few useful tidbits of knowledge).

Questions or Comments about this site? Contact danstoner _ at _ gmail.com.

RSS Feed for this blog

Other places to find me on the web:

Twitter

LinkedIn

GitHub

Support This Site

If you like something that you find on this site, please consider making a purchase through one of the links below or sending me an item from my Amazon Wish List.


The Clymb


Awesome VPS hosting by Linode.com