Tuesday, January 16, 2007

Primate Parts

Recently Chris Lamb and friends wrote about their experience adding a feature to javac, a pastime slightly more popular than it used to be now that javac's sources have been opened under the GPL. And he found something strange:

"Anyway, it turns out that the javacc [sic] code is messy. Really really messy. But it’s the source of great amusement though, not only from the scary amount of no-op casts, misleading indenting and undocumented functions, but the lexical token for the ‘@‘ symbol is ‘MONKEYS_AT‘. No, we have no idea either."
I responded with a conditional promise to tell him the story:
"Actually, the indentation is consistent if you have your tabs set at 8 spaces, where God intended them.
"There’s a story behind MONKEYS_AT, and if you know it this little piece of code is a funny inside joke. But if you want me to tell you, you’ll have to take back your assertion that javac’s code is messy and tell me that it’s a work of art."
Chris quickly buckled to the pressure, responding by email:
"Yes, it is true - when set it to 8 spaces, it seems to look a bit
better. What I mean to say is, it's now a work of art and any blemishes
are my fault. :)

"Anyway, yes, my friends and I would really like to know this story
behind the naming of the token though -- we found it at about 3AM whilst
hacking on the javac code and it put us off our stride somewhat. ^_^"
Here's the formerly untold story of MONKEYS_AT.

During the development of the JDK5 language features, the Sun team had regular meetings with a team from Denmark that was designing and implementing the variance feature (since renamed wildcards, which is a longer and more interesting story).  You can find the team member names in the paper describing the work. The Danish team was led by Mads Torgersen, and we all enjoyed a number of evenings chatting over beer. During one such session, I was discussing the work I was doing to implement annotations, and I mentioned that, unlike the "#" character that seems to have many names, there don't seem to be any alternative names for the "@" character. Mads told us that in Denmark, there are a number of names for this character, including the archaic "monkey's ass", which refers to the similarity in appearance of this character to the rear end of a monkey. We all thought this was hilarious, but perhaps a bit too risque to put in corporate-developed and publicly-visible sources. But it was just too funny to leave out. Thus I came up with the pun MONKEYS_AT. To this day that little inside joke in the sources reminds me of the team and the time we spent together.
http://www.gafter.com/~neal/p1055.jpg
Mads, by the way, is the one on the left. ;-)
There you have it: a disinterested observer, inclined to believe otherwise, comes to appreciate the beauty and humor of javac.

8 comments:

Anonymous said...

In German, it's similar, it can be Affenschwanz (monkey's tail), Affenohr (monkey's ear), Affenschaukel (monkey swing), Klammeraffe (clamping monkey (?))

Anonymous said...

By the way, I have also noticed a lot of "redundant" things in various places of JDK (not just javac). It looks like maintainers of Java do not use (do not like?) modern IDEs like IntelliJ IDEA / Eclipse / NetBeans, since it is virtually impossible to create such code with good modern IDE that immediately highlights any redundant cast, variable, or other similar things. Or maybe it is just a legacy from days where java code had to be written using EMACS or other similar editor package that does not do advanced code analysis and error highlighting on the fly.

I agree that its annoying when you open some java source in your favourite IDE and it is all "red/yellow" in many places instead of being "green". I think it is bad for SUN/Java image. I would like to see it at all cleaned up one day.

Anonymous said...

I wouldn't say "disinterested". Thanks for you the story :)

Anonymous said...

Thanks a lot, its great to have snippets of information about 'war stories' like this. I can imagine how amusing this must have been - since finding it in the source, it has become somewhat of an 'in-joke' amongst the group of us who were going through the javac sources. There's no end to the comedy in free software projects!

Alex Buckley said...

Will you also tell us why it's NullPointerException and not NullReferenceException?

Anonymous said...

BTW: Also swedish uses nature to name the @-sign. "snabel-a" =~ "A" with elephant trunk

Unknown said...

Roman: I thought the same when I was working at Sun on Swing's code. But the fact is that many people, at least in the Java Client Group, still use Emacs to perform their job. Now that the code is open, maybe somebody will have the nerve to run IntelliJ's static checker against the whole source tree and fix it. Note that it wasn't something easy to do internally because of the VCS which lacked IDE's support and requires to type a command before editing each file.

Unknown said...

The picture shows perfectly what the @-sign is called in Dutch: apestaartje (monkey's tail)