From: Rob Andrews <rob@us...> - 2002-04-25 23:17:10
Please pardon such a novice question, but a friend far more well-versed
in Java than I am has asked me about writing Jython code and producing
from it human-readable Java source.
It seems to me this should be possible without a herculean effort, but I
don't know enough to come up with an intelligent answer on my own just yet.
Can someone point me in the right direction?
From: Kevin J. Butler <kevinbutler1@bi...> - 2002-04-25 23:55:16
Rob Andrews wrote:
> Please pardon such a novice question, but a friend far more well-versed
> in Java than I am has asked me about writing Jython code and producing
> from it human-readable Java source.
jythonc's output isn't what you're looking for?
OK, so maybe it is "human-interpretable" rather than "human readable". :-)
The only thing I know of to do a clean translation from Jython source to the
human-readable (equivalent, minimal) Java source is a human.
That said, it is very easy for simple stuff that is using Java objects:
- add type declarations
- add 'new' for constructor calls
- change __init__ to class name
- remove def
- add 'public' and friends
- remove 'self' and/or convert to 'this'
- add semi-colons & braces
- convert loop syntax
- print x, y -> System.out.println( x + ' ' + y )
Difficulties arise when you're using Python types and operators:
- a[n] translation depends on whether a is a sequence or dictionary
- for k, v in dict.__items__() becomes a mess of Map.Entry instances
And of course, if you're using Python library methods, conversion to Java is
difficult, but even so it is generally easier than writing it in Java
originally, because you've got a good prototype of what you want, and maybe
you can continue using the Jython runtime for parts of it.
Get latest updates about Open Source Projects, Conferences and News.