Andy Reitz (blog)

 

 

OSCON: Inside Ponie, the Bridge from Perl 5 to Perl 6

| 1 Comment

A port of the Perl 5 runtime to the Parrot interpreter (used by Perl 6). Allows you to run un-modified Perl 5 code on Perl 6. The focus is on Perl 5 XS, which appears to be the Perl module standard. Hence, the idea is to be able to run the CPAN modules that use XS on Perl 5 on Perl 6.

Perl 5 VM:
  • Stack machine
  • 300 instructions
  • OP tree, not bytecode
  • Never serializes these instructions out to disk (attempts to do this that have been bigger and slower)

Goal is to write and run Perl 6 code, run existing Perl 5 code, and run code that links to external libraries (XS). Call back and forth transparently. Pass data back and forth. Then we can convert Perl 5 code function by function to Perl 6 (nice).

After going through some problems with inline, the conclusion is that you need to have the code executing within one VM, with a single runloop. Can't compile Perl 6 code to Perl 5 -- VM not modern enough. Reverse is also hard -- Ponie provides another way. The Perl 5 language is defined by the C source (since there is only one implementation, and some quirks that aren't documented). There is a lot of complexity in how Perl 5 has been implemented, that must be bridged to get it working in Perl 6. There is a need to unify data storage, so Perl 5 data must be wrapped, so that it can be stored in Parrot.

Ponie is a big refactoring exercise. Work is linear -- each task depends on a previous task. Finding many bugs in the Perl 5 core. Fixing these, and making some improvements in Perl 5 core. What is still a little unclear from this talk, is how Parrot will actually work when it is finished. It looks like it will be integrated with Perl 6, and allow seamless execution of Perl 5 code, but I'm not sure. There might be an option to invoke it, or something.

-Andy.

 

 

1 Comment

"Can't compile Perl 6 code to Perl 5 -- VM not modern enough." is slightly exaggerating. It is true that Perl6 code compiled to perl5 will not have efficient threading or mix-encoding strings, but most production Perl programs don't use them anyway.
Anyway, I'll still pursue the plan of making Pugs eventually just be a pure-perl5 module on CPAN, where you can mix Perl6 code freely with Perl5 code, on the perl5 runtime. Multiple approaches is good; eggs, baskets etc... :-)