Mod parrot
   HOME

TheInfoList



OR:

Parrot is a discontinued register-based
process virtual machine In computing, a virtual machine (VM) is the virtualization or emulation of a computer system. Virtual machines are based on computer architectures and provide the functionality of a physical computer. Their implementations may involve special ...
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 (normal ...
and execute it. Parrot is free and
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
software. Parrot was started by the
Perl Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language". Perl was developed ...
community and developed with help from the open-source and free software communities. As a result, it was 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 requireme ...
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 connection between computers or between computer programs. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standard that des ...
(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 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 (prog ...
and
Perl Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language". Perl was developed ...
. The name was later adopted by the Parrot project (initially a part of the Raku development effort) which aimed to support Raku, Python, and other programming languages. 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 legal 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, ...
and
trademark A trademark (also written trade mark or trade-mark) is a form of intellectual property that consists of a word, phrase, symbol, design, or a combination that identifies a Good (economics and accounting), product or Service (economics), service f ...
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. Historical design decisions are documented in the form of Parrot Design Documents, or PDDs, in the Parrot repository. Until late 2005,
Dan Sugalski Dan Sugalski was the initial designer and chief architect for the Parrot process virtual machine that was initially created to run Perl 6. In 2005 Dan handed over Parrot lead duties to Chip Salzenberg and shortly thereafter left the Parrot projec ...
was the lead designer and chief architect of Parrot.
Chip Salzenberg Chip may refer to: Food * Chip (snack), thinly sliced and deep-fried gastro item ** Potato chips (US) or crisp (UK) * Chips (fried potato strips) (UK) or french fries (US) (common as a takeout side) * Game chips, thin chip/French fries * Choc ...
, 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 the ...
, 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.


Languages

The goal of the Parrot virtual machine was 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 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 relationships amo ...
s between languages.


Static and dynamic languages

The differing properties of statically and dynamically typed languages 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 descr ...
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 instr ...
(for the
.NET The .NET platform (pronounced as "''dot net"'') is a free and open-source, managed code, managed computer software framework for Microsoft Windows, Windows, Linux, and macOS operating systems. The project is mainly developed by Microsoft emplo ...
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 Stack-oriented programming is a programming paradigm that relies on one or more stacks to manipulate data and/or pass parameters. Programming constructs in other programming languages need to be modified for use in a stack-oriented system. Most ...
. Parrot developers chose a register-based design, reasoning that it more closely resembles a hardware design, allowing the vast literature on
compiler optimization An optimizing compiler is a compiler designed to generate code that is optimized in aspects such as minimizing program execution time, memory usage, storage size, and power consumption. Optimization is generally implemented as a sequence of op ...
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 computer code consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). For conventional binary computers, machine code is the binaryOn nonb ...
. Other register-based virtual machines inspired parts of Parrot's design, including
LLVM LLVM, also called LLVM Core, is a target-independent optimizer and code generator. It can be used to develop a Compiler#Front end, frontend for any programming language and a Compiler#Back end, backend for any instruction set architecture. LLVM i ...
, the Lua VM and Inferno's
Dis Dis, DIS or variants may refer to: Arts and entertainment Music * Dis (album), ''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 Seimeib ...
.


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 Function application, applying and Function composition (computer science), composing Function (computer science), functions. It is a declarat ...
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, an ...
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) is an enumerated value that specifies the operation to be performed. Opcodes are employed in hardware devices such as arithmetic logic units (ALUs), central processing units (CPUs), and ...
s. Implementing solutions to these problems at the virtual machine level obviates the need to solve them 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 runtime system for Raku rules for the Parrot virtual machine. PGE uses these ''rules'' to convert a parsing expression grammar into Parrot bytecode. It is ther ...
(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 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.


Implementations

The most complete language implementations targeting the Parrot VM were Raku (known at the time as Rakudo Perl 6), Lua and a new language called "Winxed". Projects to implement many other languages were started, including
PHP PHP is a general-purpose scripting language geared towards 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. ...
,
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 (prog ...
, and
Ruby 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 sapph ...
; along with esoteric and demonstration languages such as
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, ri ...
and the " squaak" tutorial language. None of these projects were successful in becoming the primary implementation of their respective languages.


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 (normal ...
'' 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 (for example, .txt, .mp3, .exe) that indicates a characteristic of the file contents or its intended use. A filename extension is typically d ...
".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 Central processing unit, 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 (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
type * N:
floating-point In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a ''significand'' (a Sign (mathematics), signed sequence of a fixed number of digits in some Radix, base) multiplied by an integer power of that ba ...
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 or ''The Unicode Standard'' or TUS is a character encoding standard maintained by the Unicode Consortium designed to support the use of text in all of the world's writing systems that can be digitized. Version 16.0 defines 154,998 Char ...
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


mod_parrot

mod_parrot is an optional module for the
Apache web server The Apache HTTP Server ( ) is a free and open-source cross-platform web server, released under the terms of Apache License 2.0. It is developed and maintained by a community of developers under the auspices of the Apache Software Foundation. ...
. It embeds a Parrot virtual machine interpreter into the Apache server and provides access to the Apache API to allow handlers to be written in Parrot assembly language, or any high-level language targeted to Parrot.


See also

*
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 ...
*
GraalVM GraalVM is a Java Development Kit (JDK) written in Java. The open-source distribution of GraalVM is based on OpenJDK, and the enterprise distribution is based on Oracle JDK. As well as just-in-time (JIT) compilation, GraalVM can compile a Java ...
*
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 instr ...
(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 ...
*
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, Java Virtual Machine (JVM) to add support for Dynamic programming language, dynam ...


References


External links

*
Perl 6 and Parrot links
*For mod_parrot: ** ** ** {{Perl Cross-platform software Free and open source interpreters Free software programmed in C Perl Register-based virtual machines Software using the Artistic license Discontinued software