Related link: http://www.onjava.com/pub/a/onjava/2003/09/24/readable_java.html

Stephen Jungels wrote an interesting article on syntax problems in JDK 1.5. In it, he proposed an interesting variant on Generic syntax using parentheses instead of angle brackets. That is, his syntax replaces code like expurgate(Collection<String> c) with code like expurgate((String) Collection c) and the angle brackets after Collection became a cast before Collection.


He listed a lot of reasons why he prefers his syntax. Most of his reasons seemed unconvincing to me, to be honest. And the fact that Java generics look like C++ templates counts as a big win for me (it starts my intuition going in the right direction).


But recently I’ve discovered, there’s a huge argument against angle brackets syntax:

Generics Code isn’t HTML or XML


Sounds stupid, right? What I’m complaining about is simply that cutting and pasting angle-brackets code into a web page, or into many instant messaging clients (I’m using AIM 5.3.2392 and I can’t send generics code in a chat session), or into a wide variety of e-mail readers, is broken. A lot of devices, when confronted with <T extends Rentable> render it as blank.


So I don’t like Stephen’s syntax. But I really wish I didn’t have to use amperandltsemicolon all over the place when I want to IM about a piece of code either.

Do you ever IM or e-mail code? How do you get around problems with the clients?