I’ve come across two blog posts that leave me perplexed: First there was “When Should You Jump? JSR 308. That’s When.”, and now I just found “What Hath Java Wrought”.
I don’t know anything about the authors and I have only read the two posts, but statements like “Every language has a complexity budget. Java blew through it with generics in Java 5.” and “First we got Generics. We all know how that went. While it’s passably better than what was originally there, it’s still not worth a damn.” make me furrow my brow. As for generics, I gladly trade in the more complicated syntax for better static typing. Annotation processors can do the same for non-null values, mutability, problems with equality and identity. They can bring linear types into the language, and make pretty much every kind of program analysis I can think of easier.
I don’t understand why there is such much animosity towards JSR 308. It is much less intrusive than generics were; unless you plan to use raw types, the updated collections libraries virtually forced you to adopt generics to a certain degree. That’s not the case at all with annotations. If you like you can easily ignore the entire idea.
Now, perhaps I’m just not a good programmer, and that’s why I prefer to ride with training wheels like generics, more precise type systems and better warnings, but this kind of humility has never hurt me so far. It does not make sense to be so frugal on the syntax side; the semantic benefits by far outweigh the costs.
I’m definitely not a fan of how generics were implemented using erasure, and I believe there are shortcomings both in the annotations provided with Java 1.5 and JSR-308 (see LAPT-javac, xajavac and blog posts), but I’m a firm believer that programmers have benefited a lot from generics, and that they will benefit in a similar way from annotations.
The beautiful thing about annotations is that dealing with them works on two different difficulty levels: Implementing annotations is not perfectly straight-forward, they use a syntax that is a bit different than the one used for regular Java classes, and that can be a bit confusing. Using annotations that have already been implemented, however, is easy; it’s an absolute piece of cake. This means that the annotations framework, especially with the annotation processors in JSR 308, can be used by more seasoned programmers to provide a lot of value even to programmers who do not know all of the details.
As a programming language researcher, I’m excited about annotations because they allow me to extend and modify the Java language in a relatively safe, convenient and compatible way. The resulting experimental languages may not be the most elegant ones, but they do the trick. Considering the two different levels of difficulty, and the possibility to completely ignore annotations, I have no idea why programmers would dislike annotations so much that they would abandon a language that can still be used exactly the same as without annotations.
Pingback: Indefinite Articles » Perplexion