This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Bill and all, I am glad that i have chance to ask this question instead of digging into many documentations.(May be i am too lazy). I use Java and Python for sometimes in my projects(company's). I understand the strenght of each of these two languages. My question is, under what circumstances you will consider Jython as oppose to Python or Java? I am sorry this is a broad question. Thank for any reply.
Well, one obvious place where using Jython important is when you can't decide between Java and Python. Just use Jython and you don't need to decide- just move in and out of these two languages in the same app. If the app you are writting will never run in a Java framework, and it cannot benefit from Java's huge library of existing classes, then Python might make more sense. If you have a huge amount of OS-level work to do, then Python might make more sense. If raw runtime speed is primary, then use Java. Otherwise, it makes sense to use Jython or a combination of Jython and Java classes.
Joined: Jun 21, 2001
Bill, Thank you for the precise reply on my broad question. Your reply lead to another question. In concept, the overhead involve in Jython is higher that using Python or Java by itself. What is your opinion about these overhead? What are the decision pitfalls an application designer and implementer must be awared of? Since Python needs an interpreter and Java needs a virtual machine, Jython will need both of them. This make me feel that Jython may speed up the process of application development and give more flexibility in the design, but i don't see much gain in performance in using Jython. Am i in the right direction? Regards
Robert W Bill
Joined: Apr 08, 2002
You are right. As with most high-level abstractions there is a memory and performance penalty that you must pay to get the flexibility and quick development. This penalty isn't as large as the order of magnitude between C and some scripting languages implemented in C, so that's good. One anology that I really like is Java's hotspot. It looks for the code that needs optimizing and doesn't waste its time on the code that is rarely called anyway. That's what developing with Jython is often like. After writing something in jython, you can quickly tell which classes are those "hotspots" that are hogging the resources, and then move those to Java code. The Java/Python boundary is fairly transparent in Jython, so this is really easy and it leaves you with a fairly optimized app after a very light weight development cycle. I think Hotspot is great, and it makes sense to apply that thinking to development time as well.