Parrot virtual machine

Parrot virtual machine
Parrot Foundation logo
Developer(s) Parrot Foundation
Stable release
8.1.0 / February 16, 2016 (2016-02-16)[1]
Written in C
Operating system Cross-platform
Type Virtual machine
License Artistic License 2.0
Website www.parrot.org

Parrot is a register-based process virtual machine designed to run dynamic languages efficiently. It is possible to compile Parrot assembly language and PIR (an intermediate language) to Parrot bytecode and execute it. Parrot is free and open source software.[2]

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 Perl 6 and other modern dynamic languages.

Version 1.0, with a stable API for development, was released on March 17, 2009.[3]

The current version is release 8.1.0 "Andean Parakeet"[1]

History

The name Parrot came from an April Fool's joke which announced a hypothetical language, named Parrot, that would unify Python and Perl.[4][5] 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.[6]

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.[7]

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. Other register-based virtual machines have inspired parts of Parrot's design, including LLVM, the Lua VM and Inferno's 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 opcodes. Implementing solutions to these problems at the virtual machine level prevents repeated efforts to solve these problems in the individual client languages.

Compiler tools

Main article: Parser Grammar Engine

Parrot provides a suite of compiler-writing tools[8] 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.[9] As of July 2013, actively maintained languages are:[10]

Inactive languages, as of July 2013, are the following:

Internals

There are three forms of program code for Parrot:

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:

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 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.[14]

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.[15] 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.

See also

References

  1. 1 2 "New supported release 8.1.0 "Andean Parakeet"". Parrot Foundation. 2016-02-16. Retrieved 2016-09-26.
  2. "Parrot Contributor License Agreement 1.0" (PDF). Parrot Foundation. Retrieved 2009-03-18.
  3. "Parrot Roadmap". Parrot Foundation. 2008-11-20. Retrieved 2008-11-20.
  4. "The Story Behind the Parrot Prank - O'Reilly Media". Oreilly.com. 2001-04-06. Retrieved 2014-02-25.
  5. "Programming Parrot". Perl.com. Retrieved 2014-02-25.
  6. "Languages | Parrot VM". Parrot.org. 2006-02-14. Retrieved 2014-02-25.
  7. Announcing the Parrot Foundation Archived June 29, 2008, at the Wayback Machine.
  8. Archived May 9, 2009, at the Wayback Machine.
  9. "Languages – Parrot". Trac.parrot.org. Retrieved 2014-02-25.
  10. Parrot.Org: Languages
  11. Whiteknight. "Whiteknight/matrixy — GitHub". Github.com. Retrieved 2014-02-25.
  12. http://www.parrotcode.org/docs/parrotbyte.html
  13. Archived July 20, 2009, at the Wayback Machine.
  14. Otto, Christoph (2010-10-21). "reparrot: Parrot has a new architect. What now?". Reparrot.blogspot.com. Retrieved 2014-02-25.
  15. "Parrot 6.1.0 - Parrot Design Documents (PDDs)". Docs.parrot.org. Retrieved 2014-02-25.
This article is issued from Wikipedia - version of the 11/14/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.