Skip to main content

Java 5.0 language changes were good ?

After listening to JavaPosse Episode 79, I realised that I wasn't the only one to think that the new Java 5.0 language features are scary and challenging.

The section was called "Were the Java 5 features a bad idea?" and the related links are :

Shai's Weblog : Java 5.0 languages features were a bad idea
JavaLobby: Java 5.0 language features
ServerSide: Autoboxing and NPE

My knowledge is still around Java 1.3.x level, and I'm learning slowly about the new features. Asserts look like a good Java 1.4/5.0 addition.
The Java 5.0 additions that look good to me are :
- for each syntax - handy and I wonder if faster due to the compiler knowing the bounds and not needing the array bounds checking ?
  • Enums - they look really useful
  • printf format - looks really good and powerful, better than the C one
  • StringBuilder
  • more robust collection framework
not sure about
  • boxing/unboxing - although at first glance looks okay
  • generics - looks horrible & as complicated as C++ templates :-)
  • Metadata - not sure what they are used for

Comments

I think Annotations are best new thing in Java 5. One of the worst is the static import. Generics are OK, but overrated. Enums are nice too, printf()/String.format() and Varargs are very useful.
Lee said…
I don't think I've seen the static import yet. I agree with the rest, they seem very useful.

Popular posts from this blog

Overcome Java JNI gdb errors on GNU/Linux

If you happen to try to debug any Java JNI programs using gdb on GNU/Linux you will soon come across error messages. For example : $ gdb --args java MyJavaProgramUsingJNI cannot find user-level thread for LWP nnn: generic error warning: Cannot initialize thread debugging library: versions of libpthread and libthread_db do not match The reason for this is that the java program mucks around with LD_LIBRARY_PATH and that prevents gdb from running correctly. To overcome this, you have to run your Java program and place a pause in the Java code, such as reading a key, and then in another shell, run gdb to attach to the running Java process. You can then set your breakpoint on your JNI code and debug it. Here is an example : Compile your Java program: $ javac JNITest.java Generate the JNI header file: $ javah -jni JNITest.java Create and compile your C code library: $ cat jnilib.c #include "JNITest.h" JNIEXPORT jint JNICALL Java_JNITest_addValues( JNIEnv

App Sightings

jDiskReport is an excellent disk utility. Visual very well designed and works very well also. jGoodies jEdit is an excellent Java text editor. jEdit jEdit - features SQuirreL SQL Client - a universal SQL client SQuirreL SQL client SQuirreL SQL client - screenshots FreeMind - free mind mapping in Java FreeMind FreeMind - screenshots

JavaPosse update

I keep listening to this wonderful podcast : Java News, Interviews and more about the Java programming language. I'm catching up with past episodes and listening to the past Java events that I missed the first time around. I'm up to episode #057 so far, it's wonderful. Very interesting and enlightening. JavaPosse About JavaPosse