Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Perl 6 Deep Dive

You're reading from   Perl 6 Deep Dive Data manipulation, concurrency, functional programming, and more

Arrow left icon
Product type Paperback
Published in Sep 2017
Publisher Packt
ISBN-13 9781787282049
Length 402 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Andrew Shitov Andrew Shitov
Author Profile Icon Andrew Shitov
Andrew Shitov
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

1. What is Perl 6? FREE CHAPTER 2. Writing Code 3. Working with Variables and Built-in Data Types 4. Working with Operators 5. Control Flow 6. Subroutines 7. Modules 8. Object-Oriented Programming 9. Input and Output 10. Working with Exceptions 11. Regexes 12. Grammars 13. Concurrent Programming 14. Functional Programming 15. Reactive Programming

Compilers

During the process of Perl 6 development, a number of compilers were created. Some of them were just a playground to test some ideas, whereas some were more mature. Among the most important, we should mention the following four projects:

  • Parrot
  • Pugs
  • Perlito
  • Rakudo

There were more attempts to create a Perl 6 compiler, which were less successful or less complete. We will go through the preceding list to see the highlights of each project and then focus on Rakudo, which is the compiler you should use today.

Parrot

Parrot is the first virtual machine aimed to be the base of the Perl 6 compiler. The initial design of the language suggested that the source code is compiled to the bytecode, which is executed by the virtual machine. Parrot's goal was to create a virtual machine suitable for handling all the needs of Perl 6 from simple data types, such as integers, to more complicated structures, such as classes, with the ability to call methods on objects and follow the object hierarchy.

The project is available at parrot.org. After some time, Parrot started supporting other programming languages, such as Lua or Python, and the virtual machine became less focused on Perl 6 itself. For example, the Ponie project was an attempt to create a compiler that would execute Perl 5 programs using Parrot.

Parrot became one of the virtual machines inside another project, Rakudo. However, before we go to Rakudo, let's follow the historical path and talk about Pugs.

Pugs

Pugs (Perl User's Golfing System) is a Perl 6 compiler written in Haskell. It was started in 2005 by a sole developer and soon attracted more people to the team. Pugs was the most sophisticated compiler of its time. It was difficult and very time consuming to compile the project, the execution speed was low, but the quality of the compilation and the coverage of Perl 6 specification were outstanding.

Pugs main role in Perl 6 as of today is the vast test suite. It was created to test Pugs itself, but turned out to be an official test suite for Perl 6. A compiler that claims to call itself a Perl 6 compiler must pass the test suite tests.

Pugs are not developing anymore, but its source code is available on GitHub at https://github.com/perl6/Pugs.hs.

Perlito

Perlito is another very interesting example of a project of building a Perl 6 compiler. It was aimed at cross-compiling Perl 5 or Perl 6 to one of these languages—JavaScript, Java, Go, Python, Ruby, or Lisp. You can find the project's repository at https://github.com/fglock/Perlito.

Perlito offers a web interface to compile the subset of Perl 6 in the browser. It compiles the code in Perl 6 to JavaScript and executes it immediately. This page is available at http://fglock.github.io/Perlito/perlito/perlito6.html. This project covers the Perl 6 specification only partially, but it may still be used to create various online educational systems for both Perl 5 and 6.

Rakudo

Rakudo is a compiler initially built on the Parrot virtual machine. Later, it started using the Java Virtual Machine (JVM), but in the end, the developers of Parrot created their own virtual machine, MoarVM (Metamodel on a Runtime Virtual Machine (www.moarvm.org)). Currently, the support of JVM is limited, and the main virtual machine is MoarVM.

Rakudo itself is a Perl 6 compiler. For us, the most useful compiler is Rakudo Star, which is a distribution including the compiler as well as a number of Perl 6 modules and a few command-line tools, such as a module installer. In this book, we will use the Rakudo Star compiler to run programs in Perl 6.

Rakudo's website is rakudo.org.

You have been reading a chapter from
Perl 6 Deep Dive
Published in: Sep 2017
Publisher: Packt
ISBN-13: 9781787282049
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime