((Very)Tiny)Prolog in Javascript

This represents my entry into the 5k award. This is a competition to design useful or appealing webpages/sites that fit in under 5k of source.

As you might expect, this is neither useful or appealing, except to extreme geeks.

Browser compatibility: I know it'll work on NN4.7 (but probably not before that; it shows up some bugs in the JS implementation) and IE 4 and 5. Lynx users can merely look at the code and retch.

Here's the explanation I sent with the entry:

OK, this is a total geek toy. The attached ZIP file should unzip to 4935 bytes; call it prolog.html.

The interpreter is a TinyProlog written in JavaScript. It's brutal enough that it breaks a lot of (even recent) JS implementations; I've tried it on NN4.7 and that seems to work; similarly on mozilla. I've no idea if it'll run under any of the IE beasts, but it probably ought to.

How it works: you can view the original source at <http://tribble.ilrt.bris.ac.uk/~cmjg/test/prolog.html>

However, this is more than two times too large for the competition. I had a play and discovered that javascript's eval() lets you define functions (<http://tribble.ilrt.bris.ac.uk/~cmjg/test/eval.html>) and so compressed the code a bit. I stored the whole interpreter definition into a single (compressed) string and expanded it before eval()ing the result.

Yep, it's hideous. But: it's not obfuscated; it's just compact.

You need to be a serious geek to appreciate this, I suppose, but I thought it was worth an entry. Probably won't win any awards for asthetic appeal though :-(

As a side note, the original interpreter has been used in a number of demos and tutorials (primarily geared at members of the library community) along the lines of "look how easy it is to inference over metadata".


PS. If the zip's corrupt the original file is at <http://tribble.ilrt.bris.ac.uk/~cmjg/test/prolog.small.html>