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



Paulo Moura wrote:

On May 22, 4:19 pm, Cameron Hughes <cahug...@xxxxxxxxxx> wrote:

The most relevant comparison between Java & Prolog is object oriented solutions vs logic programming solutions. Unification approaches vs assignment approaches.

The first "vs" above is both true and misleading (the second "vs" is
the important one). About the misleading bit. We've OOP languages
built from imperative language foundations (e.g. Objective-C, C++,
Java). We've OOP languages built from functional languages foundations
(e.g. CLOS). We've OOP languages built from logic languages
foundations (e.g. OL(P), L&O, Logtalk). This is a consequence of the
need of powerful code encapsulation and code reuse mechanisms missing
from imperative, functional, and logic languages. Language
implementers do not develop e.g. CLOS or Logtalk because they miss or
they are envy of imperative programming styles. Programming in CLOS
still fells like functional programming. Programming in Logtalk still
feels like logic programming. Encapsulation features helps you
encapsulate code. Reuse features helps you reuse your code. A function
is still a function either in plain Lisp or in CLOS. A predicate is
still a predicate either in plain Prolog or encapsulated in a Prolog
module or a Logtalk object.

Java is well suited to certain paradigms of software development. Prolog is well suited to other paradigms of software development. These two languages should be used
to complement each other.

People often use Java not because its OO features per se but because
its libraries. And, when talking about libraries that allows you to
write powerful applications without the need of implementing every
single bit of functionality yourself, then we, Prolog programmers,
have good reasons to fell envy :(

Obviously many problems can be solved from either a object oriented or a logic programming paradigm (but the solutions will look different!)

Yes, solutions will look different. But, for non-trivial problems, one
of them will be a good (or at least acceptable) solution while the
other will be a awkward solution at best. Objects are secondary here.
As you wrote above, the "unification approaches vs assignment
approaches" is what dictates the fundamental differences.

Best regards,

Paulo

Of course, I agree with virtually all of the above. My statement about Java representing OO and Prolog Logic, really was a gross generaliztion and
over simplification (but it was just to make a point) not necessarily with precision. I largely agree.

I do disagree however with your "But for non-trivial problems" One will be good and the other will be awkward statement. Let's consider
some non trivial problem. It is totally fair to say that we can have a high quality object oriented decomposition, and object oriented solution model
of the non trivial problem. It is also totally fair to say that we can have a high quality logic programming decomposition and logic oriented solution model
of the same problem. Both can be equally effective and both can be seen as elegant to their respective communities. The object model and the logic model are not
mutually exclusive for non trivial problems. In fact the more non trivial a problem is the more likely it will lend itself to multiple paradigms and models. That
is (at least in part) what makes it non-trivial! That's precisely where insight and inspiration come into play in our game. Its the ability to see the problem and
solution from a
completely different place.

The models we choose help us to see the problem from different perspectives. I have found it very, very rewarding to model the same problem and somesolution
using object models, functional models, and FOL models, etc. I can't really shed any light on small problems, most of my professional experience involves
non trivial stuff. When we are talking about non-trivial or real-world (scale) applications then it is obvious that Java and Prolog are not
interchangeable. You wouldn't really just swap out one over the other just to shave some seconds off their quick sort implementation . Not unless
you were dealing with mission critical, life or death scenario. In which case the use of either Java or Prolog would have to be under scrutiny.


In terms of Libraries ., hmm (I see what you mean) But perhaps there is a paradigm shift in order. Of course it is seductive to think of Prolog with
security libraries, database connectivity libraries, math libraries, XML parsing, more string processing libraries, GUI, LDAP, SOAP, etc. and adding
or enhancing standard versions of these aren't necessarily a bad thing. But if you look at Prolog as a different paradigm of programming then you don't necessarily
use the Library metaphor. I know that the idea of a library is true and tried and easily digestable notion. But perhaps that metaphor misses the boat with
Prolog. Do we want to extend the functionality of Prolog through libraries or something else? What about extended Prolog's power through the addition
of different 'inference patterns', modal logics, cognitive structures? What about adding new graph traversal modes? What about additional parallelism models?
Let's add some of this stuff!!! the more of this we have the more unimportant the argument between Java vs Prolog becomes.

Obviously when you are deep in a prolog application and you (suddenly) find that you need to talk to Oracle, Microsoft Active Directory, Ldap, and then render a flash movie
it would be nice to have some built in Prolog libraries that would accomplish all that stuff :-) LOL. But we typically use Prolog for other types of scenarios. Right?


.



Relevant Pages

  • Re: Is Prolog good for AI? (was: Minsky still posting)
    ... > than a programming language suitable for large scale direct human use. ... but it was Prolog nor AI. ... >> than most other languages. ... PHP because it solves a very specific problem. ...
    (comp.lang.prolog)
  • Re: Head-in-the-Sand Liberals (LA Times Columnist)
    ... You claimed to have known several computer languages, ... If you lie about knowing computer languages, ... of the programming loop for a functional ... You also don't know Java. ...
    (rec.org.mensa)
  • Re: How come Ada isnt more popular?
    ... Most programming languages were terrible at that time, ... And we talked about "Why isn't Ada more popular?". ... Adopting Java ...
    (comp.lang.ada)
  • Re: performance question
    ... that let me mix different programming styles more freely. ... When I started learning Java, my biggest problem was that I ... I've noticed that people often prefer to take shortcuts when writing code - ... deficiencies in the model and/or the existing languages that implement ...
    (comp.lang.java.programmer)
  • Re: Bloody Java again
    ... I passed my Java exams last year but really have ... Erlang's concurrent programming is rather abstract and high-level. ... He is not being asked to grade umpteenth different languages. ... Student: "It's all in the program, ...
    (comp.lang.functional)