[xquery-talk] Is it possible to maintain a list of value in XQuery

Liam R E Quin liam at w3.org
Wed May 15 21:39:42 PDT 2013

On Thu, 2013-05-16 at 00:22 +0000, David Lee wrote:
> I still am unconvinced that the theory that a purely functional
> language would enable vastly better optimizations
> has yet to be realized in the real world and may never be.

I'm not sure I'm failing to follow you incorrectly here.

Yes, declarative languages, especially with referential transparency,
are often massively easier to optimize than procedural ones. Or rather,
the computer science and mathematics might be harder in some cases, but
the optimizations can be more far-reaching. The down side is that they
tend to start out slower, so it doesn't always balance out. *BUT* they
are also often more maintainable.

I started to write an essay on optimization of procedural languages and
realised it was crazy and stopped.

One minor note though, that applies to a great many languages where the
same code is run many times - logging the result of each conditional and
then rewriting the generated code to make the faster branch the more
common is a useful trick that only works in some environments. The speed
difference in a language like C or assembly is because one branch has to
do a jump (goto) to get to the else part, and jumps tend to stall the
CPU pipeline. But even in a language like XQuery you'll tend to get L2
cache performance benefits in such cases. I don't know how significant
they would be, and would be interested in hearing from implementors.

Maybe we should have a public XQuery optimization wiki, although I don't
know how many vendors would be able to share their deep and wonderful
secrets :)


Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml

More information about the talk mailing list