Parrot virtual machine
From Seo Wiki - Search Engine Optimization and Programming Languages
|File:Parrot Foundation logo.png|
|Stable release||2.0.0 Inevitable / January 20, 2010|
|License||Artistic License 2.0|
Parrot is a register-based process virtual machine designed to run dynamic languages efficiently. It uses just-in-time compilation for speed to reduce the interpretation overhead. It is currently possible to compile Parrot assembly language and PIR (an intermediate language) to Parrot bytecode and execute it. Parrot is an open source project distributed with a free software licence, making Parrot free 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 (Artistic License 2.0), platform compatibility across a broad array of systems, processor architectures compatibility across most modern processors, speed of execution, small size (around 700k depending on platform), and the flexibility to handle the varying demands of Perl 6, and most, if not all, other modern dynamic languages. Other goals include improving introspection, debugger capabilities, and compile-time semantic modulation.
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 Perl 6 development effort) which aims to support Perl 6, Python, and other programming languages. Several languages are being ported to run on the Parrot virtual machine.
The Parrot 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.
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 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 it as an advantage of the Parrot machine that it has registers, and therefore more closely resembles a hardware design, allowing the vast literature on compiler optimization to be used generating code for the Parrot virtual machine so that it will run bytecode at speeds closer to machine code. Other register-based virtual machines have inspired parts of Parrot's design, including the Lua VM and Plan 9's Dis.
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. Implementing solutions to these problems at the virtual machine level prevents repeated efforts to solve these problems in the individual client languages.
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 a 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
There are three forms of program code for Parrot:
- Bytecode 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".
Parrot is register-based like most hardware CPUs, unlike most virtual machines, which are stack-based. Parrot provides four types of registers:
- I: native integer type
- N: floating-point numbers
- S: advanced string 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.
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
.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
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 and chief architect of Parrot's compiler tools, is now the 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. This practice has improved the project's velocity and stability.
- Common Language Runtime (CLR)
- Comparison of application virtual machines
- libJIT Just-In-Time compilation library, a library by Rhys Weatherley, Klaus Treichel, Aleksey Demakov, and Kirill Kononenko for development of advanced Just-In-Time compilation (JIT) in Virtual Machine implementations, Dynamic programming languages, and Scripting languages.
- ↑ "Parrot Contributor License Agreement 1.0" (PDF). Parrot Foundation. http://www.parrot.org/files/parrot_cla.pdf. Retrieved March 18, 2009.
- ↑ "Parrot Roadmap". Parrot Foundation. 2008-11-20. https://trac.parrot.org/parrot/wiki/ParrotRoadmap. Retrieved 2008-11-20.
- ↑ "Parrot 2.0.0 Released!". Parrot Foundation. 2010-01-20. http://www.parrot.org/news/2010/Parrot-2.0.0. Retrieved 2010-01-21.
- ↑ http://www.oreilly.com/news/parrotstory_0401.html
- ↑ http://www.perl.com/pub/a/2001/04/01/parrot.htm
- ↑ http://www.parrot.org/languages
- ↑ http://www.parrotblog.org/2008/06/announcing-parrot-foundation.html
- ↑ http://docs.parrot.org/parrot/latest/html/docs/book/ch04_compiler_tools.pod.html
- ↑ https://trac.parrot.org/parrot/wiki/Languages
- ↑ http://parrot.org/languages
- ↑ http://www.parrotcode.org/docs/parrotbyte.html
- ↑ http://en.wikibooks.org/wiki/Parrot_Virtual_Machine/PASM_Reference
- ↑ http://docs.parrot.org/parrot/latest/html/docs/book/ch03_pir.pod.html