New Java language features

I just read an interview with Joshua Bloch in which he explains the new features for JDK 1.5. Joshua Bloch is the creator of the Java Collections Framework and author of hands down the best Java book I've ever read: Effective Java.

It's interesting how C# and Java seem to be playing leapfrog. C# started out with many of Java's features and some useful improvements of its own, and now Java is taking a number of C# features like attributes, enums, foreach and autoboxing, and adds some more like generics, static imports, and extendable enums.

Enums are something that are long overdue for Java, and their implementation in JDK 1.5 seems extremely powerful. On the other hand, extending enums will make it very easy to turn them into non-immutable objects, and could potentially cause multi-threading issues. Having a language construct for Enums will undoubtedly increase their adoption though, as most Java developers are either unaware of, or confused by, the Enum-class pattern that Joshua writes about it Effective Java. And anything is better than the current common practice of declaring a bunch of String or int constants.

Another item I'm excited about is support for generics. Though Bruce Eckel and Robert Martin have gotten me more interested in dynamic languages, I'm still not sure if I'm ready to switch away from statically typed languages. I agree with Carlos, who writes this about statically typed languages:

The pros I perceive is not what most would argue. It's actually based on my experience using the Visualage and Eclipse environments. The pros are that it's easier to navigate and search the code base. See the absence of type information makes it difficult to find the dependencies between code. Ask any smalltalker their experience of trying to reduce the size of the smalltalk image, it's an extremely painful process. Just because you're liberated today from type information, doesn't mean that it's not going to strike you back tomorrow.

I'm not sure if I can live without the code-insight features that VC#.NET and IntelliJ IDEA give me. Of course I won't know how a language like Python compares to a statically typed language until I actually try it. My fears may be ungrounded and, like Bruce, Robert and many others, I may end up loving it. Maybe my next pet-project should be SharpReader.py ;-)

While I'm still using statically typed languages though (Java by day, C# by night), it will be great to get that static typing on Collections and the like as well. Being forced to do type-casts every time you pull an item out of a Collection pretty much defeats the purpose of static typing...

By the way, .NET 2.0 will also add support for generics. From what I heard, they will leapfrog Java again on that one by allowing that type-information to be available at run-time as well. I seem to remember reading somewhere that Java's generics will be compile-time only. At run-time, a Collection<String> in Java will look like any other Collection. Someone please correct me if I'm wrong on this one.

TrackBack URL for this entry: http://www.hutteman.com/scgi-bin/mt/mt-tb.cgi/46
Comments

Python is a beautiful language, really. You could use it as a glue language or a mainstream language, that's up to you.

If you really want to develop a SharpReader (great work!) in Python, I think it's a great idea

Bye

ps. could you implement a search engine in SharpReader? And hopefully, release its source code on a license for non commercial purpose. It could be very helpful

Posted by Lawrence Oluyede at May 10, 2003 4:55 AM

Try it, you'll like it
Give it a try. If you like, you can use this as a starting point. If you'd like to collaborate, let me know.

Trackback from Sam Ruby at May 10, 2003 8:42 AM

On generics in Java... I've not followed what the standard is going to include. The Generic Java compiler, which has been around for years and I think is driving the standard, works as you describe (by necessity since it is a pre-compiler). That is, the generics metadata is compiled out of the result. Natch.

Posted by Patrick Logan at May 10, 2003 11:59 AM

as for code insight in Python, have you tried PyCrust ?

Posted by jm at May 11, 2003 5:10 AM

Java 1.5

Trackback from Andrew Stopford's Weblog at May 12, 2003 12:56 PM

It seems to me that compile-time generics would offer greater speed than jit-based generics. Deeper nesting, etc would be possible surely?

Pete

Posted by Pete at August 29, 2003 12:24 PM
This discussion has been closed. If you wish to contact me about this post, you can do so by email.