Random Art and the Law of Rotten Software

Since the death of my old web server my Random Art has not worked. Bringing it up to date and installing it on the new server was a nightmare in software management. But it was worth it. The new Random Art runs the random art program inside your browser!

I implemented the old Random Art in 2005 with ocaml and cduce. Cduce is a programming language for XML which statically checks correctness of produced XML. I thought that nothing could be better than a web site that has an a priori guarantee of 100% complicance with strict HMTL. Those were the days of idealism.

Well, in 2010 it turned out to be quite impossible to reinstall Random Art on the new server. First of all, the current version of cduce is incompatible with the one from 2005. In addition, the old version of random art relies on old ocaml libraries that are not available in current Linux distributions, so I cannot easily recompile it. If I really wanted to install the old version, I would have to install an antique Debian system from 2005, but then I would suffer from old security holes. There must be a software equivalent of the second law of thermodynamics, let’s call it the Law of Rotting Software:

“All software eventually fails, even if it you leave it alone.”

So it was clear that I should junk cduce and use something sane, like Django. (I know there is ocsigen, but as we say in Slovene, even a donkey steps on thin ice only once). I separated the ocaml code that computes random pictures from cduce and reimplemented the web site in Django. The site was up and running in no time! Except that all pictures were uniformly gray. It took me a week to figure out that this was caused by a change between ocaml 3.10 and 3.11 in how they treat mutable record fields inside function closures. It is still not clear to me exactly what the change is because I am not able to produce a small example that shows the difference.

I wanted to make the new site more user friendly by allowing users to generate their own random pictures. They would have to compute images inside their web browsers because I cannot afford a cloud of servers. So I decided to try Jake Donham‘s amazing ocamljs compiler that compiles ocaml to javascript. It worked, after a couple of days of making sure that the javascript code was equivalent to the ocaml code. I had to fix the pseudo-random number generator (which broke compatibility with the old random art), and remove a number of ambiguities about the evaluation order of arguments (ocaml evaluates  f x y in an undefined order, but usually right to left, whereas Javascript evaluates the arguments in f(x,y) from left to right). I am amazed at having 1200 lines of ocaml code run inside a browser.

Anyhow, I hope you will enjoy the new web site. Now I just have to make it work under Internet Explorer, which does not support HTML5 canvas element that I use for drawing (I suppose I just have to get Google’s excanvas to work.) Also, I recommend Google Chrome over Firefox because its javascript engine is way faster.

6 comments to Random Art and the Law of Rotten Software

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>