wood burning stoves 2.0*
The moose likes Jython/Python and the fly likes Jython ? what for ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "Jython ? what for ?" Watch "Jython ? what for ?" New topic
Author

Jython ? what for ?

Nagarajan Seshadri
Greenhorn

Joined: Feb 14, 2002
Posts: 2
Java as such is very good as an object oriented programming..language..and if at all there is a need for some scripting..we have javas predecessor..javascript..for the purpose...
Most ppl even doesnt know what for we have python and languages of that origin....
when this is the way...S/W world is moving..2..why do we have another new Prg.lang...Jython?? coming here???
Rishi Singh
Ranch Hand

Joined: Dec 09, 2000
Posts: 321
Hi Seshadri,
I guess it combines the power of Perl and JavaScript into one.we have excellent String manipulation becomes very easy in perl and the same is not provided in javascript.So if it integrates Perl + JavaScript then nothing like it.Well it sounds intreating , lets see ..??? what it is all abt

Rishi Singh
SCJP,SCWCD
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

there are certainly advantages in integrating languages of differnt types to achievedesired results: Java and SQL via JDBC, Java and XML, Java and XSLT, and I'm sure there are others...
I'm not seeing the advantage in directly integrating Java and Jython...
I read the O'Reilly article and i like the fact that you can write Jython line by line to simulate Java GUI code, makes GUI development easier.
If you're using it to write code that looks like Java, but is just shorter, or for a one-off script, I still don't see Java as such an overhead. (but then maybe I overuse Java)
If I haven't (till this point in my life) missed any of the features that Jython provides over Java, does it mean I'm doing things wrong or that I don't really need those features?
OK, so it turned into a bit of an attack. I am keen to be educated though. Who wants to argue the case?
Dave
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Yeah i second your views.
But i guess jython is recommended only for rapid prototyping and improved productivity and not for delivering a enterprise solution.
The number of lines of code that we will write in jython will *definitely* be n times lesser than
java. I found java to be a bit verbose ;-)
I if i can represent a dictionary by

rather than

i'm already seeing improvement in productivity ;-). Yeah i don't want to talk about java.util.Enumeration methods now ;-)
and yeah the shell interface is great esp for those new to java programming.
Why s'd I be expected to write a class just to figure out how to use a hashtable / arraylist?
i don't see much OO there but still am forced to write a class with a main.
jython is 100% pure java and i don't think it can provide us anything more than what java does.
I guess the jython file that we write will be ultimately coverted to a java .class file? and i feel that the performance w'd'nt be as good as an equivalent java code.
But when i do prototyping do i look for performance?
I found the features in python2.2 to be very intutive and i hope those things will figure in jython soon.
I have played around with jython a bit.
I guess the author / someone and will correct me if there is anything wrong with my observations.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by karthik Guru:
I guess the jython file that we write will be ultimately coverted to a java .class file? and i feel that the performance w'd'nt be as good as an equivalent java code.
But when i do prototyping do i look for performance?

There is an aticle profiling various Java scripting tools at JavaWorld here including some benchmarking against Java and others.
I'm still reading through, but it appears that there are significant differences. It seems like you'd definitely restrict its use to one-off or simple behaviour tasks (like you'd do in batch files?) and not in enterprise, critical or threaded environments...
Jeff Caswell
Greenhorn

Joined: Mar 20, 2002
Posts: 6
I'm replying to qualify for the free book giveaway but am interested in any Java news like this anyway. I still consider myself a novice when it comes to the whole scope of Java, but my general experience tells me that Jython is probably just another buzz word trying to hook you into spending precious time learning something you can already do quite easily with what is already out there. If it is written with 100% Java, then why not just use Java yourself to do the same task?
Morten Moeller
Ranch Hand

Joined: Nov 26, 2001
Posts: 30
The reason to not just use Java is simple.
Sometimes one would like to be able to let the user automate certain features or script functionality in an application. To do this you need an embedded scripting language like Jython (or Rhino, Jacl). This was an end user can change the behavior of a running program basicly.
Most text editors, irc clients, IDEs has this feature and it gets more and more common in most applications to embed a scripting language these days.
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Jeff,
In response to your question, "Why not do it yourself?" I have to ask when's the last time you intentionally wrote code that replicated an existing, tested, class?
If you've ever written an interpreter, you know how difficult it can be. So if you need a scripting language in your app, why re-invent the wheel and get stuck having to handle support calls for it. Go with something like Jython and tell 'em "RTFM."
Burk


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Stephen Peterson
Ranch Hand

Joined: Dec 25, 2000
Posts: 33
Bruce Eckel has some interesting stuff out available as a download from his website -
check the Thinking in Patterns,(Under Development) download at his download page.
He has an interpreter design pattern for which he motivates the use of python/jython to Java programmers. This exceprt from his summary of chapter 9 seems relavant:
To me, Python and Java present a very potent combination for program development because of Java’s architecture and tool set, and Python’s extremely rapid development (generally considered to be 5-10 times faster than C++ or Java). Python is usually slower, however, but even if you end up re-coding parts of your program for speed, the initial fast development will allow you to more quickly flesh out the system and uncover and solve the critical sections. And often, the execution speed of Python is not a problem – in those cases it’s an even bigger win. A number of commercial products already use Java and Jython, and because of the terrific productivity leverage I expect to see this happen more in the future.


United Health Group<BR>Hartford, CT, USA
Wai-Ming Lau
Greenhorn

Joined: Mar 14, 2002
Posts: 6
I'm curious, if Jython is related to Python script, would it be easier to learn Python first and then Jython? Or vice versa?


Wai-Ming Lau<br />SCJP2, DB2 DBA
Doug Wang
Ranch Hand

Joined: Oct 05, 2001
Posts: 445
David,
Thanks for your recommendation. A really good read.
karthik,
I second your views.
Yes. I think jython is just suitable for rapid prototyping not for application, though it can freely access tons of Java objects. But as a Java programmer, I am delignted to see I have a handy scripting tool for my administrative task, rapid prototyping task, and debugging task, etc.
Originally posted by karthik Guru:
But i guess jython is recommended only for rapid prototyping and improved productivity and not for delivering a enterprise solution.


Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep
Robert W Bill
Author
Greenhorn

Joined: Apr 08, 2002
Posts: 21
I found the skeptic's thread- Great!
I always appreciate the skeptic's thoughts because I'm a cynical skeptic at heart
Jython has some advantages, but you should hear that about every language. There had to be a perceived advantage or the language should have never been written. The trick is to know when one of those advantages directly applies to your development project or development style. There's no way Jython fits the bill (no pun intended) for everyone, so the best approach is offering a good picture of Jython's niche to help you decide. Here's my crack at it.
Jython is the Python language implemented in Java. High-level languages, famous in C/C++ for embedding, scripting and rapid prototyping are becoming poplular/valuable to the Java world. This inspires two questions.
Q1 - Is there cause to use a scriping language along with Java? If you write an app that you want end users to extend/script/automate/customize, or if you collaborate with more than just the hardcore Java programmers, then the answer is yes. If you want better approaches for unit testing, DB reports/maintenance, web development, and anywhere there are fickle clients that frequently request changes, the answer is yes.
There's other reasons to pursue a high-level languages which are often similar to justifications for the interpreter pattern, but most programmers know when they get there.
Q2- Is Jython the best high-level language to choose if you decide you want one? No non-commercial representative is daring enough to bluntly say yes or no to these kind of language-war questions, but here's the hints I can offer.
If you appreciate Python's syntax, its ability to make confusing/complex logic easier to work out/understand, then the answer is obviously yes.
Jython's OO structure combined with the transparency between Python and Java really creates a fluid mix. So, you can use java
and jython classes interchangeably balancing Jython's rapid development and clear syntax with java's much faster runtime speed, all in a consistent OO structure. This might be one of those zen-like things that you have to experience to appreciate the blend.
Python developers can rave on for hours about productivity beyond all other language, so you can say "ditto" about Jython. Prototyping apps in Jython aften takes the same time it takes me to write proposals for most projects. Note that productivity is an important and frequent topic, but should take a back seat to code readability and other quality issues (see the "zen" issue above).
Yes, Jython is slower than java, but focussing on speed ignores the advantages of a pre-packaged interpreter pattern for embedding, clarity of code, maintainability, and the other
advantages Jython seeks to offer. Jython also has such a small learning curve so it fits more people.
Jython's interactive evaluation is great for learning new libs. Jython's functional programming tools are often a refreshing surprise for the Java OOP crowd. Jython's reflection tricks are useful. If you want operator overloading, use Jython. Need dynamic typing, try Jython. Want meta-classes, limited multiple-inheritance... well, you get the picture.
If something in here caught your attention, Jython may be worth investigating. If not, don't bother.
Either way thanks for your posts!
Cheers,
Robert
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Me, a sceptic? I trust you have proof.
I can see the advantages you mention, but how would you weigh them against the added complexity that bringing a second language into a project creates?
Especially if we begin to mix the two - which would probably happen, they seem made for it.
Nevertheless, a newbie on the project would probably be more than a tad confused - particularly if they weren't familiar with Jython.
Any idea how long it takes the average (if there is such a thing) developer to "get his head around" the language and start thinking in it? I feel that's the point where you understand the language well enough that you work with it instead of trying to do things the way you do in some other language.
Sorry for the wordy-ness. I suspect most developers are familiar with the feeling though. It happens when you're working with a new language and suddenly realize that it makes sense to you, you aren't "translating" it anymore.
I've learned a lot of languages over the years and I'm probably gonna learn Jython too. It looks to tempting not to...
Burk
Originally posted by Robert W Bill:
I found the skeptic's thread- Great!
I always appreciate the skeptic's thoughts because I'm a cynical skeptic at heart
Jython has some advantages...
Jython's OO structure combined with the transparency between Python and Java really creates a fluid mix. So, you can use java
and jython classes interchangeably balancing Jython's rapid development and clear syntax with java's much faster runtime speed, all in a consistent OO structure. This might be one of those zen-like things that you have to experience to appreciate the blend.
Python developers can rave on for hours about productivity beyond all other language, so you can say "ditto" about Jython. Prototyping apps in Jython aften takes the same time it takes me to write proposals for most projects. Note that productivity is an important and frequent topic, but should take a back seat to code readability and other quality issues (see the "zen" issue above).

[ April 10, 2002: Message edited by: Burk Hufnagel ]
Robert W Bill
Author
Greenhorn

Joined: Apr 08, 2002
Posts: 21
The complexity question is a good one, especially in development teams. New languages and mixing languages sounds like something that can throw a wrench in things. I haven't worked with a lot of different dev teams, but I have to say that the primary draw to Jython for me is the lack of complexity. The Python language is a one-week project for a Java programmer. I don't mean to trivialize the importants of really learning the details of the language, which takes a month or two, but real productivity is a week or less away.
The real battle against complexity comes when mixing languages. Again, this is why I'm drawn to Jython. This starts with my love of hotspot. It's a great concept- optimize what needs it most. I love it so much that I apply it to human time on the development side of the equation. I write in Jython, and port those 10% of classes that are resource hogs to Java. This only makes sense if the mixing of languages doesn't add undue complexity. The Python/Java union in Jython seemed special in this regard because the transparecy seemed to allow this hotspot-like development model without adding any sizeable complexity.
This is pretty anecdotal, but you've really hit the topic that drew me to Jython in the first place.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jython ? what for ?
 
Similar Threads
Jython
import .so files
Any Resources for Jython ?
Jython with JDK1.5
How to assess the execution time