Tuesday, October 03, 2006

The Grand Folly

I've actually made significant progress on my port of MediaWiki to Java. The Article class is now free of syntactic errors. So is CacheManager. I'm working on Database now, and swearing constantly at PHP's crappy database support. PHP remains one of my least favorite languages of all time.

MediaWiki has a gazillion global variables. The container class (MW) I created to hold all of them (as statics) keeps getting larger and larger. Fortunately most of them will get refactored out later, into either system configuration classes or into the Request wrapper class (depending on whether they're system-wide or merely request-wide variables).

The nice thing is that PHP's syntax is "close enough" to Java's that I can simply paste the .php file into a .java file and usually get it "close enough" for Eclipse to identify methods without too much additional editing. (Getting them syntactically valid is another story.) It took me about two evenings and two weekend days to get Article into a state where (a) it was internally syntactically valid and (b) all of its external references existed in a state that would allow them to resolve. So that means I've also cleaned up quite a few other things, and also created several new auxiliary classes to deal with various PHPism, especially PHP arrays (plain and associative). There's still several spots that are likely semantically broken because of egregious use of mixed types (that is, returning results of different, nonhomologous types depending on the situation, which is peachy in a late-binding loosely-typed language like PHP, and total anathema in Java). So far I've had two instances of reflection in Database that I sincerely hope I will be able to get rid of.

Once I get all the code through this first-pass translation process, then I will go through and try to harmonize what's there and start refactoring. A large part of this process is simply so that I can familiarize myself with the code, so even if I never bring this completely to fruition, I'll still have gained something out of it.

Now I just need to get SVN working so I can share this evil thing with the rest of the world and maybe even invite a few people to Join the Fun. Any advice on that would be appreciated.