Thursday, December 22, 2005

Dear Apple X11 Developer

Please, please, please fix these two bugs:
  1. When I command-tab switch to X11, the windows don't come to the top. Apple just introduced this bug in Tiger. I can work around it by command-tab switching a second time or by command-` switching, but this is a royal pain, especially considering I do it a couple hundred times a day.
  2. The alt key doesn't work. Creating a ~/.Xmodmap file with the following contents works randomly. Sometimes I have to call xmodmap ~/.Xmodmap manually, sometimes I don't. It's as if there's some sort of race condition.
    keycode 66 = Alt_L
    !keycode 63 = Meta_L
    
    clear Mod1
    !clear Mod2
    
    add Mod1 = Alt_L Alt_R
    !add Mod2 = Meta_L Meta_R
I use Apple's X11 server on a daily basis, and these two bugs make me miserable. I can't take much more. I'm actually contemplating switching to Linux for development. Update: Keith pointed out that the first bug is fixed. I just got a new computer and I installed X11 *after* the 10.4.3 update, and now Software Update says no more updates are available. Crap. Looks like I have to download the developer tools. Can you still download X11? Update #2: Manually downloading and re-installing the 10.4.3 update fixed the first problem. Now for the alt key...

Generics Puzzler

Does the following code compile?
  class Puzzler {

    <T> T cast(T t, Class<T> clazz) {
      return clazz.cast(t);
    }

    <T> T nop(T t) {
      return cast(t, t.getClass());
    }
  }
Why not? Update: To make things more interesting, in Mary's honor, I'll ship a free Google t-shirt (paid for out of my pocket) to the first person to post a comment with the correct answer (judged by me).

Thursday, December 15, 2005

PHP on a Java Web Server

Cameron: Caucho Resin, a J2EE server with a cult following from a small software company in the states (and Belgium too, now) has done it again:
Caucho Resin now supports PHP, and it's SIX TIMES FASTER than Apache mod_php.
What's more, PHP support is a stated goal of JSR 223, Scripting for the Java Platform. This is why a recent BusinessWeek article (I'm deliberately not linking to it) which compared PHP to Java really got under my skin. PHP should be implemented on the Java platform, not compared to the Java language. Why on Earth would a PHP pundit align with MS to gang up on Java? The logic escapes me.

Why do people compare Java to Cobol?

Can you create real time applications using Cobol? Can you write cell phone applications in Cobol? It makes a lot more sense to compare Java to C++. Notice how no one talks about C++'s cool factor?

The Elements of Typographic Style Applied to the Web

Does anyone else find the introduction to The Elements of Typographic Style Applied to the Web difficult to read? Small text size and serifs are a bad combination.

Tuesday, December 13, 2005

In San Diego

I'll be at the JCP EC meeting (which happens to be co-located with ApacheCon) for the next couple days. Hani's first in person EC meeting!

Null Placeholders in JDK 1.5

Null placeholders come in handy when you want to support null values but a Map implementation you depend on doesn't. An enum placeholder maintains object identity across object serialization for free:
  enum Null { VALUE }

  /**
   * Replaces null with placeholder.
   */
  Object replaceNull(Object value) {
    return value == null ? Null.VALUE : value;
  }

  /**
   * Resolves placeholder as null.
   */
  Object resolveNull(Object value) {
    return value == Null.VALUE ? null : value;
  }
Things can still get a little hairy when you mix null placeholders with generic types. Your placeholder can implement the same type as the value, or you can resort to casting hacks.