What exactly is Parrot?
Asked Answered
D

7

26

I understand that Parrot is a virtual machine, but I feel like I'm not completely grasping the idea behind it.

As I understand, it's a virtual machine that's being made to handle multiple languages. Is this correct?

What are the advantages of using a virtual machine instead of just an interpreter?

What specifically is Parrot doing that makes it such a big deal?

Defensible answered 22/9, 2008 at 23:4 Comment(0)
L
37

Parrot is a virtual machine specifically designed to handle several languages, especially the dynamic languages. Despite some of the interesting technology involved, since it can handle more than one language, it will be able to cross language boundaries. For instance, once it can compile Ruby, Perl, and Python, it should be easy to cross those boundaries to let me use a Ruby library in Python, a Perl library from Python, so whatever combination that I like.

Parrot started in the Perl world and many of the people working on it are experienced Perl people. Instead of using the current Perl interpreter, which is showing its age, Parrot allows Perl to have features such as distributable pre-compiled modules (which everyone else has had for a long time) and a smarter garbage collector.

Lingual answered 22/9, 2008 at 23:28 Comment(4)
Thanks for a good response from a member of the Perl community! I had no votes left, but once the day ticks over (in 15 minutes' time) I'll vote you up. :-)Bentwood
Perl has had distributable pre-compiled modules for a long time; they just never caught on (largely because they are just a dump of the in-memory format of the compiled code, so they end up being big enough that the time to load them from disk can be longer than the time it would take perl to regenerate them from the source code)Clementeclementi
From what I remember reading, the PMCs also only worked in certain situations. I never explored them because I recall breaking them quickly. I forget the details though.Lingual
@ysth: completely unrelated topic, but pre-compiled perl5 bytecode .pmc modules do work fine for some time. To the size bit: p5p deliberately broke B upstream in 2011 with 5.14 [perl #81332] "744aaba059 bloats the B compilers." You need to patch B or use perlall --patches=Compiler to get small and fast .pmc files. But it's faster to load .pmc than .pm of course. Parrot .pbc files, as @brian already explained are architecture cross-compatible. pmc not. [interestingly I'm the maintainer of both, parrot and B::Bytecode]Bridewell
C
21

Chris covered the user-facing differences, so I'll cover the other side.

Parrot is register-based rather than stack-based. What that means is that compiler developers can more easily optimize the way in which the registers should be allocated for a given piece of code. In addition, the compilation from Parrot bytecode to machine code can, in theory, be faster than stack-based code since we run register-based systems and have a lot more experience optimizing for them.

Cholera answered 22/9, 2008 at 23:15 Comment(0)
B
14

Parrot is a bytecode interpreter (possibly with a JIT at a future stage). Think Java and its virtual machine, except that Java is (at the moment) more geared towards static languages, and Parrot is geared towards dynamic languages from the beginning.

Also see Cody's excellent answer! Highly recommended.

Bentwood answered 22/9, 2008 at 23:6 Comment(3)
Another important point to mention is that Parrot is register-based intead of stack-based, unlike the JVM and CLR. This can, in theory, make optimization easier as we have much more experience with register-based systems.Cholera
Cody: You should post that so I can +1 your comment. :-)Bentwood
Actually parrot has had jit, for x86 systems at least, for a while now.Bradney
A
8

Others have given excellent answers, so what remains for me is to explain what "dynamic" languages actually mean.

In the context of a virtual machine it means that the type of a variable is not known at compile time. In "static" languages the type (or at least a parent class of it) is known at compile time, and many optimizations build on that knowledge.

On the other hand in dynamic languages you might know if a variable holds a container type (like an array) or a scalar (string, number, ...), but you have much less type information at compile time.

Another characteristic is that dynamic languages usually make type conversions much easier, for example in perl and javascript if you use a string as a number, it is automatically converted to a number.

Parrot is designed to make such operations easy and fast, and to allow optimizations without knowing having type informations at compile time.

Athirst answered 22/9, 2008 at 23:4 Comment(1)
It's not just about types. Dynamic languages allow you to redefine various non-type things after compilation.Lingual
S
2

Here is The Official Parrot Wiki.

You can find lots of info and links there.

The bottom of the Parrot wiki home page also displays the latest headlines from the Planet Parrot feed aggregator.

In addition to the VM, the Parrot project is building a very powerful tool chain to make it easier to port existing languages, or develop new one.

The Parrot VM will also provide other languages under-the-covers support for many powerful new Perl 6 features (please see the Official Perl 6 Wiki for more Perl 6 info).

Parrot will provide interoperability between modules of differing languages, so that for example, other languages can take advantage of what will become the huge Perl 6 version of CPAN (the vast Perl 5 module archive, which Perl 6 will be able to access via the forthcoming Perl 5.12).

Simas answered 28/9, 2008 at 23:59 Comment(0)
U
1

Honestly, I didn't know it was that big of a deal. It has come a long way, but just isn't seeing much use. The main target language has yet to really arrive, and has lost a huge mind-share among the industry professionals. Meanwhile, other solutions like .Net and projects like Jython show us that the here-and-now can beat out any perceived hype.

Undermine answered 29/9, 2008 at 0:37 Comment(0)
R
1
  • Parrot will be what java aimed for but never achieved - a vm for all OS's and platforms
  • Parrot will implement the ideas behind the Microsoft's Common Language Runtime for any dynamic language and truly cross-platform
  • On top of everything Parrot is and will be free and open source
  • Parrot will become the de facto standard for open source programming with dynamic languages
Ron answered 3/5, 2012 at 17:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.