Thursday, August 26, 2010

Hack First, Justify Later



As I mentioned in last week's episode, the first step in my purported web project was to get a webserver up and running. I tried GNU MyServer, but, couldn't figure out the setup, and then I tried GNU Serveez, which was out of date.

My hacked version of Serveez, which I'm calling Serveez-MG for now, it up in my space on Github. It seems to run great, and works with Guile 2.0.

This hack was interesting because I changed philosphies a few times along the way.

Stage 1: Professionalism

At first I thought I was going to do a clean update of the GNU Serveez. I was making atomic commits, writing decent ChangeLog entries, and pulling the project piece by piece into a modern Automake / Autoconf / Libtool / Gnulib project. But, realized this was going to take forever, and it is a waste of our few beautiful summer days, so I quickly moved on to ...

Stage 2: Hackery

Screw this. Why be so methodical on some software that nobody, nobody, is ever going to use except for me? And probably not even me, since I'll probably just use Apache anyway.

I dug in and changed everything with abandon. I replaced everything that annoyed me. I untangled their beautiful but labyrinthine #define macros.

The #ifdef branches were deeply nested, so I ripped that all out, too. Multiplatform: gone. Configurable: gone. Removed all the code to handle possibly missing functions.

Stage 3: Purity

Maybe I wasn't just being unprofessional. Maybe, I said to myself, I had a plan all along. I started to audit the code by comparing it to the Linux Standards Base database keeping only the functions that were LSB compliant. Eventually I had code that should compile cleanly on LSB systems.

It was actually kind of fun: looking in the LSB database navigator to see what functions and constants had good acceptance among the distros.

I also attacked the autotools with a vengance. I tried to make the Autoconf and Automake files as trivial as possible. Doing so led me to make libserveez subdirectory into an Autoconf subproject: that was a great simplification.

Stage 4: Finishing

And now the code is all clean and shiny, but, the commits that got me here are a tangle, with many changelog messages like "hack" or a 500 line commit called simply ".".

Maybe I should start back at step 1 and do it for real this time, now that I know the endgame.

Or maybe I should try to spend more time in the sun.

Monday, August 16, 2010

The Hack Hole

So, first of my migration project, I was going to install a webserver on my computer. Fedora 13 already comes with Apache, of course, but, again where's the fun in that.

I laid down some ground rules for this game.
* First, I'd evaluation pure Guile solutions. I actually tried this once before
in this post
* Second, I'd evaluate official GNU packages
* Then I'd look at pure GPL options

I also added the additional requirement
* It had to build out of the box
* I had to be able to set it up using the included documentation

(Which is a bit of a joke considering what happened later.)

In Guile, the only actively maintained webserver is TTN's Sizzweb. It didn't build out of the box for me. Looking for a script that wasn't there. There is still a some incompatibility between TTN's tools and new Guile 1.9.11 beta's build system, although there has been some recent convergence.

Moving on to GNU webservers...

GNU MyServer 0.9.2 built without much difficulty. It did require me to install the libevents library, which wasn't a documented dependency. I found that it didn't have enough documentation on how to configure it. It comes with a sample configuration file that I modified, but, I failed to get it running. I expend much effort, as I was still trying to be faithful to my self-imposed rules.

GNU Serveez was next. One of its features was that it integrated well with Guile and could be extended in Guile. Yet, it did not compile cleanly, and it was fairly out of date. It did not work with the new Guile 1.9.11 beta. This was to be expected. Guile's API changes frequently which has been a source of frustration for many.

Then, I violated my own rules and tried to patch it up. It deceptively appeared simple, but, once I started modifying it, it just got worse and worse. The whole shebang: autoconf, automake, the obsolete Guile API. I kept hacking and hacking and four days later, I have it working with new Guile.

It leave me asking myself, why? Why did I spend so much time on this?

Whatever. It is almost done, so I'll clean it up and post it. But the final product is way too hacked to resubmit upstream.