Java arrays and primitive types should (perhaps) be deprecated
I have been brushing up on my Java skills this year. For 2 years I did mostly Ruby and Common Lisp development. I think that Lisp is a great research language but not so great for deployments and long term maintainability. Ruby is a great prototyping language and for small web portal projects Rails is my favorite tool. However, I keep coming back to Java because of the tools/libraries and the robust deployment software options.
So, I have carefully read through both Effective Java (2nd edition) and Java Generics recently to brush up on my Java skills. As a result, I completely refactored one of my medium size projects to use generics and collection classes exclusively - no arrays. Since arrays must contain reifiable types they play poorly with generics.
There are some obvious cases where not using primitive types leads to excessive object creation and boxing/unboxing. That said, I expect Java compilers, Hotspot, and the JVM in general to keep getting better and this may be a non-issue in the future.
So, I have carefully read through both Effective Java (2nd edition) and Java Generics recently to brush up on my Java skills. As a result, I completely refactored one of my medium size projects to use generics and collection classes exclusively - no arrays. Since arrays must contain reifiable types they play poorly with generics.
There are some obvious cases where not using primitive types leads to excessive object creation and boxing/unboxing. That said, I expect Java compilers, Hotspot, and the JVM in general to keep getting better and this may be a non-issue in the future.
Groovy has become my jvm language. Graceful integration with Java and most of the benefits of dynamic languages. Tools still leave a lot to be desired. Much better than plain Java though. I'm not sure Java should change at all now - freeze it and allow the innovation to take place in the vm, and new languages for the vm.
ReplyDeleteHello Patrick,
ReplyDeleteGroovy certainly looks good, but runtime performance is poor. I have invested a huge amount of time in the last 3 1/2 years getting into Ruby, and for some things I like JRuby, so I think that I will stick with Ruby as my "slow" language. Really, would be very happy if I never had to use anything but Ruby but in the real world sometimes runtime performance maters.
Scala looks good because of language features, good runtime performance, and an interactive development shell. That said, I have decided to wait to see how popular the language (and Lift) get.
In general, I agree with your enthusiasm for new JVM languages.
What do you think about the Java generics?
ReplyDeleteI've used them on each (usually small) Java project I've worked on in the past couple years. While coercing types out of a standard Vector or ArrayList has always been ugly, the generics syntax strikes me each time as being really verbose & repetitive.
I've been using NetBeans for Java work for some time, ever since I needed to build a desktop app and liked their interface builder. Refactoring support there helps some, but it still feels like the entire process gets in the way of coding.
But you've worked on more substantial programs in Java than I have -- probably ever, certainly lately. =) What do you think?
Hello Michael,
ReplyDeleteI like and use Java generics, but for me it is mostly an "all or nothing" exercise: I tend to not mix plain arrays with generics in the same code base.
If you find the syntax verbose, you can try Scala (very efficient), JRuby (not so efficient), or Groovy (also not so efficient).