Re: In which cases/problems is Prolog faster than Java?



Christina wrote:

Does minimax algorithm work faster in Prolog than in Java?

Some 10 years ago, when Java was only byte-code emulated, there was a
paper (or tech report) by (I think) Spanish people (UPM probably) who
showed with some benchmarks that Java and Prolog had roughly the same
performance (on some benchmarks, including qsort if I remember
right). I repeated some of those benchmarks myself at that time and it
depended a bit on which Prolog system one uses, and how one writes
particular constructs (if-then-else or multiple clauses with cut for
instance), but Java and Prolog were indeed close in speed.

In the mean time, Java execution technology has moved to JIT with
accordingly higher performance, while Prolog has mainly stayed
emulated. So you should expect that Java implementations are faster
(by an order of magnitude) than Prolog implementations. And that's all
you will be able to compare anyway: one implementation versus another
implementation, not one language versus another language. It's all in
the compiler technology that is used, nothing intrinsic in the
language, at least not for toy benchmarks where "everything is known".

BTW, you version of mergesort runs on lists of 30000 elements easily
in SWI, so you should blame the Trinc-Prolog implementation, not
Prolog - again the implementation and not a language.

A couple of weeks ago, a colleague from the numerical analysis group
said proudly that he had written a Sudoku solver and that he was
positively impressed that his program found the solution to a
newspaper puzzle in under 2 minutes. Now we know it is easy to write a
Sudoku solver in Prolog (and even easier in Prolog+constraints) that
solves puzzles in about a millisecond. It turned out that my colleague
had written his solver in MatLab ... so Prolog is faster than MatLab ?


Cheers

Bart Demoen
.



Relevant Pages

  • Re: In which cases/problems is Prolog faster than Java?
    ... showed with some benchmarks that Java and Prolog had roughly the same ... not one language versus another language. ...
    (comp.lang.prolog)
  • Re: Managing relations between objects
    ... I agree that an inference engine would be useful in language like Java and ... However, a programming environnement like Prolog, Python and Ruby don't ... automation, procedures and state machine cover most of the needs (I know, ... there is no native state machine in Java nor C#). ...
    (comp.object)
  • Re: How long it takes to educate Prolog/CLP programmer?
    ... other language" is pretty shallow. ... Now some guys want to apply the same principle to Prolog. ... 20 K lines of Prolog (with CLP) and they want someone to "learn ... years of C++ or Java. ...
    (comp.lang.prolog)
  • Re: Managing relations between objects
    ... However, a programming environnement like Prolog, Python and Ruby don't ... > there is no native state machine in Java nor C#). ... programming language, but it does have a C interface for embedding into ...
    (comp.object)
  • Re: Is Prolog good for AI? (was: Minsky still posting)
    ... but it was Prolog nor AI. ... whereas it is actually a language with a heavy dependence on ... I write declarative-style programs in C and Java. ... but there are hardly any portable resources. ...
    (comp.lang.prolog)