Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!gatech!news.sprintlink.net!simtel!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: speed of prolog
Message-ID: <9514714.11493@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU (CS-Usenet)
Organization: Computer Science, University of Melbourne, Australia
References: <3pam2e$9jh@chuangtsu.acns.carleton.edu> <3pptgj$6do@percy.cs.bham.ac.uk> <D90wt4.32n@cee.hw.ac.uk>
Date: Sat, 27 May 1995 04:32:24 GMT
Lines: 67

andrew@cee.hw.ac.uk (Andrew Dinn) writes:

>James A Hammerton (J.A.Hammerton@cs.bham.ac.uk) wrote:
>: nelsonb@mathcs.carleton.edu wrote:
>
>: : I have heard that prolog is fast.  Is this true?  If it is, why?  Thanks.
>
>: I don't know where you heard that from. Prolog is not going to be as
>: fast as say C or C++, because...
>
>Oh dear. The answer here is almost as irrelevant as the question. A
>language can hardly be described as slow or fast per se.

No, a language certainly can be described as fast or slow.
People often do describe languages in that way!
And, although it does have limitations, it is a _useful_ description.

>So much depends.

Yes, but that doesn't make the description of languages as "slow"
or "fast" useless.

Of course, it would _more_ useful to give a more qualified statement,
such as "In the vast majority of situations, assuming equivalent
programmer competence, Prolog is slow when compared to C", or something
even more qualified.  But throwing up one's hands and saying that all
performance comparisons between programming languages are meaningless
is not very useful.

>Undoubtedly, for many tasks a Prolog program, even when coded by an
>expert, cannot do the same job as fast as a C++ program coded by an
>expert.

I would say that C would be faster than Prolog for the vast majority of tasks,
not just "many tasks".  With C++ it is a little less clear, since
one of the strengths of C++ is its ability to span a wide range of
efficiency/productivity trade-offs.  A C++ programmer might often
choose a less efficient but easier and more maintainable solution, if
efficiency was not so important.  But presuming both the Prolog
programmer and the C++ programmer were concentrating on efficiency,
I would expect the C++ program to be faster in the vast majority of
cases.

>But for some tasks the converse is the case.

Name some!

If there are any tasks where Prolog can out-perform C or C++,
they are *very* few and far between.  I challenge anyone to
produce such a Prolog program.  I am very confident that I
could write a C/C++ program with equal or better performance.

>[...] stop worrying about raw speed and start worrying about
>other more important properties which your programs need to have such
>as readability, maintainbability, reusability, testability etc.

It is certainly true that looking at efficiency alone gives you a
very skewed view, and that these other factors are more important
for most applications.

But Prolog doesn't score wonderfully on the readability and
maintainability scales either ;-)

-- 
Fergus Henderson
fjh@cs.mu.oz.au
http://www.cs.mu.oz.au/~fjh
