<< October 2009 | Home | December 2009 >>

Wednesday Java Quiz: What Does It Print?

Q: Will the following Java program compile? Run without exceptions? If so, what does it print?

import javax.swing.*;

public class Main {
  public static void main(String[] args) {
    JButton button = new JButton("OK");
    System.out.println(button.isVisible());
  }
}
Tags :

Relentless Reduction Of Complexity

[Note] I started this blog 7 days ago but didn't finish it on time. I'm finishing it up now. The current date will be November 13, 2009 starting from the next sentence.

"Relentless reduction of complexity" is a phrase I picked up from Alex Payne's keynote at the Strange Loop 2009 conference 21 days ago. Of all the things that was said during conference, this phrase resonated with me the most.

Yesterday, at the St. Louis JUG, Brian Gilstrap gave a very well thought-out, compelling presentation on RESTful Web Services using JAX-RS and Jersey. While the overall subject is interesting, it is a "little" comment that Brian made that struck me: "I created a mini-framework just so that I don't have to repeat the same line of code in every class."

Then, as if to reinforce this Minimalist theme, Richard Bair of the JavaFX team posted Looping in FX today in his and Jasper Potts's FX Experience blog in which he outlined the evolution of loop construct in the JavaFX SDK, going from a Java-ish

public function hideAll():Void {
    for ( i in [0..sizeof this.childrenPopups] ) {
        if (this.childrenPopups[i].visible) {
            this.childrenPopups[i].hideAll();
        }
    }
    hide();
}

to a JavaFX-ish

public function hideAll():Void {
    for (p in childrenPopups where p.visible) {
        p.hideAll();
    }
    hide();
}

In both Brian's and Richard's instance they have achieved "code that works" first, but their professionalism and pursuit of excellence carried them further, to make the code simpler and more elegant.

I admire their approach to writing great code profoundly. And I think producing not merely passably working code but elegantly organized crystal clear code is a trait that serious programmers should acquire, perfect, and make a habit.

Closures In Java 7: It's On Again

Alex Miller: Apparently Mark Reinhold announced that closures would be added to JDK 7 at Devoxx today:

I am, well, surprised. Having commented on closures in Java somewhat verbosely in the past, I don't have any words left in me about this topic, except "whatever!"

I'll believe it when I see it. Remember, they promised XML literals for Java 7, and I'm still bitter that they dropped it. :(

Coincidentally, Neal Gafter, of Microsoft dotNet platform languages group, posted a simplified proposal for Closures for Java (v0.6a).

For those who don't follow my blog, my position has always been:

  • Not adding closure to Java will kill Java
  • The death (or the absence of evolution) of Java the language will render the JVM the platform anemic
  • An anemic JVM platform will suffocate parasitic JVM languages like Scala and Groovy while at the same time decrease its attractiveness as an alternative implementation platform for other scripting languages (JRuby, Jython, etc.)

So, it's a Good Thing.

[Update] I consulted the I Ching, the ancient Chinese Oracle, on the meaning of this matter, and received the following gua:

I Ching (ca. 900 B.C.): 否(坤下乾上)
《否》:否之匪人,不利君子贞,大往小来。
初六,拔茅茹以其汇。贞吉,亨。
六二,包承,小人吉,大人否。亨。
六三,包羞。
九四,有命,无咎,畴离祉。
九五,休否,大人吉。其亡其亡,系于苞桑。
上九,倾否,先否后喜。
Tags :

Hmmm...

... I wonder where I can find a text/html decoder?

text/html decoder?

(Firefox showed this dialog box after a typical "A plugin for some media content on this page is not installed, would you like to search for a plugin?" dialog box.)

Tags :