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



Christina wrote:

I have implemented sorting algorithms like merge sort, tree sort and
bubble sort in both Java and Trinc-Prolog, hoping to prove that Prolog
runs faster than Java....Unfortunately, for large amount of data
(30000 input size), Trinc-Prolog dies and Java runs in 2 or 3
miliseconds....for small input, still Java is better in comparison
with Trinc-Prolog. I will also test minimax algorithm for checkers,
both in Java and in Prolog, but this will take some time....firstly, I
am interested in small problems that would prove Prolog's efficiency
over Java.
I want to know which problems work better in Prolog than in Java, so
that I can continue my study.
Thank you,
Christine

Problems that involve unification, depth first search, recursion,
serious list manipulation will be better implemented in Prolog.

Its not just the speed. Its the process of implementing the solution.
You will require two or three times the amount of code to implement
unification and DFS, and list processing in Java than it takes in
Prolog.

also after you done implementing it in Java maintaining it will be
(somewhat of a challenge)

So comparing qsort, bubble sort, etc is not a good metric.

There are list manipulation techniques in Prolog that can easily be done
in a single line
of Prolog that would require many lines of Java. The same is true for
Prolog algorithms
that rely on unification, DFS and recursion. I've had to convert Prolog
code to Java and
C++ its (almost) never a pretty sight. And the C++ and Java
programmers that have
to maintain it always feel trepidation.


.



Relevant Pages