Monday, 27 April 2009

Experiment Dump

Over the past few years I've accrued a lot of failed, successful or otherwise abandoned experimental programs in my /home/chris/Files/Documents/Play/Programming directory (yes, I am somewhat OCD about file organisation). Since they might be interesting to some people, as they were obviously so interesting to me that I wanted to write them, I've started to upload them to FreeWebs. Here's a list, along with a brief description. - This is a simple test showing one of the reasons I hate Java. Java stores integer numbers in a fixed amount of space, 32 bits. 32 bits can be in one of 2^32 unique combinations, which Java divides down the middle. The middle combination, 10000000000000000000000000000000, is taken to be zero. The combination above, 10000000000000000000000000000001 represents 1, and so on up to 11111111111111111111111111111111, which is 2147483647. In the other direction, the combination below (01111111111111111111111111111111) represents -1, 01111111111111111111111111111110 represents -2 and so on until 00000000000000000000000000000000, which is -2147483648. The problem with this can be shown if you try to add 1 on to the biggest number, which gives 100000000000000000000000000000000, but since Java only allows numbers to be 32 bits long it only bothers looking at the last 32 bits, so it thinks that 2147483647 + 1 = -2147483648, which in my opinion is a fail. To add insult to injury, Java doesn't allow applications to compile unless they handle every possible exception they come into contact with, including those that will never be thrown or which aren't even used, yet Java is perfectly happy to let its own failures pass without comment, causing debug headaches.

To run this just compile it (for example with "javac"), then run it (for example with "java MaxInt").

JavaGnucleon.tar.bz2 - This is a simple board game along the lines of Atoms on the Amiga. Players take it in turns to click on squares to "add an atom to them". Anyone can click on an empty square (indicated by a 0), but once a square has an atom in then it is owned by that player (and changes colour) and only that player can click on it from then on. Once a square gets as many atoms in it as it has nearest neighbours (not including diagonals) then it explodes, sending one atom to each neighbour and claiming them for the player. Chain reactions can occur if a square explodes and sends an atom to a neighbouring square, giving it enough to explode, and so on.

package-installer.tar.bz2 - This is a non-functional Java GUI for a package management tool I was working on a couple of years ago. It's similar to APTonCD, but as far as I know predates it a little.

AppPrefs.tar.bz2 - This is a non-functional Python/GTK GUI for choosing GNOME's default applications. It shows how the default browser could be chosen, giving a textual description of each one's unique features (ie. what makes it different) along with a screenshot. The idea is that users don't need to know or remember the names of the applications, they can read the description and look a the screenshot to see if it's the one they were looking for (these days Synaptic can show screenshots, which is awesome :D ). Also, I wanted to get rid of the IMHO broken idea of associating applications with filenames, such as files ending in ".mp3" and so on. File types should be determined using magic or libmagic, and users shouldn't have to care about the implementation. They should just be able to say "Music" or "Spreadsheet". - A very simple Python script which makes a square bounce around the screen based on some very dodgy Physics.

Some Nice Things

I've not posted for a while, due to a mixture of an increasing workload, the ability to let off a constant barrage of my thoughts to rather than build them up into a blog post, and my constant disdain for Web-based apps.

So what do I want to blog about? Nothing particularly structured, just some stuff that I find interesting. Keep in mind though, that my definition of interesting includes the fact that 12cm optical discs have increased their storage capacity by 2 orders of magnitude in the 27 years from the CD to the BluRay, whilst in the same time frame the capacity of 3 1/2" hard drives has gone up 12 orders of magnitude. (I'm writing an essay on Optical Data Storage for a Physics module :) )

For those of you who may remember Deluxe Paint on AGA capable Amigas I can heartily recommend that you check out Grafx2, which seems to work on pretty much every OS and has recently been added to Debian, so you can install it by ticking "grafx2" in any package manager, it will be downloaded and installed along with everything it depends on :) Doesn't seem to do animation yet, as far as I can tell, which is a shame.

Also recently added to Debian is Closed World Model, cwm. This is pretty special, since it takes cutting edge computer knowledge representation as used by the Semantic Web, and makes it accessible via a tool similar to UNIX's (and of course GNU's) classic sed tool. For example, you can use a command like "cwm --rdf inputfile1.rdf inputfile2.rdf --n3 inputfile3.n --rdf --think --pipe > output.rdf" to take at all of the knowledge from the RDF files inputfile1.rdf, inputfile2.rdf and inputfile3.n (in RDF-XML and Notation3 formats), comparing the knowledge they contain, and dumping all of the new knowledge it can infer into the RDF-XML file output.rdf. For example, inputfile1.rdf could contain statements that Chris Warburton is a student, Chris Warburton has a website and that Chris Warburton has a brother David Warburton. inputfile2.rdf could say that Brothers are related and that Brothers share a Mother. inputfile3.n could say that David Warburton has a blog at and David Warburton has a mother Cheryl Warburton. cwd would then combine these and the output file would contain deductions such as David Warburton is related to a student, is run by a student and Chris Warburton has a mother Cheryl Warburton.

This is pretty cool, since it commoditises the previously tricky area of RDF access, allowing it to be scripted, for example in the backend of Web sites, in the same way that Imagemagick has done to images (eg. for thumbnailing).

Pretty cool. Anyway, it's getting late so I should get some sleep now.

I'm going to post some of my programming experiments soon, so look out for them :)