stefan_ml at behnel
Jun 4, 2012, 8:27 AM
Post #3 of 3
Narayanaswamy, Mohan, 04.06.2012 16:56:
Re: Where is the latest step by step guide to use Jython to compile Python into Java?
[In reply to]
> Python is dynanmic programming (but strongly typed), java is
> static-typed language. Currently it is not possible to convert python
> into java, since python types are dynamically identified, not identified
> during compilation.
That's not entirely true. It's *possible* to translate Python to Java, just
like it's possible to translate Python to C or other statically typed
languages. That wouldn't be a 1:1 mapping from Python language constructs
into similar looking Java language constructs, simply because the Python
constructs tend to be more powerful and general, so there is no simple
direct mapping. But assuming sufficiently complex Java code, any Python
code can be translated to equivalent Java code.
Simple prove: Jython can execute Python code, and Jython is (at its basis)
written in Java. If you now collect all Java code that Jython executes
during the run of a Python program, you get pure Java code that is
equivalent to the Python program. Maybe not beautiful code, but definitely