The Cafes » Why Java Doesn’t Need Properties (It already has them) (original) (raw)
There’s an awful lot of sound and fury right now about adding syntax support for properties to Java 7. The more I think about this the more I think the whole idea is wrong for several reasons:
1. It doesn’t let you do anything you can’t do now. It’s a minor improvement at best.
2. It makes source code that uses it incompatible with previous compilers for no particular reason.
3. It invalidates a lot of books and tutorials, and existing knowledge of how Java works.
4. At least some of the proposals add keywords to the language, thus breaking existing programs.
5. At least one of the proposals adds an operator to the language (->
), thus making Java more complex to read, not less.
These aren’t insurmountable hurdles by any means, and objections 4 and 5 can be eliminated completely with a better proposal; but if we’re going to surmount obstacles 1-3, there needs to be a clear benefit. The proposal needs to make code a lot cleaner or let us do something we can’t already do. So far that doesn’t seem to be true.
What’s all too often missing from these discussions is a realization that even the best feature comes with a cost. Everything you add to a language bloats it a little more. It makes the language that much harder to learn, that much harder to document, that much harder to read. Not a lot, mind you, but somewhat; and over time all these little changes add up, especially when you aren’t allowed to take anything out to counterbalance the added feature weight. This is especially true of features that are added years later rather than designed into the language from the start. The debacle that is generics (Can you say “type erasure”?) should have taught us that if nothing else.
Another example: closures. These make sense considered in isolation, but they’re not isolated. Closures are cleaner than anonymous inner classes, but if we can’t remove anonymous inner classes, we shouldn’t add closures too.
Java in a Nutshell has already split once and is still starting to look like a telephone book. How much bigger can we make the language before it collapses under its own weight? At some point, someone needs to put their foot down and say their will be no new features without clear and compelling benefits. Java must not become the Kitchen Sink Language for everyone’s pet project. We need to let Java be Java, and let other languages implement features like properties and closures if developers want them. They can all still be compiled to the Java VM if desirable. However one language cannot be all things to all people, and Java shouldn’t try.
This entry was posted on Thursday, January 25th, 2007 at 7:52 am and is filed under Blogroll. You can follow any responses to this entry through the Atom feed. Both comments and pings are currently closed.