• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Jython?

 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, what is Jython, and as a java developer, why do I need it?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's an implementation of the Python scripting language in Java. From my limited experience, it provides you most of the same benefits Perl can, but it (a) doesn't look like line noise, and (b) is easier to integrate with Java.
[ April 08, 2002: Message edited by: Jim Yingst ]
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for a java programmer, python is an obvious choice compared to perl.
I did try out OO Perl before checking out python.
Check out python2.2 (it has excellent features).
then learn jython.
Current version of jython is not same as that of python. SO you w'd'nt be seein the 2.2 features there. But that's fine.
You have access to all the java libraries + most of the python libraries also come for free.
But the documentation is'nt that good though :-(
I found python to be a little addictive once i started doing some stuff with that! ;-)
good luck.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am a java programmer with 3 years of experience. I have been using perl scripts on linux. Does jython provide the same features and advantages as compared to perl? Going through the documentation, it seems quite interesting . Can anyone tell me more about the advantages and disadvantages of using jython as compared to python.
Thanks.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ajit Malleri:
Hello,
I am a java programmer with 3 years of experience. I have been using perl scripts on linux. Does jython provide the same features and advantages as compared to perl? Going through the documentation, it seems quite interesting . Can anyone tell me more about the advantages and disadvantages of using jython as compared to python.
Thanks.


Yes, Python does what Perl does (generally speaking), but in a naturally more structured, object-oriented way. The advantages of Jython to Python include having immediate access to the Java class libraries and being able to run the script wherever there is a JVM. Disadvantages are that it may be slower and you cannot so easily interoperate with C/C++ (when running from a JVM).
Note, though, Jython, as much as possible, is Python. You can write and debug using Jython and then run the same script without a JVM using the Python interpreter (again, with a few caveats). Thus via Jython, Python is actually more platform independent than Java.
I speculate that the greatest value in learning Jython is to Java developers who don't know a scripting language, and who by learning one gain some tools they wouldn't otherwise have.
Cheers,
Glenn
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, but could someone provide some small examples of where it could be used and how?
thanks,
bear
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know of a good online resource for Jython?
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.jython.org/
that's the main place to start out at.But like someone said earlier, learn python first, because that's what jython is, just a more highly glueable version of it, and it was written in Java too
http://www.python.org/ is the main page for Python, you can find pleanty of documentation of it there.Try out the download for the Python tutorial, it comes in PDF format, pretty cool. And also they have in the Jython section of the site a downloadable version of "Thinking in Paterns with Java",, if you don't already have it, it's some good reading.And it's apparently been somewhat updated to cater to Jython users out there. Ohh and by the way, two cool things about the Python language, it's got alot of cool libraries beside the basic ones Python and Jython comes with.There is also Vpython, V stands for visual, and Pygame, which has special libraries for game developement.And the other thing is, scripts written in this language are very much shorter than programs written in other languages
And for you Perl progragramers, there's Parrot, which I didn't see when I stopped by the site, should be somewhere though,looks like it got bumped out by the new release of Python, I dunna know, ok, I'll stop talking your ears off now
 
Shawn Meyers
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://sourceforge.net/foundry/python-foundry/
has assorted info on Python and forums too
and http://hackers.com/bulletin/index.php?s=
has some good scripting lanhuage forums too
and http://www.jython.org/applets/index.html
is some examples of applets written in Jython
Ohh, and do you know where the name python came from??A snake??Nope, Monty Python hmm?,?
ok, just some after thoughts
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, but what can I do with Jython that I can't in java? Or why would I want to do something particular in JYthon that I wouldn't/couldn't want to do in Java?
I still don't have a sense of how it "works" and what it can do for me as a current java developer
 
Shawn Meyers
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Umm,,,what can you do that you can't do?,,umm, well,, you can make Java a scriptable language.Very simple and flexible string manipluation.Python has a little bit of everything you might like from other languages in it.I really think you should go over to http://www.python.org/doc/ ,, download the documentation and find out what Python is all about,after all, what Jython is, is an adaption of the Python language, in short, it is Python
Really,what it is about is intergrating a scripting language with Java.There are so many different functions and statements in it, even diferent kinds of lists, making your strings easier to manipulate later on in your code.But really, check out the Python tuitorial, find out what it's all about, it is pretty much the simplest language to learn, your not going to fry your brain checking it out, it's the ideal first language, and since it isn't you first language, you got it in the bag my friend And if it isn't to your likeing,awe well.
 
Author
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because Jython is written in Java, it's hard to say Jython does things that Java can't. But, if you look at it from a syntax point of view, Jython/Python is a higher level, uses dynamic typing, supports operator overloading, dynamic code evaluation (exec/eval) and has a full complement of functional programming tools. Don't forget that you also get Python's simple, clear syntax.
These attributes usually mean improved code readability, speedier development, shorter prototype/test cycle, and increased flexibility. I really get the sense that Jython is a great tool for trying to improve code quality too. The terse syntax, interactive interpreter and dynamic typing really help you see your design in a clear way.
Here's some of the places where it can't be beat. Extending apps with higher-level (scriping) languages is unparalelled because of how transparent the Java/Python boundary is. Unit testing is great because of how quick it is to write test scripts and because you can set "respectJavaAccessibility" to false Plugging Jython into servlet containers works well because Jython syntax is very text-processing friendly.
Hope this helps.
 
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

Originally posted by Robert W Bill:
Unit testing is great because of how quick it is to write test scripts and because you can set "respectJavaAccessibility" to false


Does that mean that Jython will let me access things marked private? If so, then I think I have found a Very Nice Tool indeed. Unit testing can reach a new level of completeness!
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about the speed issue ? In one word ? Comparing to a "normal" java app.
slower ? faster ?
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.jython.org/docs/differences.html
Here is the best source for the differences between the two languages.
 
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
Concerning "respectJavaAccessiblity"...
Yes, it means you can access private/protected fields/methods. Yes, it is good for unit testing, and there's an abvious warning that it's not intended for production, safety-critical apps.
Concerning speed, Jython is slower than Java. I usually write apps in Jython, then convert only the time-intensive portions to Java. This conversion usually gives me a 9x improvement in that class. It's usually 10% of classes that hog 90% of the machine, so that selective Java coding usually makes for acceptable apps in less dev time.
 
Brett Anthoine
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the answer.
 
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

Originally posted by Robert W Bill:
Concerning speed, Jython is slower than Java. I usually write apps in Jython, then convert only the time-intensive portions to Java. This conversion usually gives me a 9x improvement in that class. It's usually 10% of classes that hog 90% of the machine, so that selective Java coding usually makes for acceptable apps in less dev time.


Sounds like an improvement over the old 80/20 rule... I like it!
While I like the idea, I'm still concerend about the people who have to maintain "combination" apps after I'm gone. I have a button that says, "Write your code as if the person maintaining it is a homicidal maniac who knows where you live." It's a bit extreme I guess, but it reminds me that "tricky" code is often not a Good Thing - and that's kind of how I feel about mixing Jython and Java in the same app.
Mr. Bill, are you aware of any "best practices" to reduce this potential problem? Documentation easily falls behind - or is ignored altogether... is there something else you would recommend?
Thanks, Burk
 
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
I don't know of any proposed best-practices specifically for the python/java mixture. However, the sense of "combination" is minimal when using Java classes in Jython because Jython uses any java class without modification. Embedding Jython within Java is a notch more complicated. When embedding, A lot of people store their Jython scripts in creative ways (databases, remote servers, etc). This brings up one point where confusion often resides. Java has the classpath to locate classes and Jython has the sys.path to locate modules. This can get hairy, so it's important to clearly document how and why your sys.prefix, sys.path and any other properties related to these things are set. That's the trick to keeping homicidal maniac successors happy
 
Message for you sir! I think it is a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic