Scala or XML for Documents? (March 24, 2006)

I have used DocBook in the past for documents where I would like to distribute both HTML and for-print versions. It works reasonably well, but there are three major shortcomings:

  1. There are no subroutines or macros. If you do something twenty times, you have to repeat yourself.
  2. It does not look as nice as a carefully written Latex file.
  3. It does not handle math formulas, where Latex remains king.

I have long yearned for a Turing-complete language to use instead of XML. It turns out that Scala's case classes are about equally as expressive, while addressing most of these issues. The first issue goes away entirely. The second is actually reduced, but only because I wrote my own style sheets instead of relying on Docbook. (As an aside, why in the world do the standard Docbook styles generate such bad for-print versions? Latex's simple article style looks much better.) Only the third is left untouched.

Enough said. The implementations are about equally long, if you discount the style sheets. Here's the original file and counts:

And here are the new files:

Finally, here's the output. I think it all looks so so, although naturally I mildly prefer both of my versions to the Docbook ones.


Lex Spoon