7 ms·
I've wondered this a few times myself - I like learning languages (even if not directly applicable to paid work) and Prolog has been on the list, but I wonder i
by solaxun 6y ago
I've wondered this a few times myself - I like learning languages (even if not directly applicable to paid work) and Prolog has been on the list, but I wonder if the concepts are better left on their own rather than packaged into a DSL.
If I understand constraint propagation and backtracking, why not just use those concepts when it fits the problem rather than an entirely new language meant specifically for that narrow range of problems?
- chubot 6y agoYeah I think that is a better solution. Somebody who worked on the Mercury logic language for 10 years ago said the same thing here: https://old.reddit.com/r/ProgrammingLanguages/comments/9kb9z5/logic_programming_languages/ https://old.reddit.com/r/ProgrammingLanguages/comments/9kb9z... I have worked on and with Mercury for about 10 years. I had very little logic programming experience before this, while others tend to learn Prolog first. I like Mercury, but not for the logic programming features, in practice they aren't used very often, there's not many parts of a program that require backtracking. So on reflection, I don't think it's something I'd include in a new language, it's not worth the implementation and maintenance costs. Not for most programs most of the time anyway. On learning logic programming: It might sound like I'm discouraging anyone interested in this, far from it. Logic programming is a great paradigm to learn, another conceptual tool in your toolbox etc. via https://news.ycombinator.com/item?id=18376593 https://news.ycombinator.com/item?id=18376593
- inkyoto 6y agoProlog excels at solving NP complete problems (e.g. the SAT solver) or combinatorial problems in general that would normally require polynomial-vs-exponential time to find a solution whereas the use of Prolog allows to arrive at the same solution in the linear-vs-quadratic time. It is not really possible to accomplish it with a DSL. Another amusing property of Prolog is that a typical Prolog program can be run forward... and backward, i.e. it is possible to «ask» a question and receive an «answer», or if the «answer» is known, the program can arrive at a set of all possible «questions». Hence heavy Prolog use to build expert systems and alike. Back in the days, we used to giggle that if the 42 answer was fed into a Prolog problem solver to arrive at a full and exhaustive set of questions about the meaning of life, the universe and stuff, that would instantly create a singularity at the point in time and space where the solver was run and henceforth result in a collapse of the universe unto itself.