Path: utzoo!yunexus!ists!jarvis.csri.toronto.edu!rutgers!ucsd!ucbvax!hplabs!hpfcso!hpldola!patch From: patch@hpldola.HP.COM (Pat Chkoreff) Newsgroups: comp.lang.prolog Subject: Fun. vs. Logic Message-ID: <11500018@hpldola.HP.COM> Date: 10 Nov 89 01:43:15 GMT Article-I.D.: hpldola.11500018 Organization: HP Elec. Design Div. -ColoSpgs Lines: 44 I have been reading "Elements of Functional Programming", by Chris Reade, and it has caused me to reconsider the relative merits of logic versus functional programming languages. Specifically, I am considering the merits of Prolog versus ML or Miranda. Most Prolog predicates implement functions, so why not be honest and just use a functional language? It is very difficult, if not impossible, to write Prolog relations which work robustly in "all directions", i.e., solve for their inputs given their outputs. O.K., it's possible to write a parser which can be run backward, converting a syntax tree to a token stream. But once you add a symbol table and a code generator, you might as well be honest: you have implemented a function mapping a token stream into object code, it probably isn't reversible, and you probably don't even care. The nice thing about a functional language is that the functional dependencies are documented within the language, rather than as extraneous "modes" or in comments. In Prolog, there is a wide divergence between theory and practice, but in a functional language, the theory itself is practical. Most practical Prolog programs use constructs which are impossible to define within the pure Horn clause model -- they are riddled with constructs such as cut, not, and findall, and sometimes even assert and retract. These detract from the value of a Prolog program as a mathematical specification. The only impure constructs I've seen in functional programming are exceptions and destructive assignment, and these are very rarely used. In the "Elements of Functional Programming", each of these is used exactly once in order to implement some low-level stuff. Every other program is defined purely functionally, which means that it has well-defined semantics within lambda calculus. Furthermore, functional programming languages are strongly typed and higher-order, which cannot be said for Prolog. That allows me to do things like manipulate graphs as full-fledged objects, rather than as data scattered around in extensional relations. I can do that in pure Prolog, too, but it ain't easy. Are my points mistaken, or are there some features of Prolog which are just so wonderful that they eclipse all the bad things? Maybe logical variables or something? I have quite a bit of experience with Prolog, but none whatsoever with ML or Miranda. Patrick Chkoreff 719-590-5983 --- R.S.V.P. --- {hpfcla,hplabs}!hpldola!patch