You can always create java code the same way webapps create HTML: with a template. Then you can have the java source code compiled into bytecode using a regular Java compiler ( see: Package javax.tools )
Not necessarily the best option, but definitely an option ( and quite simple btw )
Answer from OscarRyz on Stack OverflowYou can always create java code the same way webapps create HTML: with a template. Then you can have the java source code compiled into bytecode using a regular Java compiler ( see: Package javax.tools )
Not necessarily the best option, but definitely an option ( and quite simple btw )
Reuse is good. Complexity is a price.
It will make you pay twice or more later on. Measure your ROI (Return on Investment) before you make a leap.
[Edit:]
- You could use Jython which will make it easy to write glue code as calling Java functions.
- jythonc transforms Python source code into Java source code then invokes a Java compiler to turn it into .class files.
- As said, you could use templating. Some one did use cheetah for that purpose. Though the link is not available any more.
Python Code Generation Tools
Anyone know a good library to generate random REAL address data? Can I with Google Maps API?
Transitioning from Python to Java
Best way to combine Python and Java?
What types of Python code can be converted to Java?
Is the Python to Java converter free?
Can I also convert Java back to Python?
Videos
What do you guys use to generate Python code? I saw that a lot of people just use Jinja2 with some templates, which looks simple and powerful. You still have to generate the environments and write the templates. Now I'm looking around whether someone already did the work of generalizing that step (thinking about fields in classes, inheritance, constructors etc. and how to map that data to the environment) or whether I have to do it myself.
TLDR: Are there simple but powerful Python code generation "frameworks"?
EDIT:
-
I found pymultigen. Seems like it helps with creating code in multiple files.
-
Looks like pyecoregen is a specialized multi-file code generator based on pymultigen.