Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Parrot compare to other virtual machines?

Tags:

jvm

clr

raku

parrot

Parrot is the virtual machine originally designed for Perl 6.

What technical capabilities does the Parrot VM offer that competing virtual machines such as the Java Virtual Machine (JVM)/Hotspot VM and Common Language Runtime (CLR) lack?

like image 882
knorv Avatar asked Nov 27 '09 23:11

knorv


People also ask

What is Parrot programming?

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 and execute it. Parrot is free and open source software.

Which languages use virtual machines?

Process VMs are implemented using an interpreter; performance comparable to compiled programming languages can be achieved by the use of just-in-time compilation. This type of VM has become popular with the Java programming language, which is implemented using the Java virtual machine.


1 Answers

The following answer was written in 2009. See also this 2015 update by raiph.

To expand on @Reed and point out some highlights, Parrot's opcodes are at a far higher level than most virtual machines. For example, while most machines store integers and floats, the basic registers are integers, numbers, strings and Parrot Magic Cookies (PMCs). Just having strings built in is a step up from the JVM.

More interesting is the PMC, sort of like JVM's object type but far more fungible. PMCs are a container for all the other more complicated types you need in a real language like arrays, tables, trees, iterators, I/O etc. The PMC and the wide variety of built in ops for it means less work for the language writer. Parrot does not shy away from the messy but necessary bits of implementing a language.

My information may be out of date, but I believe opcodes are pluggable, you can ship a Parrot VM that only contains the opcodes your language needs. They were also going to be inheritable, if your language wants their arrays to work a little different from stock Parrot arrays you can do that subclass it.

Finally, Parrot can be written for not just in assembler (PASM) but also a slightly higher level language, Parrot Intermediate Representation (PIR). PIR has loops, subroutines, localized variables and some basic math and comparison ops, all the basics people expect in a programming language, without getting too far away from the metal.

All in all, Parrot is very friendly to language designers (it is written by and for them) who want to design a language and leave as much of the implementation as possible to somebody else.

like image 166
Schwern Avatar answered Oct 13 '22 19:10

Schwern