xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:

I have this question because my colleague were trying to use a perl script I wrote on AIX 6.1 lately.

I tested the script on 5.12 linux version. Since built-in perl version in AIX 6.1 is 5.8.8, we have to update some modules to fit my script such as Cwd. unfortunately, the update of modules stuck us for a long time.

Finally, the script was working on AIX, but the price is that I remove invocation of Cwd and other modules similar to be possible to raise issues from my script, make use of standard modules shipped with perl at most, and rewite the part of the script about database calling in java because we all know installation of DBD::Oracle in AIX is another thing make headache, and time left us was short.

So, my question is , why perl5 doesn't run over a virtual machine like JVM does? In my opinion, it would make codes more portable and easy install. have any perl gurus been trying to port perl5 to Parrot or even JVM?

just a random question, hope gurus can enlighten me. Thanks





I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Replies are listed 'Best First'.
Re: why is there no a PVM for perl?
by moritz (Cardinal) on Jun 02, 2011 at 16:25 UTC
    So, my question is , why perl5 doesn't run over a virtual machine like JVM does?

    Hysterical Raisins, erm historic reasons.

    When Larry Wall started developing Perl, there weren't that many cross-platform virtual machines that were suitable for running Perl. I didn't do any computing back in those days, but my guess was there weren't actually any.

    The current Perl 5 compiler (which includes its own VM, for that matter) is the result of gradual evolution from the original perl 1 sources, there was never a complete rewrite, so no good opportunity to switch to another VM.

    There have been attempts to port Perl 5 to other VMs, but none of them have produced anything really compatible to perl 5. Given some idiosyncrasies in the parser, the runtime model and the XS API, that's not too surprising.

    Finally you should consider that whenever you port something to a more general backend, you have to compensate for some mismatch between desired and available semantics, and implement missing parts. That comes with a performance cost you need to pay.

Re: why is there no a PVM for perl?
by ikegami (Patriarch) on Jun 02, 2011 at 15:34 UTC
    What makes you think there isn't? Perl code is compiled into an intermediary form called opcodes. These opcodes is what are executed at run-time.

      In theory perl is a PVM. However in reality I found Perl often less compatible then claimed on various forums and places.

      The problem is not the core of Perl, but often the CPAN modules. A multitude depends on an specific underlying function call or program, often only found in the Linux world. The use of a XS interface, often present in the modules without any mention in the documentation, can really break portability.

      I love programming in Perl but I don't claim any more that it is portable. I always say that minor work is most likely. I ran often enough in the same kind problems while porting a script developed on Linux to Windows.

      So the grandparent has a point.

      I would like to know from fellow monks what kind tips and tricks they have in store to avoid a maximum number of problems. Parallelism is such item where I'm very weary for potential problems when porting code.

      my 2 cents

      Martell

        > A multitude depends on an specific underlying function call or program, often only found in the Linux world. The use of a XS interface, often present in the modules without any mention in the documentation, can really break portability.

        IMHO you are idealizing JAVA now, because use of native libraries causes the same problems there.

        For much the same reasons I try to avoid modules using XS. Just inspect the dependencies in CPAN and parse the code for DynaLoader to do so.

        Cheers Rolf

        In theory perl is a PVM. However in reality I found Perl often less compatible then claimed on various forums and places.

        Compatible with what?

        A multitude depends on an specific underlying function call or program, often only found in the Linux world. The use of a XS interface, often present in the modules without any mention in the documentation, can really break portability.

        What does Perl having a VM have to do with portability, especially those of native libraries? That's the point, not a question. The OP is conflating two topics.