Pipedreaming: Could XPath have been better?

By Michael Kay on January 15, 2010 at 02:18p.m.

I normally resist the kind of wishful thinking that tries to improve languages like XML or XPath without worrying about backwards compatibility. In practice you can never ignore the legacy: compatibility means deliberately repeating other people's mistakes, as David Wheeler used to say when I was an undergraduate. But it's New Year, so let's be absurdly optimistic, and assume that anything can be done. (And what set me on to this was actually something quite practical: Anthony Coates is looking at the XML support in Scala. Scala has a kind of XPath-like expression that adapts the XPath syntax into the Scala framework. So in such an environment, there is indeed an opportunity to rethink things.

Here are some of the changes I think I would make:

What is all this trying to achieve? The bottom line, I guess, is

(a) making the semantics of the language cleaner and more explicitly functional;

(b) removing quirkiness and non-orthogonality even where these quirks provide ways ways of expressing commonly used constructs more concisely

Of course, it's all an academic exercise. But perhaps it points the way to a better way of describing the current language by mapping the syntax onto a more regular core.