[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Re: For loop over a collection, multiple

John Snelson john.snelson at ORACLE.COM
Wed Mar 3 12:23:23 PST 2010


  Re: For loop over a collection
Martin Probst wrote:
>> There are plenty of essential use cases of this kind (most of the ones I see
>> on a daily basis...)
>>
>> In the absence of such a scripting extension you have to go back and forth
>> between XQuery and other language (Java, Ruby, etc). That's what people
>> do,  that is very expensive in productivity and performance (thanks the
>> wonderful XML APIs..), and not maintainable.
> 
> I wouldn't agree. I have experimented several times with writing
> complete applications in XQuery, and it always feels like writing PHP
> code in 1999. No polymorphy, no abstraction mechanisms, no data types,
> and - to be quite honest - a relatively clunky syntax for a general
> purpose programming language. All of those are not problems when using
> XQuery as a query and/or XML manipulation language.

The higher order functions support in XQuery 1.1 should make a massive 
difference to that. It also allows you to create "sequences of 
sequences", and to therefore build data structures. I've already built a 
red/black tree using it, which can be used for sorted sets and maps.

> Of course it depends on your system setup, but you neither have to pay
> a performance penalty for moving from XQuery to another language, nor
> do XML APIs have to be ugly; at least for the part that you would do
> in an imperative language.

But nothing is as simple as XQuery's tight integration with XPath, and 
straightforward inline XML construction.

> I also wouldn't agree with the maintenance thing. The worst
> maintenance nightmares I've seen were usually written in a language
> that wasn't fit for the purpose, thus all kinds of problems ensued.
> Rather use the right tool for the job in a polyglot programming
> environment.

I don't disagree. It's just that there's a lot of applications who need 
to manipulate XML, query databases and/or produce XML/HTML. In that 
case, as many eXist and MarkLogic customers are finding out, XQuery is a 
great fit.

>> That's WAY worse then an XQuery scripting extension: at least XQuery-SE
>> programs can be compiled and optimized globally, but if the logic is split into
>> multiple languages, it's much harder, if not impossible to optimize globally.
> 
> That is actually a big concern for me, that scripting will make it
> impossible to optimize and compile XQuery programs globally. I
> probably don't have enough insight into the spec right now, but it
> seems to be like you wouldn't be able to do any reordering, shoving
> conditions around etc beyond the scope of a single sequential
> expression, would you?

Sure - it will be hard to optimize the imperative logic, just as it's 
hard to optimize Haskell's monads, or Scheme's assignments. But then 
again, 95% of code isn't on the critical path and doesn't need optimizing.

I don't want to sound too dismissive - I think optimization and 
parallalization is really important. But so is interacting with the real 
world and the 4th dimension. XQuery will always have at it's core a 
declarative functional language which will give users the tools they 
need to write optimizable code, and a query origin which I hope will 
encourage the solving of problems in a functional manner.

>> I do not know a single functional programming language that didn't get into
>> "dirty" scripting extensions when it reached a certain audience, and a
>> certain maturity.
> 
> Haskell? Depends on how you see Monads, I guess.

Monads are imperative, no question. In fact, I'm almost certain you 
could prove that XQuery Scripting Extensions is equivalent to 
introducing a monad called "sequential".

John

-- 
John Snelson, Oracle Corporation               http://twitter.com/jpcs
Berkeley DB XML:            http://oracle.com/database/berkeley-db/xml
XQilla:                                  http://xqilla.sourceforge.net


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.