Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!apple!voder!pyramid!octopus!vsi1!altnet!uunet!mcvax!ukc!etive!lfcs!jha From: jha@lfcs.ed.ac.uk (Jamie Andrews) Newsgroups: comp.lang.prolog Subject: Re: The meaning of "declarative" Message-ID: <849@etive.ed.ac.uk> Date: 14 Oct 88 17:52:30 GMT References: <818@etive.ed.ac.uk> Sender: news@etive.ed.ac.uk Reply-To: jha@lfcs.ed.ac.uk (Jamie Andrews) Distribution: comp.lang.prolog Organization: Laboratory for the Foundations of Computer Science, Edinburgh U Lines: 72 [ I posted this article before, but I suspect that it didn't get outside Edinburgh. If it did, please forgive me for reposting. ] In article alf@sics.se (Thomas Sj|land) writes: >Statement 1, (commonly accepted, it seems, although the meaning is unclear): > "Prolog is a declarative language" To me, "declarative" just means that you are writing programs by declaring (or "defining", or "describing") mathematical structures. I think the term was first used to draw a distinction between imperative languages and languages like LISP. So in functional languages, programs describe functions, and in logic programming, programs describe relations. I remember that when I learned LISP, it was very unclear to me why being declarative made it so superior to conventional languages. I was left with the impression that my prof. just thought it was better for some vague aesthetic reasons. Frankly, I'm still unimpressed by purely functional programming languages. >My view: "(declarative programming <-> programming without added intension)" I'm not sure what you mean by "added intension". Do you mean implementation considerations that make the program do more or less than it would seem to from a purely declarative reading? > My intuition leads me to think of soundness rather than completeness > when I hear the term "declarative". But consider the Prolog program P(x) :- Infinite_loop(x). P(3). and the query P(3). In the declarative reading of the predicate, it looks like P(3) holds. But when we run the query, it goes off into an infinite loop -- thus P(3) effectively does not hold. In this case, the declarativeness or intuitiveness of the program has just been misleading. A complete system, or an understandable semantics with respect to which a system is complete, would eliminate this problem. How much of a problem is this? It depends on your point of view. I think that if a system is just sound, that's good enough for most purposes; but if it's also complete with respect to some clean semantics, it's even better because we can also (supposedly) see when a program is going to terminate, as opposed to just seeing when it's not going to succeed (the only thing we can get for sure from a declarative reading when the system is just sound). BTW, re. my comment about functional programming: logic programming uses the language of logic, which is (by definition, almost) very close to the way we think and deduce information from assumptions. So logic programming is very useful for systems with lots of logical dependencies (expert systems, protocol testers, etc.), and its structure corresponds to a wide class of problems. Functional programming can make no such claim -- very few problems seem better thought of in terms of mathematical functions. The main thing that functional programming seems to offer over relational is a clear and deterministic decision procedure. --Jamie. jha@lfcs.ed.ac.uk "I always find mathematics so difficult" -- D.Hilbert