NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed. (sponsored)
In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.
Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.
Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Replies:
46 -
Pages:
4
[
1234
| Next
]
Threads:
[
Previous
|
Next
]
Is there a consensus on fixing Generics for Java 7?
Seeing as closures and properties are still quite disputed, I was wondering whether there was any consensus on introducing Reified Generics for Java7 instead. There is a proposal on how to implement this in a backwards-compatible way here: http://tech.puredanger.com/java7#reified
Re: Is there a consensus on fixing Generics for Java 7?
A problem with reification of generics is that if the same syntax and the same classes were used, but reified, then some currently working (but strange) code could start to fail.
For example:
List<Object> objects=(List<Object>)listOfStrings; is currently valid, but gives a compile warning. With reification, that would fail, so any solution isn't necessarily going to be straightforward.
One option is a different syntax for reification, e.g.:
List<&String> strings=new ArrayList<&String>();
Another is for reification to happen but not to actually perform runtime checks unless requested. In other words, a List<String> would be castable to a List<Object>, but would not
actually be
a List<Object>. Such casts could enable runtime checking somehow, in the same way that Double[] is a subtype of Number[], (which violates the Liskov Substitution Principle, but nevermind) but that a Double[] cannot accept an Integer, regardless of its compile-time type.
A third option is to have reified generic classes be separate from unreified generic classes. I don't think this would be that useful, from a code repetition view.
Re: Is there a consensus on fixing Generics for Java 7?
> > Is there a consensus on fixing Generics for Java
> 7?
>
> no
but there is. There's a consensus among many people that it's a bad idea
There's also no doubt a consensus among a small number of people that it's a good idea, though no doubt there's no consensus among those people as to what should be done.
Re: Is there a consensus on fixing Generics for Java 7?
What do you mean it is a bad idea? Is it a bad idea to be able to know that a List<String> is a list of Strings!? Or to be able to have two methods doSomething(List<String> aList) and doSomething(List<Integer> aList) defined inside a class at the same time!? Hell no!
Re: Is there a consensus on fixing Generics for Java 7?
Wouldn't it be a better solution to have a new class version ?
We had one in Java 5 to have the generics and enums, we could have one for Java 7 to use reified generic with the same syntax.
If the code is "strange", then you would compile it with Java 6 compatilibity.
Java's messed up generics are going to hurt the platform, but it's not fixable: either, they introduce subtle errors, or they make the language even messier than it is. The best thing Sun can do at this point is to stop f*cking with the language.
Now that Java is open source you should be able to provide a compiler/vm at least demonstrating the reified generic.
Yes you will not be able to call it Java, but if it is better/faster, Sun is much likely to incorporate it into the main Java branch.
This is why we are so happy that Java is open source Are we?
Jean-Marie Dautelle - Marlboro, MA
-- Javolution: Everything should be made as simple as possible...
-- JScience: But not simpler!
Re: Is there a consensus on fixing Generics for Java 7?
I read the blog.
While it has backward compatibility, it essentially bifurcates the entire Java code space between reified and non-reified collection classes, etc. Essentially you'd have to have java.util2, etc.
Personally, I'd stick with generics as they are over that mess.
It strikes me that there are more reasonable compromises. Construction of generic objects could capture type information when compiled with new -target/-source flags in some future JVM. One could query this information at runtime -- with the possibility that the result could be null, of course. One could write such things as "new T[n]" without a compiler warning if the compiler could determine that runtime information should be available (barring a past unsafe caste, of course). One could still write such things *with* a warning and a possible runtime error in cases where the compiler could not make this determination.
Type safety is like anything else and language purity are like anything else -- goals to be weighed against other requirements. Nothing goal has absolute priority -- and for me having hundreds of classes using java.util and hundred using java.util2 and not being able to interchange data between the two except by copying collections or some such is a fate *far* worse than type erasure (which works fabulously in my experience apart from a few "new T[n]"-like cases.
Re: Is there a consensus on fixing Generics for Java 7?
Fair enough, I don't care how Generics Reification is done under the hood so long as it gets done. There is an already existing BugParade issue calling for Sun to add Reified Generics to Java and I am hoping you and others will vote for it. Once sun commits to adding this feature you and others will propose your approach and Sun will hopefully pick the best one.
I personally believe that Generics without Reification is worse than no Generics at all. I didn't used to feel this way. Using the Generic Collections API is quite nice but once you try writing your own Generic classes you hit a brick wall fairly quickly. It is a total mess and leads to very unreadable code and in other cases unwritable code.
Is there a consensus on fixing Generics for Java 7?
URL: PureDanger
At 7:08 AM on May 24, 2007, cowwoc wrote:
Fresh Jobs for Developers Post a job opportunity
Seeing as closures and properties are still quite disputed, I was wondering whether there was any consensus on introducing Reified Generics for Java7 instead. There is a proposal on how to implement this in a backwards-compatible way here: http://tech.puredanger.com/java7#reified
Please, let me know what you think.
46 replies so far (
Post your own)
Re: Is there a consensus on fixing Generics for Java 7?
A problem with reification of generics is that if the same syntax and the same classes were used, but reified, then some currently working (but strange) code could start to fail.For example:
List<Object> objects=(List<Object>)listOfStrings; is currently valid, but gives a compile warning. With reification, that would fail, so any solution isn't necessarily going to be straightforward.
One option is a different syntax for reification, e.g.:
List<&String> strings=new ArrayList<&String>();
Another is for reification to happen but not to actually perform runtime checks unless requested. In other words, a List<String> would be castable to a List<Object>, but would not actually be a List<Object>. Such casts could enable runtime checking somehow, in the same way that Double[] is a subtype of Number[], (which violates the Liskov Substitution Principle, but nevermind) but that a Double[] cannot accept an Integer, regardless of its compile-time type.
A third option is to have reified generic classes be separate from unreified generic classes. I don't think this would be that useful, from a code repetition view.
Re: Is there a consensus on fixing Generics for Java 7?
> Is there a consensus on fixing Generics for Java 7?no
Re: Is there a consensus on fixing Generics for Java 7?
there is a problem with the Reified Generics itself. it will complicate the JVM design.Re: Is there a consensus on fixing Generics for Java 7?
> > Is there a consensus on fixing Generics for Java> 7?
>
> no
but there is. There's a consensus among many people that it's a bad idea
There's also no doubt a consensus among a small number of people that it's a good idea, though no doubt there's no consensus among those people as to what should be done.
Re: Is there a consensus on fixing Generics for Java 7?
What do you mean it is a bad idea? Is it a bad idea to be able to know that a List<String> is a list of Strings!? Or to be able to have two methods doSomething(List<String> aList) and doSomething(List<Integer> aList) defined inside a class at the same time!? Hell no!Re: Is there a consensus on fixing Generics for Java 7?
Wouldn't it be a better solution to have a new class version ?We had one in Java 5 to have the generics and enums, we could have one for Java 7 to use reified generic with the same syntax.
If the code is "strange", then you would compile it with Java 6 compatilibity.
-Christopher
it's unfixable
Java's messed up generics are going to hurt the platform, but it's not fixable: either, they introduce subtle errors, or they make the language even messier than it is. The best thing Sun can do at this point is to stop f*cking with the language.Re: it's unfixable
Yes, stop messing up the Java language!Start a new one for this cool-must-have stuff of yours like closures or reified generics, leave my perfectly sane Java alone
No problem, do it yourself!
Now that Java is open source you should be able to provide a compiler/vm at least demonstrating the reified generic.Yes you will not be able to call it Java, but if it is better/faster, Sun is much likely to incorporate it into the main Java branch.
This is why we are so happy that Java is open source
Are we?
-- Javolution: Everything should be made as simple as possible... -- JScience: But not simpler!
Re: Is there a consensus on fixing Generics for Java 7?
>> Is there a consensus on fixing Generics for Java> but there is. There's a consensus among many people that it's a bad idea
Why would it be a bad idea to fix the generics?
Maybe the consensus you are referring to is only among yourself
Re: Is there a consensus on fixing Generics for Java 7?
Guys, I don't think you actually read the link I mentioned.Neil suggests a way to introduce Reified Generics with full backwards compatibility: http://gafter.blogspot.com/2006/11/reified-generics-for-java.html
Are you honestly telling me there is no consensus for this? If not can you please explain why you're against it?
Thank you,
Gili
Re: Is there a consensus on fixing Generics for Java 7?
I read the blog.While it has backward compatibility, it essentially bifurcates the entire Java code space between reified and non-reified collection classes, etc. Essentially you'd have to have java.util2, etc.
Personally, I'd stick with generics as they are over that mess.
It strikes me that there are more reasonable compromises. Construction of generic objects could capture type information when compiled with new -target/-source flags in some future JVM. One could query this information at runtime -- with the possibility that the result could be null, of course. One could write such things as "new T[n]" without a compiler warning if the compiler could determine that runtime information should be available (barring a past unsafe caste, of course). One could still write such things *with* a warning and a possible runtime error in cases where the compiler could not make this determination.
Type safety is like anything else and language purity are like anything else -- goals to be weighed against other requirements. Nothing goal has absolute priority -- and for me having hundreds of classes using java.util and hundred using java.util2 and not being able to interchange data between the two except by copying collections or some such is a fate *far* worse than type erasure (which works fabulously in my experience apart from a few "new T[n]"-like cases.
Re: Is there a consensus on fixing Generics for Java 7?
Fair enough, I don't care how Generics Reification is done under the hood so long as it gets done. There is an already existing BugParade issue calling for Sun to add Reified Generics to Java and I am hoping you and others will vote for it. Once sun commits to adding this feature you and others will propose your approach and Sun will hopefully pick the best one.I personally believe that Generics without Reification is worse than no Generics at all. I didn't used to feel this way. Using the Generic Collections API is quite nice but once you try writing your own Generic classes you hit a brick wall fairly quickly. It is a total mess and leads to very unreadable code and in other cases unwritable code.
Please vote in favor of http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5098163 to get Generics fixed as soon as possible.
Re: No problem, do it yourself!
People did that long ago; Sun didn't care.