Summary of JDK1.5 Language Changes
An anonymous reader writes "Over at java.sun.com, there's an informative article about the new features in JDK1.5. Some of the changes like generics are nice and should make some things easier. Some of the enhancements to me are purely sugar, like enumerators. When it comes down to it, once the code is compiled, it's the same. The thing I hope is, some of this new syntactic sugar doesn't result in more obfuscated code. Unlike some people, I feel using programming shorthand leads to increased maintenance. This is especially true when you have to debug a complex application."
check out eclipse -- a very sweet java IDE.
http://www.eclipse.org/
http://www.xemacs.org ;-)
what more do you need?
If you want a *real* IDE, I'd check out IntelliJ's Idea product. It's a few hundred $$$. Lots of folks like Netbeans and IBM's Eclipse as well (sorry, no url to eclipse, but I'm sure you can find it). The latter 2 are opensource.
May no camel spit in your yogurt soup.
Eclipse is "the awesome." It's feature-filled and relatively easy to use. Being free is a nice plus, too.
My roommate told me about it, and once I started using it I never looked back.
GeekNights!
Late Night Radio for Geeks!
AFAIK they will not be breaking existing code... If anything, they had to go out of their way (e.g. the ugly foreach statement) to ensure backward compatibility. In 1.4, the assert keyword might have caused problems, but now I don't think that's the case.
It's good to see enumerators formally supported, but you were not really _forced_ to use plain ints up to now. It is just some sort of an anti-pattern, which everybody seems to be using happily.
The type-safe enum pattern shows the correct way of handling enumerations. And you can the Jakarta Commons Lang library to make it a bit easier.
No bytecode changes are required. There have been "test" implementations out since Java 1.2. You can get the current 1.3 release atc es s/adding_generics/
http://developer.java.sun.com/developer/earlyAc
Generics
The new Java generics are really weak compared to C++ template support. This is probably partially due to difficult in compiler support and also complexity (templates are without a doubt the most complex feature of C++). I was disappointed though in Java generics mainly due to lack of any kind of specialization support and also about the strange paradigm used for Iterators (instead of an iterator being class defined with a consistant interface, it's an external class that just behaves that must wrap a behavior around the class).
Enhanced for loop
This is for_each() in C++. Now, with for_each, you have to use function objects which is arguable as to whether it's more readable. Fortunately, Boost has developed a boost::lambda class that allows for code to be used as the third parameter. This is _really_ neat.
Autoboxing/unboxing
I presume this means that primatives can't be used in generics.. That's kind of sad. This isn't a problem in C++.
Typesafe enums
This would be a nice linguistic pattern to have in C++. As it stands, the equivalent would be:
struct Coin { enum { penny, nickel, dime, quarter }; };
Static import
This can be achieved via using in C++. Of course, Java doesn't even really have a namespace paradigm so it's not really a fair comparision.
Metadata
This is.. well.. strange. I didn't see the syntax for doing something like this. If it is just keyword/code replacing, then an #include directive would work just as well.
int func(int a);
func((b += 3, b));
This is what he said about Java and the likes.
Also here.
Thanks a lot Sun for posting absolutely no information about the progress of this JSR. At least Doug Lea has posted a little information.
Hi,
;-)
Well, generics remind me of C++ templates
They're not quite the same; C++ templates are essentially glorified preprocessor macros with
some relatively small checking and a rather baroque
underlying functional language. Generics are more
concrete than that.
Not to mention that attached to variable name doesn't make code any more attractive to look at.
It would be really neat to have type inference there
It appears that Java's way to solve run time errors is to screw the bolts as tight a possible during compile time.
That's the idea, and that's also what I try to do when writing programs. Why should I have to write half a dozen test suites for some simple program property if the type checker can tell me whether it'll work right?
Remember: Compilers don't do type checking just to optimise, but also to catch programming errors. And Generics allow you to catch a much more interesting class of these.
-- Christoph
I am actually using the initial implementation of this on our current project and it is very nice. Actually have fine grained synchronization control makes it much easier to deal with a lot of thread synchronization problems. It has also helped us greatly reduce deadlock and detect deadlock because locks and waits can time out and report to you that they have timed out rather than just happily returning like Object.wait() does today. All in all this, along with generics, is probably the best new feature that is being added in jdk 1.5