• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jython ? what for ?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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???
 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 883
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm curious, if Jython is related to Python script, would it be easier to learn Python first and then Jython? Or vice versa?
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Author
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 883
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic