Monday, July 28 2003

HTML forms suck

It didn’t shock me to discover this, but it was one of those things about the web that I hadn’t really played with seriously. Then I started trying to expose all of the parameters for my random web colors page, so people could tinker with the color-generation rules.

Not only did the form add 24K to the page size, it increased the rendering time by about an order of magnitude.

The syntax for <select> is just crap:

<select name="color">
<option label="Red" value="#FF0000">
<option label="Green" value="#00FF00">
<option label="Blue" value="#0000FF" selected>

Extend this to a dozen choices, and then replicate it a hundred times across a non-trivial form. Blech.

Admittedly, in my case I’d have preferred some kind of slider control for most of the parameters anyway, but I can’t help but think that it would end up implemented with the same sort of syntax. It’s almost enough to make Java and JavaScript look like reasonable technologies.

Instead, though, I think I’ll just write an interpreter for a simple mini-language that contains just enough operators to do the job. Restricts the audience for the web page a bit, but if I distribute the interpreter as a Perl module, other people can build on it.

After a bit of tinkering, I think this is a reasonable syntax for my current rule-set:

base: r=[0,100];g=[0,100];b=[0,100]
back: base;h+[-15,15];s=[0,10];v=[90,100]
side: base;h+[-90,90];v=[75,85]
text: base;h+[-30,30];s=[90,100];v=[0,20]
head: back,side;s=[90,100];v=[20,50]
link: base,text,text;s=100;v=50
visited: link;v=30

Now to write the interpreter!