Does there exist a Python-to-Perl translator ?

François Pinard pinard at iro.umontreal.ca
Thu Sep 27 11:59:13 EDT 2001


[Weet Vanniks]

> Does there exist a Python-to-Perl translator ?  This would help me produce
> Perl code after developing it in Python.  Thanks to all for answering.

None that I know.  Not so long ago, I invested some work in a Perl-to-Python
translator (`perl2py').  While doing so, I remember having remarked to myself
that a Python-to-Perl translator would be a much more difficult project.
The problem comes from the fact that Python is able to express more things
than Perl with simpler devices.  Just restoring meaningful `$', `@' or
`%' identifier prefixes would be a major difficulty.  One might resort to
simulate Python with Perl, more-or-less, having everything translated as
Perl references with types are meant to be resolved at run time.  But this
would be slow, unreadable, and probably nothing near practical.

Better rewrite by hand.  Or even better, convince people around you that
Python is much more maintainable than Perl, while being as powerful.

P.S. - `perl2py' is on the back burner for now, until I choose to revisit it.
It uses SPARK, with grammar formulations which are not speed-natural, and
the time sadly explodes with the size of Perl sources.  While reformulating
these grammars so they behave more quickly, I introduced many complexities
and ambiguities which I do not like.  I then decided to let things sleep
(and maybe mature?) for some while in the background.  Note that I'm still
very satisfied with SPARK -- it is just that I have to learn using it better.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list