Sunday, November 23, 2008

Success

I have been working with a friend at school on creating a connect four game for our networking class. It seemed at first like it would be easy, but of course there is always some catch. In this case, the problem was that after a player made a move the board would not update until the other player finished making his move. This went in lockstep with the result being that the display was always a move behind. I finally solved the problem tonight when I figured out that all I needed to do was create an inner class that implemented the Runnable interface (did I mention we were using Java) and do all of the input output in a separate thread. By doing this the program never hangs up waiting for input from a blocked socket. Which brings me to this point, threads are awesome. I go back and forth a lot on language preference between C++ and Java, but this is one area that is a definite win for Java. Of course you can program with threads in C++ if you use facilities provided by the operating system, but these are usually a little messy, not to mention different on every system. My other favorite language, Python, also has built-in support for threading but the implementation feels a little hackish compared to Java's. There are plenty of times when I'm digging through some ridiculously complicated, though supposedly "elegant", set of Java class libraries and I swear it is more trouble that it could possibly be worth, but at least for tonight, I really like Java.

Friday, November 14, 2008

It Lives

I've decided to try updating my blog again. I'm thinking I might turn this into a tech blog. Maybe I'll write more if I'm writing about something I'm really interested in rather than trying to write with no topic at all in mind. Also, I really like the new feature that allows you to follow other blogs.