[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] RE: Declarative programming requires a differentmindset
- From: Liam R E Quin <liam@w3.org>
- To: "Costello, Roger L." <costello@mitre.org>
- Date: Sun, 11 Apr 2010 02:09:37 -0400
On Sat, 2010-04-10 at 13:28 -0400, Costello, Roger L. wrote:
> Hi Folks,
>
> I continue to explore the declarative programming mindset. I've had a
> few more insights. I realized, for example, that XML Schema, RELAX NG,
> and Schematron are declarative programming languages.
To quote Wikipedia,
A programming language is an artificial language designed to express
computations that can be performed by a machine, particularly a
computer. Programming languages can be used to create programs that
control the behavior of a machine, to express algorithms precisely, or
as a mode of human communication. [1]
So, for XML Schema (let's say)....
artificial language - yes
designed to express computations - no
used to create programs - not directly, no
control behaviour - no
express algorithms - no
mode of human communication - yes
Like XSD, RNG is also a _language_, and like XSD, it's not a
programming language. Most Schema languages for XML, including
XSD, RNG and DTDs, are declarative languages but they fall more into
the category of descriptive markup than programming languages, because
you can't easily use them to write general programs. For example,
it would be difficult to write a program to solve the Towers of
Hanoi puzzle in W3C XML Schema.
Hmm, it might be possible to write a schema to validate a correct
sequence of moves. But such approaches become intractable if your
problem is more complex.
I've deliberately not mentioned Schematron because it blurs some of
the boundaries -- something I like, but not when trying to explain
things :)
XSLT and XQuery could plausibly be described as programming languages.
On your diagram [2], note that it's possible to write procedural
code in prolog, using the "cut" operator. Similarly, most LISP
code I've seen is heavily procedural, and uses assignment and
side-effects. There are "pure" dialects of LISP; Scheme is not
in general a pure dialect, although there's a pure subset of
Scheme which does not have assignment.
Constraint-based systems overlap heavily with rule-based systems,
since constraints are typically expressed with rules. But it's
an overlap relation, not a subset relation.
XHTML is not a programming language at all.
I've no clue why you put "definition-based functional language"
separately from "rule programming",you've lost me there.
A function is a set of relations mapping distinct values from some
domain to a given range. An XSLT template can be considered as a
function that maps a given sub-tree of the input to some output tree
(more precisely, XDM -> XDM). So, an XSLT stylesheet is really a
function, and XSLT is in that sense a functional language [3].
XQuery is another example of a functional language in the sense of [3];
the result of a function (like an XSLT template) depends only on the
explicit arguments: calling the same function twice with the same
arguments will give you the same result, and indeed in both languages,
an implementation can "memoize" the results of a function, and not
call it a second time if the arguments are the same.
Of course, neither XSLT nor XQuery is directly based on the lambda
calculus or on combinators (like the FP language from years ago).
I think your document is actually an interesting start, and if
it's brought into focus a little more sharply :-) then it might make
an interesting paper at Balisage this year, you've just got time to
submit it! :-)
Liam
[1] http://en.wikipedia.org/wiki/Programming_language
[2] http://www.xfront.com/XML-Declarative-Programming/
[3] http://en.wikipedia.org/wiki/Functional_programming
--
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 www.advogato.org
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]