Live data from Hacker News

Ask HN: What's Prolog like in 2024?

news.ycombinator.com

71–80 of 289 posts

Re: Ask HN: What's Prolog like in 2024?

#71
post #14

Prolog has reached an exciting new milestone with Scryer prolog. It is the first highly performant open source iso-compliant Prolog. I would check out Markus Triska's work to have your mind blown: https://www.metalevel.at/prolog https://youtube.com/@thepowerofprolog

I interviewed and helped hire Mark Thom, the original author of Scryer. I also follow Scryer with interest, even though most of my limited Prolog use has been with SWI Prolog (and one large project with ExperProlog in the 1980s). One thing to check out: Prolog plays fairly well with Python, providing opportunities for hybrid projects.

To playing well with Python, this was on a front page some time ago: https://arxiv.org/abs/2308.15893

"The Janus System: Multi-paradigm Programming in Prolog and Python"

Re: Ask HN: What's Prolog like in 2024?

#72
I chose to use prolog to essentially build an expert system across and heterogeneous data ecosystem.

Prolog could certainly use some serious improvements to its tooling. But the language is simple enough that it doesn't prove too much of an issue. You can get some much out of language it can be very powerful. In the system we've built it makes up a purely logical core that is completely referentially transparent, we leave all the ecky side effecting to a host program.

Re: Ask HN: What's Prolog like in 2024?

#73

No idea, but it might be worth looking into Mercury and {mini,micro}Kanren/core.logic as more practical iterations on it (either by adding things to Prolog or extracting the interesting to stuff to use in more general purpose languages).

At the end of the day "practical" means library support and community knowledge, by which measure Prolog and more specifically SWI and Sicstus are far more practical than any of the other logic languages or implementation options

Well if your problem does not require a solution that’s 100% written in prolog, then any relational/CLP system that can be hosted or work as a library is going to win in terms of library support and community knowledge, at solution level.

So e.g. a core.logic solution can make extensive use of the jvm ecosystem.

Re: Ask HN: What's Prolog like in 2024?

#74

Prolog, and Constraint Programming especially are great to have in your toolbox. I’ve done research in the field for years, and my job in the industry today is writing Prolog. There are real issues with Prolog: - no proper module nor package system in the modern sense. - in large code bases extra-logical constructs (like cuts) are unavoidable and turn Prolog code into an untenable mess. SWI prolog has single-sided un…

There are a lot of problems that Prolog / Constrain programming will solve very elegantly, and much more easily than imperative languages. I think constraint based programming is seriously under used in the industry, and too many programmers are unaware or unable to write constraint based code. I have always hoped to have just a constrain based programming subsystem in a lot of languages, for those niche cases.

Re: Ask HN: What's Prolog like in 2024?

#75
post #14

Prolog has reached an exciting new milestone with Scryer prolog. It is the first highly performant open source iso-compliant Prolog. I would check out Markus Triska's work to have your mind blown: https://www.metalevel.at/prolog https://youtube.com/@thepowerofprolog

I interviewed and helped hire Mark Thom, the original author of Scryer. I also follow Scryer with interest, even though most of my limited Prolog use has been with SWI Prolog (and one large project with ExperProlog in the 1980s). One thing to check out: Prolog plays fairly well with Python, providing opportunities for hybrid projects.

How do you normally use Prolog and Python together? I had looked into embedding logic programming within Python in the past, and found a lack of satisfying options, but maybe I didn't know where to look.

Re: Ask HN: What's Prolog like in 2024?

#76
The "magic" of Prolog is built upon two interesting concepts : Unification ( https://en.wikipedia.org/wiki/Unification_(computer_science)... ) and Backtracking ( https://en.wikipedia.org/wiki/Backtracking ).

Often bad teachers only present the declarative aspect of the language.

By virtue of being declarative, it allows to express inverse problems in a dangerously simple fashion, but doesn't provide any clue for a solution. And you are then using a declarative language to provide clues to guide the bad engine toward a solution. Making the whole code an awful mashup of declarative and imperative.

Rules :

- N integer, a integer > 1, b integer > 1

- N := a * b

Goal :

N = 2744977

You can embed such a simple problem easily but solving it is another thing.

The real surge of Prolog and other declarative constraint programming type of language will be when the solving engines will be better.

Unification is limited to the first order logic, high-order logic unification is undecidable in the general case. So we probably will have to rely on heuristics. By rewriting prolog goal solving as a game, you can use deep learning algorithms like alphago (Montecarlo tree search).

This engine internally adds intermediate logical rules to your simply defined problem, based on similar problems it has encountered in its training set. And then solve them like LLM, by picking the heuristically picking the right rule from intuition.

The continuous equivalent in a sort of unification is Rao-Blackwellisation (done automagically by deep-learning from its training experience) which allows to pick the right associations efficiently kind of the same way that a "most general unification algorithm" allows to pick the right variable to unify the terms.

Re: Ask HN: What's Prolog like in 2024?

#77

Definitive reference: https://www.urbanautomaton.com/blog/2015/08/10/the-pledge-to...

Dang, substitute Lisp for Prolog and this describes me. Seriously though - Prolog is an awesome tool to have in your toolbox. I've implemented Prolog-like logic programming solutions in several places in my 40+ years of programming. Like rules for assigning molecular mechanics force field atom types.

Re: Ask HN: What's Prolog like in 2024?

#78
post #25

Earlier quoted context omitted.

Could you explain more or point out some interesting references? I'm currently trying to understand how Datalog compares to SQL and, potentially GraphDBs

Prolog and Datalog example (they are identical in this case) % Facts parent(john, mary). parent(mary, ann). parent(mary, tom). % Rules ancestor(X, Y) :- parent(X, Y). ancestor(X, Z) :- parent(X, Y), ancestor(Y, Z). % Query ?- ancestor(john, X). The Prolog code looks identical to Datalog but the execution model is different. Prolog uses depth-first search and backtracking, which can lead to infinite loops if the rules…

How does the Datalog approach compare with RETE?

Re: Ask HN: What's Prolog like in 2024?

#79

Prolog, and Constraint Programming especially are great to have in your toolbox. I’ve done research in the field for years, and my job in the industry today is writing Prolog. There are real issues with Prolog: - no proper module nor package system in the modern sense. - in large code bases extra-logical constructs (like cuts) are unavoidable and turn Prolog code into an untenable mess. SWI prolog has single-sided un…

Maybe it's just me but I see a lack of a package manager as a massive, massive pro. I can't stand how seemingly every language has a package manager which requires it's own installation and you have to learn how to use THAT thing and then you need some library off github that does some minor task really well but you can't just download the fucking code, you have to import it via, idk, the Fork-Lyft manager which requires Python 3.3 and the PillJump framework and it's just like, I just want a fucking function to parse JSON, I don't want to saddle my system with 600 MB of shit I don't need.

Old_man_yells_at_cloud.jpg

Re: Ask HN: What's Prolog like in 2024?

#80

The problem with Prolog is that it's based on unification, and small unification engines can be expressed in a few lines in any functional programming language. That narrows down the already small niche where one would choose Prolog by probably a few orders.

Is this in the same sense that "one could write lisp in 99 lines of c"? In my opinion, this does not imply that proper lisp (and correspondingly prolog) implementations are useless, just because a simple implementation can be written in a different, "more expressive" language.

There is a very practical embedable logic-programming engine called miniKanren for many programming languages that can be used to add the logic-programming techniques of Prolog to other languages.

https://en.wikipedia.org/wiki/MiniKanren

There's a great book in the same series as the "Little Lisper"/"Little Schemer" books called "The Reasoned Schemer" that uses MiniKanren with Scheme.

Post reply on HN