A vision for Parrot

Donal K. Fellows donal.k.fellows at man.ac.uk
Tue Nov 12 10:30:07 EST 2002


Benjamin Goldberg wrote:
> Considering that Jcl and Jython exist, it seems like a reasonable goal

(JCL is something else.  I'd rather not remember it thankyouverymuch.)

> would be to make an interpreter which turns Java's .class files into
> Parrot .pasm files.  Once that tool exists, one could simply translate
> Jcl and Jython into parrot... there would be no need to re-implement
> them.
> 
> And one day, in the distant future, there will be a Perl6 decompiler,
> which will turn Parrot bytecode into Perl6.  Then we'll be able to
> convert the translated Jython and Jcl into Perl6 :)

$10 says that only ever happens with a performance hit.  The problem is that not
all bytecodes are created equal.  (And Jacl is an implementation of Tcl in Java
more in the way that the usual form of Tcl is an implementation of the language
in C.  The fact that Java uses bytecodes is pretty much just a distraction
here.  We also have another way of integrating Tcl with Java that keeps Tcl
implemented in C, but which integrates almost identically with the Java
language.)

> > This sort of thing tends to make me suspicious that this is little
> > more than a pipe-dream, well, at least as far as Tcl's concerned.  (I
> > don't know the other languages nearly well enough to comment in a
> > useful way.)
[...]
> Assuming you thouroughly understand Tcl's bytecodes, why not take a look
> at Parrot, and see whether the set of bytecodes that parrot supports is
> sufficient to do everything that Tcl's bytecodes do?

I know a bit about Tcl bytecodes, and a key factor about them is that they are
very tightly targetted towards implementing Tcl.

Hmm.  A quick scan through the documentation doesn't really raise my hopes.  Or
even leave me with a deep enough understanding of what's going on; is there any
deeper description than http://www.parrotcode.org/docs/parrot_assembly.pod.html
about?  (OK, Tcl's bytecodes need documentation too, but I've already gone to
the effort to understand those as part of my maintenance and development
duties.  I've just not got enough hours in the day.)  Unfortunately, the bits
that I'm most interested in seem to be the bits with least info (isn't that
always the way with complex software systems?)

First impressions: what is meant by "string" anyway?  Character sequence?  Byte
sequence?  UTF-8 sequence?  ISO 8859-1 sequence?  [FX: Reads docs]  Oh, they
carry about what their encoding is with them?  That must make working with them
fun.  How does it handle things like the blecherous monstrosities[*] used for
system encodings in the Far East?  On a quite separate point, is there a
strncmp() equivalent?  That would make implementing Tcl much easier...

More generally, Tcl would need to use PMCs throughout.  The problem is that
Tcl's value semantics (copy-on-write) do not line up well with that which Parrot
seems to use (object-based) and which, IIRC from the discussions at the time
when Parrot was being created, are closely based on those used in Perl even if
not precisely coincident.  Hence we'd be unable to use ground values except as
part of the implementation of higher-level concepts.  That'll impact badly on
performance.

It's at this point that I feel a round of "Stuff it. I'll stick to implementing
in C." coming on.  I've been quietly watching Parrot for a while now, and I
still don't think that implementing Tcl in it is really a winning proposition. 
I'd love someone to prove me wrong, but proof is building a Tcl interpreter in
or on top of Parrot and running the Tcl test suite on it (and getting a decent
proportion of the tests passing.)

BTW, how does Parrot handle calls to foreign code?  The docs I've seen are on
the hazy side, and integration with existing C, C++ and FORTRAN monoliths is
(alas) all too important in particularly commercial development.

Donal.
[* The cluster of things known as "Shift-JIS" justifies this term. IMHO. ]
-- 
Donal K. Fellows   http://www.cs.man.ac.uk/~fellowsd/   donal.fellows at man.ac.uk
-- The small advantage of not having California being part of my country would
   be overweighed by having California as a heavily-armed rabid weasel on our
   borders.   -- David Parsons <o r c @ p e l l . p o r t l a n d . o r . u s>



More information about the Python-list mailing list