Parrot VM
   HOME

TheInfoList



OR:

Parrot was a register-based process virtual machine designed to run
dynamic language In computer science, a dynamic programming language is a class of high-level programming languages, which at runtime execute many common programming behaviours that static programming languages perform during compilation. These behaviors cou ...
s efficiently. It is possible to compile
Parrot assembly language The Parrot assembly language (PASM) is the basic assembly language used by the Parrot virtual machine. PASM is the lowest level assembly language in the Parrot stack. The Parrot intermediate representation (PIR) is PASM extended to simplify devel ...
and
Parrot intermediate representation The Parrot intermediate representation (PIR), previously called Intermediate code (IMC), is one of the two assembly languages for the Parrot virtual machine. The other is Parrot assembly language or PASM. Compared to PASM, PIR exists at a slightly ...
(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 and open source software. Parrot was started by the
Perl 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 offic ...
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 language In computer science, a dynamic programming language is a class of high-level programming languages, which at runtime execute many common programming behaviours that static programming languages perform during compilation. These behaviors cou ...
s. 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 MoarVM (''Metamodel On A Runtime Virtual Machine'') is a virtual machine built for the 6model object system. It is being built to serve as yet another VM backend for Raku. MoarVM was created to allow for greater efficiency than Parrot by havin ...
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 April Fools' Day or All Fools' Day is an annual custom on 1 April consisting of practical jokes and hoaxes. Jokesters often expose their actions by shouting "April Fools!" at the recipient. Mass media can be involved in these pranks, which may b ...
joke which announced a hypothetical language, named ''Parrot'', that would unify
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
and
Perl 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 offic ...
. 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 In software engineering, porting is the process of adapting software for the purpose of achieving some form of execution in a computing environment that is different from the one that a given program (meant for such execution) was originally desi ...
to run on the Parrot virtual machine. The
Parrot Foundation Parrots, also known as psittacines (), are birds of the roughly 398 species in 92 genera comprising the order Psittaciformes (), found mostly in tropical and subtropical regions. The order is subdivided into three superfamilies: the Psittaco ...
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, educatio ...
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 othe ...
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 structures 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 and the Common Language Runtime, 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 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 ve ...
. 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.


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 computati ...
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, an ...
and threading. The biggest advantage is the dynamic extendability of objects with methods, which allows for ''polymorphic containers'' (PMCs) and associated opcodes. 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 The Parser Grammar Engine (PGE, originally the Parrot Grammar Engine) is a compiler and Run-time system, runtime for Raku rules for the Parrot virtual machine. PGE uses these ''rules'' to convert a parsing expression grammar into Parrot bytecode. I ...
(PGE), a hybrid parser-generator that can express a
recursive descent parser In computer science, a recursive descent parser is a kind of top-down parser built from a set of mutually recursive procedures (or a non-recursive equivalent) where each such procedure implements one of the nonterminals of the grammar. Thus t ...
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 ord ...
, allowing free transition between the two in a single grammar. The PGE feeds into the
Tree Grammar Engine In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are u ...
(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 mos ...
*
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 langua ...
*
Joy The word joy refers to the emotion evoked by well-being, success, or good fortune, and is typically associated with feelings of intense, long lasting happiness. Dictionary definitions Dictionary definitions of joy typically include a sense of ...
*
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 compatibil ...
(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 offic ...
*
PHP PHP is a 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 implementation is now produced by The PHP Group. ...
(via Pipp) *
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
(via pynie) * Raku (via
Rakudo Rakudo is a Raku compiler targeting MoarVM, and the Java Virtual Machine, that implements the Raku specification. It is currently the only major Raku compiler in active development. Originally developed within the Parrot project, the Rakudo sour ...
) *
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 ...
(via Cardinal) * Scheme * The " squaak" tutorial language *
Tcl TCL or Tcl or TCLs may refer to: Business * TCL Technology, a Chinese consumer electronics and appliance company **TCL Electronics, a subsidiary of TCL Technology * Texas Collegiate League, a collegiate baseball league * Trade Centre Limited ...
(via partcl) * WMLScript Inactive languages, as of July 2013, are the following: * Arc * APL * bc * Common Lisp * Lisp *
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 scripting o ...
* Forth * 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 *
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 c ...
4.5 * Smalltalk (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, rig ...
*
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 Lazy is the adjective for laziness, a lack of desire to expend effort. It may also refer to: Music Groups and musicians * Lazy (band), a Japanese rock band * Lazy Lester, American blues harmonica player Leslie Johnson (1933–2018) * Lazy Bill L ...
* 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 Unlambda is a minimal, "nearly Purely functional language, pure" functional programming language invented by David Madore. It is based on combinatory logic, an expression system without the Lambda calculus, lambda operator or free variables. It r ...


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 The Parrot assembly language (PASM) is the basic assembly language used by the Parrot virtual machine. PASM is the lowest level assembly language in the Parrot stack. The Parrot intermediate representation (PIR) is PASM extended to simplify devel ...
'' (PASM) is the low level language that
compile In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
s down to bytecode. PASM code is usually stored in files with the filename extension ".pasm". * ''
Parrot intermediate representation The Parrot intermediate representation (PIR), previously called Intermediate code (IMC), is one of the two assembly languages for the Parrot virtual machine. The other is Parrot assembly language or PASM. Compared to PASM, PIR exists at a slightly ...
'' (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 A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, and ...
, 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 languag ...
type * N: floating-point numbers * S: advanced string 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, wh ...
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 Chromatin immunoprecipitation (ChIP) is a type of immunoprecipitation experimental technique used to investigate the interaction between proteins and DNA in the cell. It aims to determine whether specific proteins are associated with specific genom ...
, a longtime Perl, Linux kernel, and C++ hacker, took over until mid-2006, when he became the lead developer.
Allison Randal Allison Randal is a software developer and author. She was the chief architect of the Parrot virtual machine, a member of the board of directors for The Perl Foundation, a director of the Python Software Foundation from 2010 to 2012, and th ...
, the lead developer of Punie 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 f ...
* Common Language Runtime (CLR) *
Comparison of application virtual machines Application virtualization software refers to both application virtual machines and software responsible for implementing them. Application virtual machines are typically used to allow application bytecode to run portably on many different comput ...
* mod_parrot *
Da Vinci Machine The Da Vinci Machine, also called the Multi Language Virtual Machine, was a Sun Microsystems project aiming to prototype the extension of the Java Virtual Machine (JVM) to add support for dynamic languages. It was already possible to run dynami ...


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