Why I hate weak typing

Saturday, November 25th, 2006

I just wasted at least two hours hunting down a bug that turned out to be in this PHP code fragment:

      if ($reader->hasValue) {
        echo ": " + $reader->value;
      }

Do you see the bug?
(more…)

Compiling Javac

Thursday, November 16th, 2006

I downloaded the javac sources and gave them a whirl with ant on my PowerBook. No success. They wouldn’t compile. I’m not sure whether this is because I’m using a Mac or because I’m using Java 5, and they want Java 6. There seem to be several missing or incompatible classes.
(more…)

Interfaces vs. Classes

Tuesday, November 14th, 2006

Apparently XOM and JDOM aren’t the only projects to consider interfaces to be more trouble than they’re worth. I just noticed that JAXB 2.0 now uses singles classes for its generated files rather than separate interfaces and implementation classes like version 1.0 did. Given that these are generated code that should not be directly modified or extended by the programmer, this seems an obvious choice.

Estimated Complexity

Monday, November 13th, 2006

From the Apache Harmony bug tracker:

Unknown Novice Moderate Advanced Guru Needs James Gosling

Porting a Java Program to PHP

Sunday, November 12th, 2006

In Processing XML with Java, I used an example of plain text, XML-RPC, and SOAP clients that communicate with a Fibonacci number server I run here on www.elharo.com. Originally I wrote the servers in Java using the Java Servlet API. However, problems with Tomcat meant that the server went down every few months. When I moved this server from Linux to a Mac I didn’t even bother to reinstall Tomcat, and instead decided to port the servers to PHP 5. PHP has its own idiosyncrasies, but I use it for other things on this server (including this blog), and it didn’t seem worth keeping Tomcat running just for a few simple scripts.
(more…)

AWT on the Event Dispatch Thread?

Friday, November 10th, 2006

Last night I was teaching my Intro Java class about Swing windows, and specifically discussing the event dispatch thread. I dutifully warned everyone that all creation and update of Swing components had to happen on this thread, usually by calling SwingUtilties.invokeLater(). Then one of my students asked a question that stumped me:

Is the same true for AWT components?
(more…)