You are here

The C language and good operating systems

Keywords: 

Last night I was on my bulletin board reading some usenet newsgroups. Some of the groups have hundreds of thousands of messages archived in them, resulting in single data files of up to a gigabyte. The BBS was designed with 10MB in mind as an upper limit, so it's doing well - but last night the disk need defragging as it was getting quite slow.

It got me thinking along other lines though, like methods to speed it up. The BBS offers a buffering mechanism in the binary API, but not to the ARexx scripts which drive the user end of the BBS. So I decided to add it into the ARexx API. Well, I spent a lot of time fixing a bug which was present in the software for probably 15 years (the buffer breaks if you list the messages backwards! Odd how it'd never been an issue before). Also some time trying to re-learn the code: the last change I made to the system was 12 months ago exactly, and before that just a dozen changes in five years.

But it's marvellous to work in C under the Amiga. Though I was immediately struck by how difficult lack of object orientation makes C (I needed to extend a data structure, so I had to recompile everything that used the data structure. If it was saved to disk (and not in IFF) I'd need to have written a conversion tool - objects and XML (like IFF) do away with this), but at the same time everything is understandable; the complexity is only of my own making, I'm not fighting a 30 layers of abstraction to find out where the prefs are being saved.

The job took a while, probably eight hours. But I loved doing it, even though by the time I'd finished the disk had defragged and the need for the buffering was less.

The next job is make the message storage more intelligent. At the moment I have more than a million messages in what are essentially unindexed flat file databases. I think now is the time to learn how to write a proper database :-)
I could just plug in MySQL, but it'd be less efficient and of course GPL. And what fun would that be? I want to write it myself for the fun of it :-)

Thinking about it, another reason I like working on my BBS is how good the code is. The quality of coding and algorithms is a given; I'm thinking more of the visual appearance. There are three authors in the sources, the original two and myself who took over from v1.2. Neither of the two original authors wrote any comments. Seriously. One author wrote extremely neat code, which I've learned a lot from, the other wrote code of equal cleverness but in an untidy way. From this mash up comes my perfected vision of code which I've been working to for many years, as I work on refactoring the existing source and writing new. It dispares me to see the visual quality of code some people produce and I have to maintain; from simple things like not continuing to use the same bracing and commenting styles from one line to another in an existing source file to more fundamental things like using indenting.