Pugs, PONIE, Parrot, and the Path to Perl 6

Peter Scott, the author of Perl Medic,
has been reading my book, Perl 6 Now
and commenting on it.
He recently completed reading it and
wrote
the most informed review of Perl 6 Now
I've seen.
But it's not shallow praise.
In fact, oddities about P6N got me to thinking
about P6N came about, how P6N stemmed from
predictions about how Perl 6 would come about,
and how those predictions were almost
correct, and how Pugs surprised
me for reasons other than it probably
surprised you.

Perl 6 and Parrot Essentials is staunchly
about Perl 6's grammar and Perl 6 on the
Parrot platform.
Perl 6 Now,
by contrast, is about Perl 6 using the Perl 5
virtual machine as a platform. (It's
also less about syntax and more about the
basic concepts.)
This might sound like a gag, get this,
I was convinced someone was going to
haul off and write a Perl 6 grammar that
didn't target Parrot, at least immediately.

It seems completely logical to target Parrot,
as Parrot was designed by Perl people
and it's designed for Perl 6.
But the bytecode format is il-documented,
register allocation in the virtual machine
isn't finalized, portability is still
immature, and it's less complete of
an implementation than Perl 5.
That's the magic thing -- I thought someone
was going to haul off and implement a
Perl 6 grammar in Perl 5, targeting Perl 5
(either through code translation or through
bytecode generation).
I thought we'd see a Perl 6 implementation
overnight that used
Perl6::Rules
and
Coro, among other things (most of them
documented in P6N) as the actual basis of
implementation.
I was psyching myself up to do a lot of the
work, too.
Someone more familiar with the Perl 6 grammar
than myself just had to jump in and start
writing that parser.
(Actually, there was a Perl 6 grammar in
Perl 5 included with Parrot, but it was
languishing, and I was just starting to
try to pick it up.)

I tried to get into Parrot development
briefly, but the more I got into it, the
more I started to feel that the Perl 5 codebase
wasn't so bad.
Complexity of Parrot was running wild.
The main point of rewritting the VM was
to make the code accessible to developers
to avoid the problem with Perl 5, where only a
small handful of people understood the code.
But fewer people understood Parrot than the Perl
5 VM.
And from the beginning, it was emphasised
that Perl 6 was not to be tied to any one
implementation.
When I wrote P6N, I was dubious of Parrot, and I'm still
feeling cautions (I side with
Joel on Software regarding his never rewrite
software article).

I was kind of expecting the PONIE effort to overhaul Perl 5's guts to the point
where they were clean and usable. PONIE has already factored out sv, av, hv,
and gv usage and replaced them with Parrot PMCs. That's a lot of the mess in
the Perl 5 interpreter, gone. Granted, the avs, hvs, etc, were just
encapsulated in PMCs, but this paved the way to moving all of the datatype
management and calls to sv_upgrade and all of that into nicely encapsulated
objects. Then I was expecting someone would write a Perl 6-to-Perl 5 translator,
or just a generic Perl 6 grammar in Perl 5, leaving me in a good position to
jump in and do a Perl 5 "B" backend. And then a Parrot backend would be used
for code generation, and the whole ball of wax could be turned into a binary,
and then Perl 6 would become self-hosting. I expected that things like
Perl6::Rules and Coro would actually become the de facto implementations
of these Perl 6 features for several years, until Parrot really became
competitive.

But no. Autrijus just had to write the grammar in Haskell and reimplement
the whole virtual machine at the same time. The plan is still to some day rewrite
the Haskell in Perl 6, create a Parrot back-end, generate a binary of itself,
and make it self hosting.
This plan reads just as I expected would
happen except s/Haskell/Perl 5/.

Right now I'm throwing my initial stones at a Perl 5 "B" VM backend
for Pugs.
Or I hope that's what I'm throwing stones at.
First step, learn Haskell
(step zero, forget all of my false starts
with Parrot, lang/perl5, etc).
Step two, fix up B::Generate
so it understands lexicals, so I can do proper
Perl 5 code generation.
Step three, get B::Generate running under
Inline::Pugs
so the Pugs universe and Perl 5 universe
exist at the same point and time.
Then learn how to navigate Pugs bytecode.
The rest is glue.

In summary, Pugs is a good thing,
Parrot is still useful for code generation
and bootstrapping even though I'm glad
people aren't waiting for it to be finished
and use it as the primary VM,
Perl 6 Now is still as relavent as I thought
it would be half a year later
though it took a lot longer getting
any press than I had hoped thus wasting
precious relavency, bootstrapping
is a fun and interesting CS problem,
and a language doesn't have to be self
hosting to be cool and useful.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Without JavaScript enabled, you might want to
use the classic discussion system instead. If you login, you can remember this preference.