After two delayed attempts, I got Mac OS X 10.4 “Tiger” installed tonight. On the first attempt I was slowed by Apple’s lame back-up application, creatively called “Backup”. It seemed to re-scan everything whenever I added or removed a folder to back-up and then tried to solve a packing optimization problem to figure out how many discs I would need. After figuring out that I needed four DVDs and preparing the staging area for them, it turns out it couldn’t write to my DVD-R discs. There are so many DVD-xyz formats, I don’t know if it’s a legitimate failure or not. The next day, I realized I could just copy the critical files to an external hard drive as a back-up. D’oh.
Finally, I was ready to install, but the installer determined (after a long scan) that the installation DVD was bad. After several retries, troubleshooting using Apple’s support web site and a web search, I realized I my DVD belonged to the “bad batch” that had been sent out. I tried to call Apple for a replacement, but their phone support was closed for the night. Today I borrowed another install DVD from Michael, and it worked fine. I also called Apple about a replacement. After 20 minutes on hold and 30 minutes with a tech support person, I think I’m getting a replacement disc sent. At least that’s what he said before the connection was inadvertantly broken on my end. BTW, that was my first call to Apple tech support in 21 years of Mac ownership.
It occurs to me that Apple has really figured out how to make money. I already pay them $100/year for .Mac, which is of little benefit, and I still have to pay $130 for a minor OS upgrade. And my previous purchase of Quicktime 6 Pro gets wiped out with Quicktime 7–not sure if I’ll get the Pro upgrade again. To top it off, my main motivation for upgrading was to get Java 1.5, which Sun gives away for free for other platforms, so I’m paying Apple for Sun’s product.
I’ve almost finished the mostly-mechanical first pass of converting the C GNU Chess code to Java syntax. I haven’t tried to compile yet, but there’s about six files out of thirty-plus that IDEA (world’s greatest IDE) says contain syntax errors. Most of them are complicated
printf() calls that I put off, thinking I might just start using Java 5, which comes with a
printf() of its own. Also remaining are some threading issues like the use of the
The most common C features in C GNU Chess that needed converting to Java:
- primitive typedefs
- better readability and type-checking by using
BitBoard instead of
long. I started using Java classes for these typedefs, but
BitBoard operations much be fast, and I’ve have to deal with translating between the different semantics for assignment of primitives and objects.
- most were just constants; I made functions for most of the others, except a few like
CLEARBIT that seemed easier to inline.
- primitive reference parameters
- I used the return value if possible; otherwise I passed the params in an array.
- only a few of these we hard to convert; Java 5’s
printf will help
- something else that’s available in Java 5
- implicit bools
- I can’t count how many times I converted “
if (c)” to “
- Java doesn’t have
goto, but it does allow labels on
continue, which sometimes resulted in creating dummy loops just so I could use a labeled
break instead of a
A week or two ago I started porting GNU Chess from C to Java in my spare time. The main motivation is to refresh my Java skills after two years of C++ immersion. It’s amazing how quickly you can lose the subtleties of a tool when you don’t use it.
I’m sure the project will succeed at making we aware of the Java/C differences, but I have to admit it’s unlikely the port will produce a runnable chess-plaing program even if I stick with it. GNU Chess code is pretty hairy, especially since it sacrifices clarity for speed. But if it does by chance run, it will serve as an interesting Java benchmark and will give me something to tinker with.
So far I’ve been translating each file to a Java class composed of static members, and I’m probably about 15% done by volume. The biggest headache so far has been lexpgn, which is a PGN (Portable Game Notation) file parser that is generated from a grammar description, sort of like ANTLR but different. I’ve barely used ANTLR, but if I knew it well, the thing to do would be to translate the lexpgn grammar to ANTLR syntax directly. The main lex() function is 800 lines long with nested switch statements and gotos …