Preston
Sr. Member   Posts: 346 Medals: 2
|
 |
«
Reply #30 on:
2003-08-14 06:49:23 » |
|
You give people an utterly misusuable tool, and they'll misuse it utterly! You know they do!
Yes, my recent C++ years in mid sized dev teams proved that. This is why I think Java is such a great and (more) "clean" language. I really like it. Very good work @ Gosling and all other contributors at SUN !
|
Memento mori.
|
|
|
cfmdobbie
JGO Wizard     Posts: 1257
Who, me?
|
 |
«
Reply #31 on:
2003-08-14 07:42:01 » |
|
My word, that is some good reading! I didn't realise the full extent of the changes being included in Java 1.5. Generics, Static Import and Enumerations get all the attention, but there's also Autoboxing, Foreach, Metadata, Concurrency Utilities API, StringBuilder (unsynchronised StringBuffer), Varargs, C-style printf-type library, and use of generics in things like Comparable<T>. Wow!
|
Hellomynameis Charlie Dobbie.
|
|
|
GergisKhan
Full Member   Posts: 221
"C8 H10 N4 O2"
|
 |
«
Reply #32 on:
2003-08-14 08:49:47 » |
|
My personal favorite that I can't wait for (though it isn't as important construct-wise) is the foreach statement.
That thing just rocks.
But I guess the most important significant change is either autoboxing or generics; I have not yet decided which is most important to me. Probably both.
|
gK
"Go. Teach them not to mess with us." -- Cao Cao, Dynasty Warriors 3
|
|
|
Games published by our own members! Go get 'em!
|
|
Athomas Goldberg
Sr. Member   Posts: 284
Grrrrrr...
|
 |
«
Reply #33 on:
2003-08-14 08:52:22 » |
|
I know. Every time they release another version spec, I start thinking about all the places I could use the new features in whatever project I'm working on. It gets really depressing. 
|
Athomas Goldberg Project Lead / Wildcard Game Technologies Group Sun Microsystems, Inc.
|
|
|
tortoise
Full Member   Posts: 230
<3 Shmups
|
 |
«
Reply #34 on:
2003-08-14 10:16:04 » |
|
I think generics are going to rock. A compile time error as opposed to a ClassCastException? Especially if eclipse will be able to pick up the error on the fly? Oh hell yeah 
|
|
|
|
|
swpalmer
JGO Kernel      Posts: 3438 Medals: 4
Where's the Kaboom?
|
 |
«
Reply #35 on:
2003-08-14 10:47:41 » |
|
When 1.5 is available it's going to take me a while to get used to not doing things the old way 
|
|
|
|
GergisKhan
Full Member   Posts: 221
"C8 H10 N4 O2"
|
 |
«
Reply #36 on:
2003-08-15 00:06:40 » |
|
When 1.5 is available it's going to take me a while to get used to not doing things the old way This reminds me of your other comment about not using switch and using polymorphism instead. I tell you, I think generics are going to rock, but I think they're going to be a PITA to remember to USE them.
|
gK
"Go. Teach them not to mess with us." -- Cao Cao, Dynasty Warriors 3
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #37 on:
2003-08-15 00:27:32 » |
|
Any news on what's going to happen to container classes when generics turn up? We going to get a bunch on new version in util.generic which support generics?
Kev
|
|
|
|
Preston
Sr. Member   Posts: 346 Medals: 2
|
 |
«
Reply #38 on:
2003-08-15 02:25:05 » |
|
Any news on what's going to happen to container classes when generics turn up? We going to get a bunch on new version in util.generic which support generics?
Kev The affected classes (=many :-) will be these: http://jcp.org/aboutJava/communityprocess/review/jsr014/
|
Memento mori.
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #39 on:
2003-08-15 02:42:25 » |
|
Had a quick read, does this mean all old code that uses collections will be broken if compiled against 1.5?
Kev
|
|
|
|
Games published by our own members! Go get 'em!
|
|
princec
« League of Dukes » JGO Kernel      Posts: 8073 Medals: 91
Eh? Who? What? ... Me?
|
 |
«
Reply #40 on:
2003-08-15 03:31:37 » |
|
No, no code will need recompiling. The generics code has a fallback where all classes are defined as using T<Object>, which is exactly how the collections classes work at the moment - as collections of Ob jects.
Cas :_
|
|
|
|
Athomas Goldberg
Sr. Member   Posts: 284
Grrrrrr...
|
 |
«
Reply #41 on:
2003-08-15 08:52:48 » |
|
My personal favorite that I can't wait for (though it isn't as important construct-wise) is the foreach statement.
That thing just rocks.
But I guess the most important significant change is either autoboxing or generics; I have not yet decided which is most important to me. Probably both. Actually, foreach combined with autoboxing and generics, really rocks. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public class MyClass {
public void myMethod(String[] args) { Map m = new TreeMap();
for (int i = 0; i < args.length; i++) { Integer freq = (Integer) m.get(args[i]); Integer incrInteger; if(freq==null) { incrInteger = new Integer(1); } else { int oldInt = freq.intValue(); int newInt = oldInt + 1; incrInteger = new Integer(newInt); } m.put(args[i], incrInteger ); } } } |
becomes: 1 2 3 4 5 6 7
| public class MyClass { public void myMethod(String[] args) { Map<String, Integer> m = new TreeMap<String, Integer>(); for (String word : args) m.put(word, m.get(word) + 1); } } |
*This example was adapted from an interview with Josh Bloch on the new features in 1.5 Actually, I'm looking forward to the java.util.concurrency.* classes (ThreadPool, PriorityQueue, etc). As someone who's been doing multithreaded programming for a long time, and learning the hard way how to get it right, it's understandable why people frequently avoid multi-threading at all costs. I think these classes will be as significant as the Collections classes were to how Java is used.
|
Athomas Goldberg Project Lead / Wildcard Game Technologies Group Sun Microsystems, Inc.
|
|
|
tortoise
Full Member   Posts: 230
<3 Shmups
|
 |
«
Reply #42 on:
2003-08-15 09:25:17 » |
|
So now Java's really, really becoming "C++ done right"  Things like that little code snippet you just put there should look really attractive to a C++ programmer who hasn't done any Java yet.
|
|
|
|
|
Abuse
JGO Kernel      Posts: 1866 Medals: 5
falling into the abyss of reality
|
 |
«
Reply #43 on:
2003-08-15 11:19:18 » |
|
If I was learning Java, and came across..... 1 2 3 4 5 6 7
| public class MyClass { public void myMethod(String[] args) { Map<String, Integer> m = new TreeMap<String, Integer>(); for (String word : args) m.put(word, m.get(word) + 1); } } |
... I would be totally lost. Coding shortcuts are good... when the meaning of the code isn't lost.
|
|
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #44 on:
2003-08-15 11:32:32 » |
|
I agree, it is going to be nice to have the ability to use these tools when its appropriate, but the readability isn't that great. Isn't it also going to lead to ppl who are moving from other languages to java using primitives for keys everywhere, instead of considering if it might be more elegant to use an object? Kev PS. Thanks for pointing out the default <Object> impl, mind at rest again 
|
|
|
|
tortoise
Full Member   Posts: 230
<3 Shmups
|
 |
«
Reply #45 on:
2003-08-15 11:56:33 » |
|
The syntax is foreign at first but I think it improves readability quite nicely. The intention is made more clear while the implementation (which is rarely necessary to know about) is nicely hidden.
When the implementation is necessary, it becomes visible, but it also becomes a part of the intention when that happens too. Sounds good to me.
|
|
|
|
|
cfmdobbie
JGO Wizard     Posts: 1257
Who, me?
|
 |
«
Reply #46 on:
2003-08-15 13:37:45 » |
|
Yeah, it'll be a little weird at first because it doesn't look like Java1.4 - but once we start playing with it I'm sure it'll be fine! That example rather compresses several themes into one place, anyway - most code won't be anything like as alien as that!
|
Hellomynameis Charlie Dobbie.
|
|
|
|