Parrot Virtual Machine/Introduction

What Is Parrot?
Parrot is a virtual machine (VM), similar to the Java VM and the .NET VM. However, unlike these two which are designed for statically-typed languages like Java or C#, Parrot is designed for use with dynamically typed languages such as Perl, Python, Ruby, or PHP.

The Parrot VM itself is written in the C programming language, which means that&mdash;in theory&mdash;it will be portable to a large number of different computer architectures and operating systems. It is written to be easily modular and extensible.

Programmers can write in any of the languages for which a Parrot-capable compiler exists. Modules written in one language, such as Perl, can transparently interoperate with modules which have originally been written in any of the other languages supported by Parrot. This easy interoperability and native support for cutting-edge dynamic programming features makes Parrot an important tool for next-generation language designers and implementers.

It is precisely because Parrot is intended to support so many diverse high level languages that Parrot has developed a very general and feature-rich architecture. Much of the Parrot architecture is still under active development, so those parts will not be able to be properly discussed here in this book quite yet. Once Parrot reaches a stable release, and more details are set in stone, this book will be able to provide a more comprehensive coverage.

History of Parrot
The Parrot project was born from the Perl 6 development project. As such, the history of Parrot, at least the early history of it, is closely tied to the history of Perl 6. In fact, understanding just how large and ambitious Perl 6 is, you'll start to understand why Parrot must have all the features it has.

It was famously quoted about version 5 of the Perl programming language that "nothing can parse Perl but perl". The implication was that the perl executable was the only program that could reliably parse the Perl programming language. There were two reasons for this. First, the Perl language didn't follow any formal specification; The behavior of the perl interpreter was the definitive documentation for the actions of Perl. Second, the Perl programming language allowed the use of source filters, programs which could modify their own source code prior to execution. This means that to reliably parse and understand a Perl program, you needed to be able to execute the source filters reliably. The only program that could do both was perl.

The next planned version of Perl, Perl 6, was supposed to be a major rewrite of the language. In addition to standardizing and bringing sanity to all the features which had slowly entered the language grammar, it was decided that Perl 6 would be a formal specification first, and implementations of that specification later.

The name "Parrot" was first used as an April Fool's joke. The story claimed that the Perl and Python languages (which are competitors, and which were both undergoing major redesigns) were going to merge together into a single language named Parrot. This was, of course, a hoax, but the idea was a powerful one. When the project was started to create a virtual machine that would be capable of running not only Perl 6, but also Python and other dynamic languages, the name Parrot was a perfect fit.

The first release of Parrot, 0.0.1, was released in September 2001. The development team has prepared a stable point release on the third Tuesday of every month.

The Parrot Foundation
The Parrot Foundation was established in mid 2008 to serve as an advocate for Parrot. The Parrot Foundation is a non-profit charity organization in the United States, and donations to the foundation are tax-deductable.

Prior to the creation of the Parrot Foundation, Parrot was managed and overseen by the Perl Foundation. This relationship was historical in nature, due to the fact that Parrot was originally intended just to be the backend for the Perl 6 programming language. Since Parrot has grown beyond that, and is attempting to deal equally with all high-level dynamic programming languages, it was decided to become separate from the Perl Foundation.

Parrot's website is http://www.parrot.org

Who Is This Book For?
This book is for readers at the intermediate to advanced level with a solid background in computer programming. Perl Programming would be a good start, although a background in any dynamic language would be helpful. Having a background in Compiler Construction, Regular Expressions, or the compiler-building tools Lex and Yacc would also be a benefit.

For the sections about Parrot hacking, a background knowledge of C Programming is required.

What Will We Cover?
This book is going to serve as, at least, a basic introduction to the Parrot Virtual Machine. We will cover basic programming for Parrot in the lowest-level languages that it supports: PIR and PASM. We will also discuss one of the greatest strengths of the Parrot platform, the Parrot Compiler Tools (PCT), which enables compilers to be written easily for higher-level languages like Perl and Python.

Later sections will actually delve into the Parrot internals, and discuss how Parrot works and how to contribute code for the Parrot development project. Extensive reference materials at the end of the book will try to keep track of the information that is most necessary for developers.

Where To Get More Information
The definitive source for Parrot information and documentation is the Parrot project website, http://www.parrot.org. Parrot programmers, hackers, and enthusiasts also chat in the Parrot IRC chatroom.

How To Get Involved In Parrot Development
The Parrot development process is large and varied. Depending on skill level, there are many opportunities for a person to get involved in Parrot development. Here are some examples:
 * If you are good at C programming:If you know C programming, help is always needed to work on Parrot. In addition to normal development tasks, there are bug reports to resolve, compile errors to fix, new platforms to port to, and optimizations to perform. Parrot needs to be ported to many different systems, and it needs to be properly tested on all of them.
 * If you are good with Perl programming:Much of the Parrot build tools are written in Perl 5. However, there is also a massive development effort to support the Perl 6 project. An intermediate language which is similar to Perl 6 but with many missing features called Not Quite Perl (NQP) is used to implement compilers for higher-level languages. If you are good with Perl and are willing to learn Perl 6 and NQP, there is a lot of compiler-implementation work that needs to be done.
 * If you are good with system administration:Parrot needs to be built and tested regularly. People are always needed who are willing to perform regular builds and tests of Parrot. If you are willing to set up automated build bot to perform regular builds and tests, that's even better.
 * If you can write:This book needs your help, and anybody can edit it. Also, there are a number of other book-writing projects concerning Parrot that are looking for active authors and editors. The more is written about Parrot, the more new users will be able to learn about it.

If you don't fall cleanly into any of these categories, there are other opportunities to help as well. This might be a good opportunity for you to learn a new skill, like programming Perl 6, PIR, or NQP. If you are interested in writing or editing, you can help with this wikibook too!

Parrot Developers
There are several different roles that people have taken up in Parrot development, even though there is no centralized management hierarchy. Volunteers tend to fulfill certain roles that they enjoy and that they have skill at.


 * Architect: The Parrot Architect, currently Allison Randal, is in charge with laying out the overall design specifications for Parrot. The architect has the final say in important decisions and is responsible to ensure that design documents are up to date. By laying out the overall requirements of the system, other volunteers are able to contribute to areas where they are most interested.
 * Pumpking:The Pumpking has oversight of the Parrot source repository, and is also the lead developer. The Pumpking defines coding standards that all contributors must follow, and helps to coordinate other contributors.
 * Release Managers: Parrot has a schedule of making releases approximately once a month. The release manager oversees this process, and ensures that releases are high quality. Release managers will control when new features can be added, and when code should be frozen for debugging. Pre-release debugging sessions are very productive and important periods for Parrot development, and ensure that many bugs get fixed between each release.
 * Committer: A committer is a person with write access to the Parrot SVN repository. Committers typically have submitted several patches and participated in Parrot-related discussions.
 * Metacommitter: A metacommitter is a person who has write access to the Parrot SVN repository and is also capable of promoting new committers. The architect and the Pumpking are automatically metacommitters, but there are several others too.

Among the above groups, there are other designations as well. This is because many committers tend to focus their efforts on a relatively small portion of the Parrot development effort.
 * Core Developer: A person who works on Parrot internals, typically one or two subsystems. Core developers need to be skilled in C programming, and also need to work with many development utilities written in Perl.
 * Compiler Developer: These developers, like the Core Developers are working on the internals of Parrot, typically by writing lots of C code. In contrast, Compiler Developers focus their effort on the various compiler front-ends such as IMCC, PIRC, PGE, or TGE.
 * High-Level Language Developer: A high-level language developer is a person who is working to implement a high-level language on Parrot. Even though they have commit access to the whole repository, many high-level language developers will focus only on a single language implementation. High-level language developers need to be skilled in PCT and many of the Perl 6-based development tools for HLLs.
 * Build Managers:Build managers help to create and maintain tools that other developers rely on.
 * Testers: Testers create and maintain a suite of hundreds and thousands of tests to verify the operations of Parrot, its subsystems, its compilers and the high-level languages that run on it.
 * Platform Porters: A platform porter ensures that Parrot can be built on multiple platforms. Porters must build and test Parrot on different platforms, and also create and distribute pre-compiled installation packages for different platforms.

This certainly isn't an exhaustive list of possible roles either. If you have programming skills, but don't know if you fit in well to any of the designations above, your help is still needed.

Resources

 * http://www.parrotcode.org/docs/intro.html
 * http://www.parrotcode.org/docs/roadmap.html
 * http://www.parrotcode.org/docs/parrothist.html