HOME

TheInfoList



OR:

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 Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
community and is developed with help from the open source and free software communities. As a result, it is focused on
license compatibility License compatibility is a legal framework that allows for pieces of software with different software licenses to be distributed together. The need for such a framework arises because the different licenses can contain contradictory requirement ...
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 (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 Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
. 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 A copyright is a type of intellectual property that gives its owner the exclusive right to copy, distribute, adapt, display, and perform a creative work, usually for a limited time. The creative work may be in a literary, artistic, education ...
and
trademark A trademark (also written trade mark or trade-mark) is a type of intellectual property consisting of a recognizable sign, design, or expression that identifies products or services from a particular source and distinguishes them from oth ...
s 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 Efficiency, efficient Data access, access to data. More precisely, a data structure is a collection of data values, the rel ...
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 describ ...
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 instruc ...
, 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 c ...
to be used in generating bytecode for the Parrot virtual machine that could run at speeds closer to
machine code In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a ver ...
. Other register-based virtual machines have inspired parts of Parrot's design, including
LLVM LLVM is a set of compiler and toolchain technologies that can be used to develop a front end for any programming language and a back end for any instruction set architecture. LLVM is designed around a language-independent intermediate repre ...
, 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 In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that ...
including closures and
continuation In computer science, a continuation is an abstract representation of the control state of a computer program. A continuation implements ( reifies) the program control state, i.e. the continuation is a data structure that represents the computat ...
s, both of which can be particularly difficult to implement correctly and portably, especially in conjunction with
exception handling In computing and computer programming, exception handling is the process of responding to the occurrence of ''exceptions'' – anomalous or exceptional conditions requiring special processing – during the execution of a program. In general, a ...
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 opera ...
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 In computer science, an operator precedence parser is a bottom-up parser that interprets an operator-precedence grammar. For example, most calculators use operator precedence parsers to convert from the human-readable infix notation relying on or ...
, 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 (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
*
Java bytecode In computing, Java bytecode is the bytecode-structured instruction set of the Java virtual machine (JVM), a virtual machine that enables a computer to run programs written in the Java programming language and several other programming languages, ...
* 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 Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offici ...
*
PHP PHP is a General-purpose programming language, general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementati ...
(via Pipp) * Python (via pynie) * Raku (via Rakudo) *
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum (aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapp ...
(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 ...
Inactive languages, as of July 2013, are the following: * Arc * 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 fr ...
*
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 lispi ...
*
ECMAScript ECMAScript (; ES) is a JavaScript standard intended to ensure the interoperability of web pages across different browsers. It is standardized by Ecma International in the documenECMA-262 ECMAScript is commonly used for client-side scriptin ...
*
Forth Forth or FORTH may refer to: Arts and entertainment * ''forth'' magazine, an Internet magazine * ''Forth'' (album), by The Verve, 2008 * ''Forth'', a 2011 album by Proto-Kaw * Radio Forth, a group of independent local radio stations in Scotla ...
* Generic Imperative Language * GNU m4 *
Jako Jako AG is a German sportswear company based in the Hollenbach district of Mulfingen, Baden-Württemberg. The company was founded by Rudi Sprügel in 1989 in Stachenhausen. Jako provides kits for teams playing association football, handball, ...
*
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 Microsoft QuickBASIC (also QB) is an Integrated Development Environment (or IDE) and compiler for the BASIC programming language that was developed by Microsoft. QuickBASIC runs mainly on DOS, though there was also a short-lived version for the ...
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 ...
(via Chitchat) * .NET bytecode The following
esoteric programming language An esoteric programming language (sometimes shortened to esolang) is a programming language designed to test the boundaries of computer programming language design, as a proof of concept, as software art, as a hacking interface to another language ...
s have also been implemented: *
Befunge Befunge is a two-dimensional stack-based, reflective, esoteric programming language. It differs from conventional languages in that programs are arranged on a two-dimensional grid. "Arrow" instructions direct the control flow to the left, righ ...
*
Brainfuck Brainfuck is an esoteric programming language created in 1993 by Urban Müller. Notable for its extreme minimalism, the language consists of only eight simple commands, a data pointer and an instruction pointer. While it is fully Turing com ...
* HQ9 Plus * Lazy K * LOLCODE * Ook! *
Shakespeare William Shakespeare ( 26 April 1564 – 23 April 1616) was an English playwright, poet and actor. He is widely regarded as the greatest writer in the English language and the world's pre-eminent dramatist. He is often called England's natio ...
* 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 A filename extension, file name extension or file extension is a suffix to the name of a computer file (e.g., .txt, .docx, .md). The extension indicates a characteristic of the file contents or its intended use. A filename extension is typically ...
".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 An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
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 be ...
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 Unicode, formally The Unicode Standard,The formal version reference is is an information technology standard for the consistent encoding, representation, and handling of text expressed in most of the world's writing systems. The standard, ...
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 GraalVM is a Java VM and JDK based on HotSpot/OpenJDK, implemented in Java. It supports additional programming languages and execution modes, like ahead-of-time compilation of Java applications for fast startup and low memory footprint. 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 instruc ...
(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