How does Parrot compare to other virtual machines?
Asked Answered
P

7

28

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?

Preoccupied answered 27/11, 2009 at 23:54 Comment(0)
T
34

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.

Teresetereshkova answered 28/11, 2009 at 0:48 Comment(3)
@raiph Your edit which added an extensive 2015 update belongs in its own answer or in a comment. It's too extensive an addition of new content for an edit.Teresetereshkova
Thanks for reviewing my edit and commenting. Would it work if I added a new answer, and then you or I added a line at the start of your answer linking to the new answer? As it stands, most folk using SO to find out info about Parrot will leave thinking that "Parrot is the virtual machine originally designed for Perl 6", which is horribly ambiguous, and that your answer is a decent one in 2015 (it's got the green check mark and my guess is that it won't be outvoted for years, if ever, despite the broken links etc.).Ozenfant
@Ozenfant Yeah, that sounds great. Write an answer on the current situation and edit mine to link to it.Teresetereshkova
S
15

You can read about much of this on the Parrot VM Intro page.

The main advantage Parrot has over the JVM or the CLR would be that it is designed to support dynamic languages first, and potentially provide better support and performance for dynamically typed languages. The JVM and the CLR are both geared more towards supporting statically typed languages, and many of the design decisions show that.

Seroka answered 28/11, 2009 at 0:4 Comment(0)
O
6

Parrot is the virtual machine originally designed for Perl 6.

There are now two VMs originally designed for Perl 6; commits to MoarVM began in 2012.

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?

In another answer on this page, Reini Urban, the current (April 2015) Parrot lead dev, provides a brief comparison of Parrot with the JVM and CLR VM.

According to Reini, a key advantage Parrot has over MoarVM is "effectively lock-less threads".

Ozenfant answered 27/11, 2009 at 23:54 Comment(0)
M
5

One other thing that makes Parrot different from most VMs (certainly different from the JVM), is that it's a register machine rather than a stack machine. But I think people will be arguing for a long long time whether that can be called an advantage or a disadvantage.

Malan answered 28/11, 2009 at 5:34 Comment(0)
K
5

I don't know JVM and CLR enough, but my tips:

  • dynamic languages (closures, polymorphic scalars, continuations, co-routines) support (speed)
  • dynamic method dispatch,
  • first class functions,
  • first-class continuations,
  • parameters (optional, named, ..),
  • register based
  • has HLL interoperability provided at an assembly level
  • range of platforms

Update: This is probably irrelevant as JVM is one of Rakudo Perl 6 backends nowadays. See Rakudo Perl 6 on the JVM (Perl 6 Advent calendar 2013, Day 3).

Kayleen answered 24/12, 2009 at 12:16 Comment(0)
X
4

The main advantage and technical difference over the JVM and the CLR is that types (classes called PMC's) and ops (methods) may be dynamically loaded from efficient user-provided C implementations, and the parser framework to create and extend languages is built-in.

Xerox answered 5/9, 2014 at 15:47 Comment(0)
J
4

This question is outdated. Rakudo Perl 6 no longer targets Parrot as a backend; MoarVM is the preferred backend, with the JVM backend a work in progress (generally works, but many Perl 6 features not implemented or currently broken). Development work (not ready for users) is being done to add Javascript as a third backend.

Jerk answered 21/1, 2016 at 21:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.