From: Joshua F. <jo...@jo...> - 2001-05-24 06:12:57
|
I have enjoyed reading Eckels' work in Thinking in Patterns about Jython's capabilities in scripting Java apps. We have not found any other documentation about the Java-specific capabilities of Jython: Calling Java classses from Python, interpreting Python code in a Java app, compiling Python classes to *.class, etc. Is there any such documentation? Joshua |
From: Alexander S. <ast...@ma...> - 2007-01-19 18:29:40
|
Generally should questions or comments about jython documentation be sent to the users list, dev list or submitted to sourceforge as bugs or feature requests? I have two specific things regarding additions to the documentation and I will mention them here for now. 1) Java Collections Integration. I encountered jython when this was a hot topic on the lists and the implementation was becoming complete. I think someone coming to jython now might remain ignorant of it. Of course it is absent from the canonical "Jython essentials" and "Jython for Java Developers" as it is part of Jython 2.2. When I checked the web site I failed to find any mention of this feature. It is really not written up on the current web site or am I missing it? 2) Jython (non)interaction with java generics Jython completely ignores java generics. In my opinion this is trivial but non-obvious. It is trivial once I remember that java generics have no support in the JVM and are essentially compile time magic (please correct me if i am wrong on this). It is non-obvious because I don't normally think about such things when just using code. I wouldn't have seen this behavior without deliberately setting out to test it. Generics provide no type safety to jython scripting on java collections. I suspect this could be the source of nasty bugs for the unwary. Is this issue worthy of documenting? Thank you, Alex Stoddard |
From: Leo U. <leo...@ya...> - 2007-01-19 18:48:58
|
yup, your right about Java's generics not existing at runtime. If java objects were naked in jython we could probably do some quick cast checks in the generated code, but alas they are not. Outside of that checking could always be put in the layer surrounding the collection class, but I don't think it would be a cheap thing to do. Every add would probably require a native method check. On the other hand, in developing the proxy method code Ive got a way around using this native method check so it conceivably use the same thing. leouser p.s. there is talk about changing generics in java for 7... --- Alexander Stoddard <ast...@ma...> wrote: > Generally should questions or comments about jython > documentation be > sent to the users list, dev list or submitted to > sourceforge as bugs > or feature requests? > > I have two specific things regarding additions to > the documentation > and I will mention them here for now. > > 1) Java Collections Integration. > I encountered jython when this was a hot topic on > the lists and the > implementation was becoming complete. I think > someone coming to > jython now might remain ignorant of it. > > Of course it is absent from the canonical "Jython > essentials" and > "Jython for Java Developers" as it is part of Jython > 2.2. When I > checked the web site I failed to find any mention of > this feature. It > is really not written up on the current web site or > am I missing it? > > 2) Jython (non)interaction with java generics > Jython completely ignores java generics. In my > opinion this is > trivial but non-obvious. It is trivial once I > remember that java > generics have no support in the JVM and are > essentially compile time > magic (please correct me if i am wrong on this). It > is non-obvious > because I don't normally think about such things > when just using > code. I wouldn't have seen this behavior without > deliberately setting > out to test it. > > Generics provide no type safety to jython scripting > on java > collections. I suspect this could be the source of > nasty bugs for the > unwary. Is this issue worthy of documenting? > > Thank you, > Alex Stoddard > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get > the chance to share your > opinions on IT & business topics through brief > surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > ____________________________________________________________________________________ Now that's room service! Choose from over 150,000 hotels in 45,000 destinations on Yahoo! Travel to find your fit. http://farechase.yahoo.com/promo-generic-14795097 |
From: Diez B. R. <de...@we...> - 2007-01-20 10:26:01
|
> 2) Jython (non)interaction with java generics > Jython completely ignores java generics. In my opinion this is > trivial but non-obvious. It is trivial once I remember that java > generics have no support in the JVM and are essentially compile time > magic (please correct me if i am wrong on this). It is non-obvious > because I don't normally think about such things when just using > code. I wouldn't have seen this behavior without deliberately setting > out to test it. > > Generics provide no type safety to jython scripting on java > collections. I suspect this could be the source of nasty bugs for the > unwary. Is this issue worthy of documenting? Why do you single out generics? There is no type annotation support in jython _anywhere_, it is the very reason I prefer jython over java in most cases. So why should anybody expect foo = "bar" foo = 100 to work, while map.put("foo", 100) map.put(100, "foo") expect to puke with type errors? So I'd say no, there is no need to especially document that. Diez |
From: Alexander S. <ast...@ma...> - 2007-01-22 15:42:41
|
On Jan 20, 2007, at 5:25 AM, Diez B. Roggisch wrote: >> 2) Jython (non)interaction with java generics >> Jython completely ignores java generics. In my opinion this is >> trivial but non-obvious. It is trivial once I remember that java >> generics have no support in the JVM and are essentially compile >> time magic (please correct me if i am wrong on this). It is non- >> obvious because I don't normally think about such things when >> just using code. I wouldn't have seen this behavior without >> deliberately setting out to test it. >> Generics provide no type safety to jython scripting on java >> collections. I suspect this could be the source of nasty bugs for >> the unwary. Is this issue worthy of documenting? > > Why do you single out generics? There is no type annotation support > in jython _anywhere_, it is the very reason I prefer jython over > java in most cases. > > So why should anybody expect > > foo = "bar" > foo = 100 > > to work, while > > map.put("foo", 100) > map.put(100, "foo") > > expect to puke with type errors? I was thinking specifically of the case of interacting with existing java libraries. Java methods still demand correct typing when used from jython. You get errors when doing things like: >>> d = java.util.Date("'100") And the same would be true for methods on any java classes one has written. However misusing a java generic will give no such error. So you may get a deferred type error in java code which a java programmer would think has been prevented by specifying the generic. So the issue isn't the lack of type safety in jython, which I agree is generally a gain, but the "odd" behavior of generic typing in java code called from jython. Without thinking carefully about it one might start looking for bugs in the wrong places. Alex |
From: Diez B. R. <de...@we...> - 2007-01-22 16:12:02
|
> I was thinking specifically of the case of interacting with existing > java libraries. Java methods still demand correct typing when used > > from jython. You get errors when doing things like: > >>> d = java.util.Date("'100") > > And the same would be true for methods on any java classes one has > written. However misusing a java generic will give no such error. So > you may get a deferred type error in java code which a java > programmer would think has been prevented by specifying the generic. > > So the issue isn't the lack of type safety in jython, which I agree > is generally a gain, but the "odd" behavior of generic typing in java > code called from jython. Without thinking carefully about it one > might start looking for bugs in the wrong places. I see what you mean. However, the type errors are thrown by the JVM - which isn't the case for generics, where it doesn't do anything because of the type erasure. So I still find it odd to add typechecking in jython. Especially since the latent classcast-exceptions that can result from it are known for ages in java-development. Sure, generics can remedy that to a certain extent - but just compile-time. One has to deal with runtime errors in jython anyway, as they are the only thing (besides syntax errors) you get. And the added typecheck doesn't come for free, either. And things can get ugly pretty fast, as in java I often have generics as parameters of generics... So, when creating instances of java collections for e.g. Map<String, Map<Foo, Bar>> like this: my_map['key'] = {Foo() : Bar()} one has to ensure that the jython dict is properly type annotated... Something I'm not even sure it can be done. nope. still not convinced ;) Diez |
From: Alexander S. <ast...@ma...> - 2007-01-22 16:20:20
|
On Jan 22, 2007, at 11:11 AM, Diez B. Roggisch wrote: >> I was thinking specifically of the case of interacting with existing >> java libraries. Java methods still demand correct typing when used >> >> from jython. You get errors when doing things like: >>>>> d = java.util.Date("'100") >> >> And the same would be true for methods on any java classes one has >> written. However misusing a java generic will give no such error. So >> you may get a deferred type error in java code which a java >> programmer would think has been prevented by specifying the generic. >> >> So the issue isn't the lack of type safety in jython, which I agree >> is generally a gain, but the "odd" behavior of generic typing in java >> code called from jython. Without thinking carefully about it one >> might start looking for bugs in the wrong places. > > I see what you mean. However, the type errors are thrown by the JVM > - which > isn't the case for generics, where it doesn't do anything because > of the type > erasure. > > So I still find it odd to add typechecking in jython. Especially > since the > latent classcast-exceptions that can result from it are known for > ages in > java-development. Sure, generics can remedy that to a certain > extent - but > just compile-time. One has to deal with runtime errors in jython > anyway, as > they are the only thing (besides syntax errors) you get. > > And the added typecheck doesn't come for free, either. And things > can get ugly > pretty fast, as in java I often have generics as parameters of > generics... > So, when creating instances of java collections for e.g. > > Map<String, Map<Foo, Bar>> > > like this: > > my_map['key'] = {Foo() : Bar()} > > one has to ensure that the jython dict is properly type > annotated... Something > I'm not even sure it can be done. > > nope. still not convinced ;) > > Diez I'm not proposing adding type checking, just adding a note to the jython docs to remind folks that generics are completely invisible to jython and the JVM. Alex |
From: Diez B. R. <de...@we...> - 2007-01-22 16:30:02
|
> I'm not proposing adding type checking, just adding a note to the > jython docs to remind folks that generics are completely invisible to > jython and the JVM. Ah, I'm sorry - I confused your post and the one from "Leo User". diez |
From: Charlie G. <cha...@gm...> - 2007-01-23 05:40:13
|
On 1/19/07, Alexander Stoddard <ast...@ma...> wrote: > Generally should questions or comments about jython documentation be > sent to the users list, dev list or submitted to sourceforge as bugs > or feature requests? If it's something that's factually incorrect or missing in the documentation, submit a bug or even better a patch. If you're not sure if the docs are wrong or you are, I'd ask the users list first. > 1) Java Collections Integration. > I encountered jython when this was a hot topic on the lists and the > implementation was becoming complete. I think someone coming to > jython now might remain ignorant of it. > > Of course it is absent from the canonical "Jython essentials" and > "Jython for Java Developers" as it is part of Jython 2.2. When I > checked the web site I failed to find any mention of this feature. It > is really not written up on the current web site or am I missing it? I think it hasn't been written up because it wasn't completed. Hopefully someone will fact check me on this, but PyList now implements List but PySet doesn't implement Set. The integration is only partially complete. > 2) Jython (non)interaction with java generics > Jython completely ignores java generics. In my opinion this is > trivial but non-obvious. It is trivial once I remember that java > generics have no support in the JVM and are essentially compile time > magic (please correct me if i am wrong on this). It is non-obvious > because I don't normally think about such things when just using > code. I wouldn't have seen this behavior without deliberately setting > out to test it. > > Generics provide no type safety to jython scripting on java > collections. I suspect this could be the source of nasty bugs for the > unwary. Is this issue worthy of documenting? It does sound like a confusing bug, but I'm not sure how common or confusing it would be in the wild. Since Jython doesn't know about generics, it can't create objects with generics either. The only way one makes it into Jython is for Java code to create it and give it to Jython. If the Jython code is making meaningful additions to the object it gets, there has to be some shared expectation of the type being added. Otherwise the Java code on the outside couldn't do anything with the added objects since it's statically typed and all. Java 5 codified this with generics, but I never actually had a problem with an Object of an unexpected class showing up in my Lists in Java 1.4; generics really just seem like a documentation enhancer and typing reducer. If I did get a ClassCastException(actually, what happens when an unexpected class gets into a generic list?), I think I'd quickly assume that my dynamically typed code is knocking down my statically typed house of cards. Charlie |
From: Ben H. <ben...@fi...> - 2001-05-24 10:07:45
|
Joshua Fox wrote: >I have enjoyed reading Eckels' work in Thinking in Patterns about Jython's >capabilities in scripting Java apps. > >We have not found any other documentation about the Java-specific >capabilities of Jython: Calling Java classses from Python, interpreting >Python code in a Java app, compiling Python classes to *.class, etc. > >Is there any such documentation? > AFAIK, only the brief material on www.jython.org, and the archives of this mailing list which holds alot of knowledge. Ive often thought Jython needs a good document set, which could be produced by organizing and distilling the mailing lists & web site. Id like to try it myself but I dont think it will happen while I am working full time. Regards Ben |
From: Brian Z. <bri...@ya...> - 2001-05-25 02:33:49
|
Would suggest hosting a wiki site on jython.org. See http://jywiki.sourceforge.net/index.php?WikiWikiWeb for some pointers explaining the wiki idea. Good thing about wiki is everybody can easily participate and share, the pages are automatically indexed; downside is that it's not as systematically organized. I put out a few page starting at http://jywiki.sourceforge.net/index.php?JythonServlet focusing on jython servlet, but don't have a lot of time adding things to it. Feel free to add pages from here http://jywiki.sourceforge.net/index.php?AddingPages -Brian ----- Original Message ----- From: "Joshua Fox" <jo...@jo...> To: <jyt...@li...> Sent: Thursday, May 24, 2001 12:12 AM Subject: [Jython-users] Jython documentation > I have enjoyed reading Eckels' work in Thinking in Patterns about Jython's > capabilities in scripting Java apps. > > We have not found any other documentation about the Java-specific > capabilities of Jython: Calling Java classses from Python, interpreting > Python code in a Java app, compiling Python classes to *.class, etc. > > Is there any such documentation? > > Joshua > > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users > |
From: <bc...@wo...> - 2001-05-29 20:06:09
|
[Brian Zhou] >Would suggest hosting a wiki site on jython.org. We already have a moinmoin running on jython.org: http://www.jython.org/cgi-bin/moin.cgi I couldn't quite figure out how to built a site with a usefull structure, so it was never announced. regards, finn |