Java to Python translation

Bertrand Geston bergeston at yahoo.fr
Thu Apr 4 09:42:49 EST 2002


"Andrew McNamara" <andrewm at object-craft.com.au> wrote in message
news:mailman.1017831968.9815.python-list at python.org...
> >> > I need to translate a (rather voluminous 100MB) java program to
> >> > python. After a few searches on google, apparently the best tools
> >> > for this task are Lex-Yacc (Flex-Bison on linux). While I am working
> >> > on the Lex-YACC HOWTO, I would be very interested in hearing of
> >> > others' successful experiences/feedback at this. Any pointers of
> >> > interest would similarily be appreciated.
> [...]
> >I think for a project like that, even a success would be disastrous.
> [...]
>
> Indeed.
>
> But I bet a complete re-write in python would less than 10MB, and take
> less than a tenth of the time of the original project... 8-)
>
> The suggestion of using Jython would be good one - subsystems can be
> rewritten and tested as time and resources allow.
>

To translate Java to Python (no idea if it is worthy in this case, but in a
more general perpective, this is a problem that makes sense IMHO) , I wonder
about this intermediate solution:
1. use a parser/generator to translate the Java code to Jython code (with
eventually some generated 'util' Java classes for the calls to the JDK
packages and other libraries)
2. translate manually the Jython code to Python code if is is really worthy.

My guess is that step 2 could be a lot simpler to achieve than the whole
translation and that step 1 can be done automatically (even if the
development of the generator requires some investment that could be shared
in an open source project) because :
- Java and Python are not so far in their concepts,
- Python is more dynamic than Java and I suppose that this makes it simpler
than the opposite (Jython)
- part of the effort could help anyway (classes to manage the java method
overridde in Python, ...)

I have no experience in such area, any comments are welcome.



> --
> Andrew McNamara, Senior Developer, Object Craft
> http://www.object-craft.com.au/
>





More information about the Python-list mailing list