Parrot was a
register-based process virtual machine designed to run
dynamic languages efficiently. It is possible to compile
Parrot assembly language and
Parrot intermediate representation (PIR, an intermediate language) to Parrot
bytecode
Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (norma ...
and execute it. Parrot is
free
Free may refer to:
Concept
* Freedom, having the ability to do something, without having to obey anyone/anything
* Freethought, a position that beliefs should be formed only on the basis of logic, reason, and empiricism
* Emancipate, to procur ...
and
open source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
software.
Parrot was started by the
Perl community and is developed with help from the
open source and free software communities. As a result, it is focused on
license compatibility with Perl (
Artistic License 2.0), platform compatibility across a broad array of systems, processor architecture compatibility across most modern processors, speed of execution, small size (around 700k depending on platform), and the flexibility to handle the varying demands made by
Raku and other modern
dynamic languages.
Version 1.0, with a stable
application programming interface
An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how t ...
(API) for development, was released on March 17, 2009.
The last version is release 8.1.0 "Andean Parakeet".
Parrot was officially discontinued in August 2021, after being supplanted by
MoarVM in its main use (Raku) and never becoming a mainstream VM for any of its other supported languages.
History
The name ''Parrot'' came from an
April Fool's joke which announced a hypothetical language, named ''Parrot'', that would unify
Python and
Perl. The name was later adopted by this project (initially a part of the Raku development effort) which aims to support Raku, Python, and other programming languages. Several languages are being
ported to run on the Parrot virtual machine.
The
Parrot Foundation was dissolved in 2014. The Foundation was created in 2008 to hold the
copyright and
trademarks of the Parrot project, to help drive development of
language implementations and the core codebase, to provide a base for growing the Parrot community, and to reach out to other language communities.
Languages
The goal of the Parrot virtual machine is to host client languages and allow inter-operation between them. Several hurdles exist in accomplishing this goal, in particular the difficulty of mapping high-level concepts, data, and
data structure
In computer science, a data structure is a data organization, management, and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data values, the relationships among them, a ...
s between languages.
Static and dynamic languages
The differing properties of
statically and dynamically typed languages have motivated the design of Parrot. Current popular virtual machines such as the
Java virtual machine
A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes ...
and the
Common Language Runtime
The Common Language Runtime (CLR), the virtual machine component of Microsoft .NET Framework, manages the execution of .NET programs. Just-in-time compilation converts the managed code (compiled intermediate language code) into machine instructio ...
, for the .NET platform, have been designed for statically typed languages, while the languages targeted by Parrot are dynamically typed.
Virtual machines such as the Java virtual machine and the current Perl 5 virtual machine are also
stack based. Parrot developers see Parrot's inclusion of registers as an advantage, as it therefore more closely resembles a hardware design, allowing the vast literature on
compiler optimization
In computing, an optimizing compiler is a compiler that tries to minimize or maximize some attributes of an executable computer program. Common requirements are to minimize a program's execution time, memory footprint, storage size, and power con ...
to be used in generating bytecode for the Parrot virtual machine that could run at speeds closer to
machine code. Other register-based virtual machines have inspired parts of Parrot's design, including
LLVM, the
Lua VM and Inferno's
Dis
Dis, DIS or variants may refer to:
Arts and entertainment Music
* ''Dis'' (album), by Jan Garbarek, 1976
* ''Dís'', a soundtrack album by Jóhann Jóhannsson, 2004
* "Dis", a song by The Gazette from the 2003 album ''Hankou Seimeibun''
* "dis� ...
.
Functional concepts
Parrot has rich support for several features of
functional programming including
closures and
continuations, both of which can be particularly difficult to implement correctly and portably, especially in conjunction with
exception handling and
threading. The biggest advantage is the dynamic extendability of objects with methods, which allows for ''polymorphic containers'' (PMCs) and associated
opcode
In computing, an opcode (abbreviated from operation code, also known as instruction machine code, instruction code, instruction syllable, instruction parcel or opstring) is the portion of a machine language instruction that specifies the operat ...
s. Implementing solutions to these problems at the virtual machine level obviates the need to solve these problems in the individual client languages.
Compiler tools
Parrot provides a suite of
compiler-writing tools which includes the
Parser Grammar Engine (PGE), a hybrid parser-generator that can express a
recursive descent parser as well as an
operator-precedence parser, allowing free transition between the two in a single grammar. The PGE feeds into the
Tree Grammar Engine (TGE) which further transforms the parse-tree generated by PGE for optimization and ultimately for code generation.
Existing client languages
Many languages already have compiler front-ends designed for Parrot; however, many of them are still only partially functional. As of July 2013 , actively maintained languages are:
*
C (C99 "dialect")
*
Java
*
Java bytecode
*
Joy
*
Lua
Lua or LUA may refer to:
Science and technology
* Lua (programming language)
* Latvia University of Agriculture
* Last universal ancestor, in evolution
Ethnicity and language
* Lua people, of Laos
* Lawa people, of Thailand sometimes referred t ...
*
MiniPerl (Perl 1.0)
*
NQP
Raku is a member of the Perl family of programming languages. Formerly known as Perl 6, it was renamed in October 2019. Raku introduces elements of many modern and historical languages. Compatibility with Perl was not a goal, though a compatibili ...
(Not Quite Perl)
*
Perl 5
*
PHP (via Pipp)
*
Python (via pynie)
*
Raku (via
Rakudo)
*
Ruby (via Cardinal)
*
Scheme
* The "
squaak" tutorial language
*
Tcl (via partcl)
*
WMLScript
WMLScript is a procedural programming language and dialect of JavaScript used for WML pages and is part of the Wireless Application Protocol (WAP).
WMLScript is a client-side scripting language and is similar to JavaScript. Just like JavaScript W ...
Inactive languages, as of July 2013, are the following:
*
Arc
ARC may refer to:
Business
* Aircraft Radio Corporation, a major avionics manufacturer from the 1920s to the '50s
* Airlines Reporting Corporation, an airline-owned company that provides ticket distribution, reporting, and settlement services
* ...
*
APL
*
bc
*
Common Lisp
Common Lisp (CL) is a dialect of the Lisp programming language, published in ANSI standard document ''ANSI INCITS 226-1994 (S20018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperlinked HTML version, has been derived fro ...
*
Lisp
A lisp is a speech impairment in which a person misarticulates sibilants (, , , , , , , ). These misarticulations often result in unclear speech.
Types
* A frontal lisp occurs when the tongue is placed anterior to the target. Interdental lisping ...
*
ECMAScript
*
Forth
* Generic Imperative Language
*
GNU m4
*
Jako
*
Octave
In music, an octave ( la, octavus: eighth) or perfect octave (sometimes called the diapason) is the interval between one musical pitch and another with double its frequency. The octave relationship is a natural phenomenon that has been refer ...
*
QuickBASIC 4.5
*
Smalltalk
Smalltalk is an object-oriented, dynamically typed reflective programming language. It was designed and created in part for educational use, specifically for constructionist learning, at the Learning Research Group (LRG) of Xerox PARC by Alan Ka ...
(via Chitchat)
*
.NET bytecode
The following
esoteric programming languages have also been implemented:
*
Befunge
*
Brainfuck
* HQ9 Plus
*
Lazy K
*
LOLCODE
*
Ook!
*
Shakespeare
*
Unlambda
Internals
There are three forms of program code for Parrot:
* ''
Bytecode
Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (norma ...
'' is binary and is natively interpreted by Parrot. Bytecode is usually stored in files with the
filename extension ".pbc".
* ''
Parrot assembly language'' (PASM) is the low level language that
compiles down to bytecode. PASM code is usually stored in files with the filename extension ".pasm".
* ''
Parrot intermediate representation'' (PIR) is a slightly higher level language than PASM and also compiles down to bytecode. It is the primary target of language implementations. PIR transparently manages Parrot's inter-routine calling conventions, provides improved syntax, register allocation, and more. PIR code is usually stored in files with the filename extension ".pir".
Examples
Registers
Parrot is register-based like most hardware
CPUs, and unlike most virtual machines, which are stack-based. Parrot provides four types of registers:
* I: native
integer type
* N:
floating-point
In computing, floating-point arithmetic (FP) is arithmetic that represents real numbers approximately, using an integer with a fixed precision, called the significand, scaled by an integer exponent of a fixed base. For example, 12.345 can b ...
numbers
* S: advanced
string
String or strings may refer to:
*String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects
Arts, entertainment, and media Films
* ''Strings'' (1991 film), a Canadian anim ...
registers with
Unicode support
* P: PMC, or ''Polymorphic Container'' — Parrot object type
Parrot provides an arbitrary number of registers; this number is fixed at compile time per subroutine.
Arithmetic operations
In PASM
set I1, 4
inc I1 # I1 is now 5
add I1, 2 # I1 is now 7
set N1, 42.0
dec N1 # N1 is now 41.0
sub N1, 2.0 # N1 is now 39.0
print I1
print ', '
print N1
print "\n"
end
In PIR
.sub 'main' :main
$I1 = 4
inc $I1 # $I1 is now 5
$I1 += 2 # $I1 is now 7
$N1 = 42.0
dec $N1 # $N1 is now 41.0
$N1 -= 2.0 # $N1 now 39.0
print $I1
print ', '
print $N1
print "\n"
.end
Development
Until late 2005,
Dan Sugalski was the lead designer and chief architect of Parrot.
Chip Salzenberg, a longtime Perl, Linux kernel, and C++ hacker, took over until mid-2006, when he became the lead developer.
Allison Randal, the lead developer of
Punie
Punie is a compiler created as a test case for the Parrot virtual machine. Its goal is to compile Perl v1 code and thereby exercise Parrot's compiler tools.
Status
The project is championed by Allison Randal, though several other Parrot hackers ha ...
and chief architect of Parrot's compiler tools, was the chief architect until mid-October 2010 when she stepped down and chose Christoph Otto as the new chief architect.
Development discussions take place primarily on the #parrot channel on irc.perl.org. In addition, there are weekly moderated meetings for Parrot and language developers hosted in #parrotsketch on the same network. Much discussion also occurs on the parrot-dev mailing list, hosted by parrot.org.
Design discussions exist in the form of Parrot Design Documents, or PDDs, in the Parrot repository.
The chief architect or another designated designer produces these documents to explain the philosophy of a feature as well as its interface and design notes. Parrot hackers turn these documents into executable tests, and then existing features.
The Parrot team releases a new stable version of the software on the third Tuesday of every month. Core committers take turns producing releases in a revolving schedule, where no single committer is responsible for multiple releases in a row.
See also
*
GraalVM
*
Common Language Runtime
The Common Language Runtime (CLR), the virtual machine component of Microsoft .NET Framework, manages the execution of .NET programs. Just-in-time compilation converts the managed code (compiled intermediate language code) into machine instructio ...
(CLR)
*
Comparison of application virtual machines
*
mod_parrot
*
Da Vinci Machine
References
External links
*
Perl 6 and Parrot links
{{Perl
Cross-platform software
Free compilers and interpreters
Free software programmed in C
Perl
Register-based virtual machines
Software using the Artistic license
Discontinued software