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?

Seki
  • 11,135
  • 7
  • 46
  • 70
user20805
  • 1,347
  • 1
  • 11
  • 10

7 Answers7

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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
  • 1
    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. :-) – C. K. Young Sep 22 '08 at 23:43
  • 1
    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) – ysth Jun 24 '13 at 19:53
  • 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. – brian d foy Jun 25 '13 at 06:19
  • 1
    @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] – rurban Sep 23 '14 at 17:58
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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Serafina Brocious
  • 30,433
  • 12
  • 89
  • 114
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.

C. K. Young
  • 219,335
  • 46
  • 382
  • 435
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.

moritz
  • 12,710
  • 1
  • 41
  • 63
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).

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
Yordan Georgiev
  • 5,114
  • 1
  • 56
  • 53
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.

ironfroggy
  • 7,991
  • 7
  • 33
  • 44