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:
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:
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:
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:
mv rakudo-moar-2021.03-01-linux-x86_64-gcc/ rakudo
Yes, check the version we just downloaded, from the folder where we can find the binary, we will only have to use the command:
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:
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).
This command will return an output like the following on the screen:
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.