Why to use Parrot (or other VM) if I have an interpreter?
Asked Answered
R

2

5

Why should I use VM, like Parrot, for a dynamic language I use (Python, Perl, ...) if I already have an interpreter? What can I potentially gain, for the cost of having different VM between my code and my machine, and by using a separate interpreter?

(I am new in VM issue, so maybe the answer is obvious)

EDIT

What's the benefit of Parrot VM for end-users?

Rhnegative answered 17/8, 2011 at 13:44 Comment(4)
May I ask, what kind of "interpteter" do you have? Up to my knowledge, there are no ad hoc interpreters available for neither Perl nor Python - all the existing implementations are using VMs.Bolshevism
Well, regular interpreter. I didn't know that there is VM back thereRhnegative
Still, what are potential advantages of having a different VM than the one already delivered with an interpreter?Rhnegative
Having a single common VM allows to have common libraries, simplifies interoperability between different languages, reduces maintenance costs, and so on.Bolshevism
M
5

Why should I use VM, like Parrot, for a dynamic language I use (Python, Perl, ...) if I already have an interpreter?

First, if you're starting a project, then you may not already have an interpreter.

However, assuming you have an interpreter and are considering whether to add functionality to it or rewrite it to use Parrot, the tradeoffs that come to mind are:

  • In general, Parrot is probably better tested than the interpreter in question (better optimizer, better garbage collector, etc.)
  • In general, Parrot's developers know more about cross-platform issues than run-of-the-mill programmers
  • In general, Parrot has solved most problems you're likely to run into
  • Parrot was designed with complete generality in mind, and that added a ton of complexity; you may not need the extra generality

Personally, Parrot's optimizer (and register-based design, largely to make optimizations easier) and well tested cross platform codebase would be enough to convince me.

Macropterous answered 17/8, 2011 at 16:23 Comment(0)
A
4

Parsing the ASCII source code is slow. It is faster if the source file gets parsed once, and then the interpreter uses a binary structure. In Python this structure gets stored in .pyc files for fast reuse.

There are two steps:

  1. Parse the source, create byte code
  2. Run (interpret) the byte code.

This is used by e.g. scala: There is no scala-VM. Scala is just a new syntax. The scala compiler creates java byte code.

Arbela answered 17/8, 2011 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.