I like Java. Well, that is, I don’t dislike Java as much as I dislike most other langauges. I’d honestly prefer ML, but I’d be without the massive ball of mud that is the Java class libraries, the wonder that is Eclipse, and ANTLR. I need these. It’s a weakness.
(I know there is ML support for Eclipse, but it’s nowhere near Java support.)
All that said, I complain about Java a lot. Almost as much as I misuse italics. Anyway, here is my list of peeves in the current Java, in no particular order.
- Lack of reified generics.
I’ve written my fair share of C++. I’m used to the idea that when you instantiate a template you get a class. That’s not how Java works. The whole type erasure idea makes me crazy almost every day. I’d be okay if the type information was available at runtime, but of course it isn’t. I’m not the only one bothered by this.
- Lack of closures.
Did I mention that I like ML? Haskell? Lisp? I understand closures, and I want to use them. I don’t want a watered down version like with generics. I want real closures. Everyone doesn’t have to use them; they aren’t an idiom for idiots. I can make do without them, but why should I have to?
- Lack of macros.
It’s not politic to miss #define, but I do. There are lots of places where I would just love to use a compile-time macro. Recently we had a problem on a project of lots of strings getting created because of debugging statements (log4j) that were not enabled. Doesn’t matter; the string gets created. The compiler can’t optimize it out, since debugging can be enabled at runtime, and I get that. But do I really need that most of the time?
Also, I use certain design patterns that cry out for a macro. Want a factory? Most of it is boilerplate. Could I do this with the new annotation system? Probably, but… you can’t replace a class with an apt-generated class; you can only generate new classes.
- Lack of delegates.
This would probably not be an issue if we had closures. However delegates are easily understood, and very useful.
Okay, that’s my Java rant for today. Back to writing Java…
