Thursday, 12 March 2009

Interpretation or Compilation?

My first pass at the XProc processor uses XSLT to compile an 'executable' XSLT that will apply the steps declared in the pipeline to the source document(s). But, whilst thinking about the structure of the compiled pipeline I began to see how I might also implement an XProc interpreter too.

The interesting thing is that the two strategies more-or-less end up applying the same kinds of transforms to the same source content but where one executes the steps on versions of the source document held in auto-generated variables (the compiled version), the other processes the whole pipeline recursively, embedding the results of each step back into the pipeline before moving on to the next step (the interpreting version). I've even been wondering whether I can build a common set of step functions that can be called from either the compiler or the interpreter so that I don't get drawn into supporting two completely separate implementations.

Both have their pros-and-cons, but the really interesting part is discovering which strategy provides the better performance, be it speed and/or memory usage that is going to be the real winner. I've already imagined how I might be able to keep memory usage under control (more on that later), but as for speed of execution, well we'll have to wait and see...

No comments:

Post a Comment