Live data from Hacker News

Introduction to logic programming with Prolog

matchilling.com

1–10 of 93 posts

Re: Introduction to logic programming with Prolog

#2
> Prolog has a straightforward syntax. You will pick up the few rules very quickly. Let us transform the Socrates example from earlier into an actual Prolog program and analyse what is happing inside the compiler.

Yeah, and no. This skips over the fact that this will not work in swipl, and you need to write those rules in a separate file, and compile/load them.

This is mentioned way after the entire introduction, after the reader has already given up on trying anything with prolog

Re: Introduction to logic programming with Prolog

#4
I hated it in university and hate it until this very moment. I get what this language is doing and why it is great for special usecases. But I can absolutly can not read code written in Prolog. Staring at 3 lines of code and not knowing what the hell it does, gives me nightmares till today.

You can write a quicksort in a few lines. You can traverse over a tree very easily. But understanding these few lines takes me more time than writing it in C, Java, PHP etc.. But I guess it is all training...

Re: Introduction to logic programming with Prolog

#5
I find the section 5.3 from the paper "Out of the tar pit"[1] describes it very well:

> It is for this reason that Prolog falls short of the ideals of logic programming. Specifically it is necessary to be concerned with the operational interpretation of the program whilst writing the axioms.

I haven't heard of any approach that generalizes the goals of logic programming in a far better way. Is there any? (on specific usecases, having a sort of rule engine for running your "business rules" can indeed be an excellent approach)

[1] https://github.com/papers-we-love/papers-we-love/blob/master...

Re: Introduction to logic programming with Prolog

#6
I've seen a few contalks about logic programming, read a few articles, and aside from the intellectual curiosity in itself I can see that it is very elegant in certain circumstances (although I lack the hands-on experience to feel what those circumstances are).

Since doing a whole program in prolog isn't really practical for me, is there any way to use the logic programming paradigm in mainstream programming languages to deal with specific problems that fit it?

Re: Introduction to logic programming with Prolog

#8

I've seen a few contalks about logic programming, read a few articles, and aside from the intellectual curiosity in itself I can see that it is very elegant in certain circumstances (although I lack the hands-on experience to feel what those circumstances are). Since doing a whole program in prolog isn't really practical for me, is there any way to use the logic programming paradigm in mainstream programming language…

Not 100% sure I answer your question but I have used Prolog mixed with Java a while ago and as a high level layer for problem representation. It's not brilliant but at that time it did help me implement quite complex agent behavior within a multi-agent environment.

Re: Introduction to logic programming with Prolog

#9

I've seen a few contalks about logic programming, read a few articles, and aside from the intellectual curiosity in itself I can see that it is very elegant in certain circumstances (although I lack the hands-on experience to feel what those circumstances are). Since doing a whole program in prolog isn't really practical for me, is there any way to use the logic programming paradigm in mainstream programming language…

I can come up with the following possibilities, although I have no experience with either:

- Using OWL in Java (with OWL API). So you use Java in combination with XML

- Use a Prolog embedding in Haskell.

Re: Introduction to logic programming with Prolog

#10

I've seen a few contalks about logic programming, read a few articles, and aside from the intellectual curiosity in itself I can see that it is very elegant in certain circumstances (although I lack the hands-on experience to feel what those circumstances are). Since doing a whole program in prolog isn't really practical for me, is there any way to use the logic programming paradigm in mainstream programming language…

Check out https://github.com/rvirding/erlog with Erlang/Elixir
Post reply on HN