Hacker News new | past | comments | ask | show | jobs | submit login

When wondering about Prolog and types one should mention Mercury -- Prolog's typed cousin.

http://mercurylang.org/

Paper already mentions -- Haskell with logic extensions:

http://www-ps.informatik.uni-kiel.de/currywiki/

The problem with Prolog is the need to rewire your brain to think in Prolog. I remember struggling for many hours to solve a problem and hitting a wall. But then when it is solved in Prolog it would be something like 10 lines of code.

It kind of reminds of understanding and writing math formulas. It would take days to decipher a one-line formula.




The problem with programming in Prolog after learning how to think in Prolog is the need to remaster control of the search space via cut.


There's a fairly large part of the ex-Prolog community that decided to go all-in on the declarative part, partly in reaction to that, and partly in reaction to other warts in Prolog's semantics, like the fact that statement order is significant. There was a period when logic-programming theorists were trying to come up with what Prolog's semantics would be, if you assumed it was possible to give it a vaguely logic-style semantics versus defining its semantics as "whatever SLDNF gives you". One of the proposals that came out that was the "stable model semantics". And that gave rise to a purely declarative logic-programming paradigm, answer-set programming. That has then turned out to mesh well with modern developments in SAT/SMT/etc. solver-style systems, instead of Prolog's more classic backtracking search, so sits at some kind of intermediate space where it's about equally influenced by the logic-programming heritage and the "solver" heritage.

A well-maintained / open-source implementation: http://potassco.sourceforge.net

An introductory paper: http://www.aaai.org/Papers/AAAI/2008/AAAI08-270.pdf


Let me add another good entry point to answer set programming. http://www.kr.tuwien.ac.at/staff/tkren/pub/2009/rw2009-asp.p...


This. I'm no Prolog expert, but every time I come back to it I remember how elegant canonical problems are to solve with it. I absolutely love the declarative style. More languages need to have logic extensions a la core.logic for Clojure, various Kanrens for Scheme. I would love to see computer scientists make advancements in logic programming.


Just a nitpick, but core.logic is a version of Kanren[0].

[0] https://github.com/clojure/core.logic


I'm aware of that, I wasn't aware that I said otherwise ;) I just meant that more implementations in more languages would be a good thing


It's just the way you phrased it, core.logic for Clojure, various Kanrens for Scheme, as opposed to, implementations for Kanren in Clojure and Scheme such as core.logic.


Amen


Same experience with Prolog: I feel like I have to re-wire my brain every time I come back to it. Completely different way of solving problems.


mercury is really nice. For example, it has uniqueness typing for IO combined with syntactic sugar to make all of this rather terse.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: