Rakudo, how to install this Raku compiler on Ubuntu 20.04

abor rakudo

In the next article we are going to take a look at Rakudo. This is a Raku compiler for MoarVM and the Java Virtual Machine. It is currently the main Raku compiler, under active development. It is a compiler that will allow us to enjoy the full potential of Raku. Rakudo is distributed under the terms of the Artistic License 2.0.

In case you did not know, Raku is a Perl-based programming language. This language has been developed by a team of dedicated and enthusiastic volunteers and continues to develop. It was originally developed within the Parrot project, but its source code repository was divided for this new project in February 2009, seeking that it could be developed independently. cell initially it was known as Perl 6, and was renamed to Raku in October 2019. It features elements from many modern and historical languages.

The first and main publication, both of the compiler and modules (called «Rakudo» or «Rakudo Star») was published on July 29, 2010. The term 'Rakudo' was chosen to distinguish between the name of a language implementation ('Rakudo') of the language specification name ('Raku'). Any implementation that passes the official test suite could call itself 'Raku'. There are currently multiple implementations at various levels of maturity, and only Rakudo implements the full subset of Raku and NQP for Raku.

Install Rakudo on Ubuntu 20.04

Today Raku is not as popular as Perl or Ruby, but it has had significant acceptance by the community. I guess this is why Rakudo can be found available in the official Ubuntu 20.04 repositories.

If you want to install it on your system, open a terminal (Ctrl + Alt + T) and run the following command:

install rakudo from apt

sudo apt install rakudo

This is the easiest installation method, but it will not give us the latest stable version of Rakudo. You can check installed version using apt typing in the same terminal:

version installed from apt

rakudo --version

From the website of this project, in the download section, we will find the option to download the latest stable version directly. We can also use the wget command in terminal (Ctrl + Alt + T) as follows:

download rakudo from github

wget -c https://rakudo.org/dl/rakudo/rakudo-moar-2021.03-01-linux-x86_64-gcc.tar.gz

After the download, you have to unzip the package with the following command:

tar xzvf rakudo-moar-2021.03-01-linux-x86_64-gcc.tar.gz

In the folder to be created, we can find the binary (raku) inside the folder bin. If you want to change the name of the folder that we just unzipped, so that it has a simpler name, you can use this other command:

rakudo binary

mv rakudo-moar-2021.03-01-linux-x86_64-gcc/ rakudo

For check the version we just downloaded, from the folder where we can find the binary, we will only have to use the command:

version downloaded from github

./raku --version

A small example of use

We are going to create an example file to test Rakudo on Ubuntu 20.04. We will do this with our favorite text editor, for this example I will use vim:

vim ejemplo-rakudo.pl

Inside the file, we just have to write something like the following:

say "Esto es un ejemplo con Rakudo utilizado en Ubuntu 20.04";

After writing the text to the file, save the changes and close the editor. When we are back in the terminal, to execute this file we only need to use the raku binary located in the folder rakudo / bin (if you have changed the folder name of the tar.gz file downloaded lines above).

rakudo/bin/raku ejemplo-rakudo.pl

This command will return an output like the following on the screen:

hello world example with Raku

Today there are many programming languages, although Raku is not as popular as Perl, it claims to be an evolution of it, and together with Rakudo they form an interesting couple to work with..

Since Rakudo is a compiler, it is important to distinguish between the compiler documentation itself and the language it implements. More information on the Rakudo compiler can be found in web page of the same, or in the official documentation. Information about Raku can also be obtained from the website of this project.


2 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Patrick Boker said

    Thank you for this how-to!

    The canonical file extension is `.raku` instead of` .pl` to have a clear distinction between Perl and Raku scripts.

    The compiled releases that can be downloaded on rakudo.org contain a script to adapt the `PATH`. It adds the `bin /` and the `share / perl6 / site / bin /` folder, which contains the `zef` module installer. It can be called like this: `$ (/ path / of / rakudo / scripts / set-env.sh)`. Then one can call `raku` and` zef` irrespective of the current working directory.

    1.    Damien A. said

      Thanks for the clarification and for the contribution. greetings