News for hackers. Stuff that matters.
Re:Ask HN: What's Prolog Like in 2024? by mark_l_watson on Thursday July 18, 2024 @09:38AM (#40995476)
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.

Re:Ask HN: What's Prolog Like in 2024? by klibertp on Thursday July 18, 2024 @10:08AM (#40995720)
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? by philzook on Thursday July 18, 2024 @10:57AM (#40996177)
I am quite pleased with the ability to easily use prolog from within python and vice versa. It makes it now one of the easiest and most expressive solvers to plug into for my tastes. I'm starting to accumulate useful solvers here https://github.com/philzook58/prologsolvers/tree/164297d87f6...

You need to install swi prolog https://www.swi-prolog.org/download/stable and pip install janus_swi

A simple example to get started: https://www.swi-prolog.org/pldoc/doc_for?object=section(%27p...

  import janus_swi as janus
  janus.consult("path", """
  edge(a,b).
  edge(b,c).    
  edge(c,d).

  :- table path/2.
  path(X,Y) :- edge(X,Y).
  path(X,Y) :- edge(X,Z), path(Z,Y).
  """)
  list(janus.query("path(a,Y)."))
Re:Ask HN: What's Prolog Like in 2024? by mark_l_watson on Thursday July 18, 2024 @10:46AM (#40996060)
Hey, thanks! That looks cool.
Re:Ask HN: What's Prolog Like in 2024? by nextos on Thursday July 18, 2024 @12:33PM (#40997299)
On the topic of multi-paradigm programming, including logic programming, Oz/Mozart is an obligatory mention. See CTM and http://mozart2.org/mozart-v1/doc-1.4.0/tutorial/index.html.

The authors were fairly prominent Prolog researchers. It's sad Van Roy is retiring and nobody is taking this forward. AliceML, a StandardML dialect inspired by Oz is also abandonware.

Re:Ask HN: What's Prolog Like in 2024? by nerdponx on Thursday July 18, 2024 @10:28AM (#40995889)
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? by mark_l_watson on Thursday July 18, 2024 @10:44AM (#40996050)
I have two short examples in one of my books that I am currently re-writing. Here is a link directly to the Python+ Prolog interop examples https://leanpub.com/pythonai/read#use-predicate-logic-by-cal...
Re:Ask HN: What's Prolog Like in 2024? by networked on Thursday July 18, 2024 @11:46AM (#40996787)
Thanks for the link. I have played with https://github.com/yuce/pyswip, and the MQI looks like a better, more maintainable approach (https://github.com/SWI-Prolog/packages-mqi).

The biggest source of friction I noticed when playing with PySwip was that because Prolog was represented as strings, it discouraged you from generating Prolog code on the fly. It would be nice to have an embedded DSL for Prolog in Python. (I am thinking something like SymPy or the Pony ORM—https://github.com/ponyorm/pony.)

Re:Ask HN: What's Prolog Like in 2024? by nickswalker on Thursday July 18, 2024 @04:37PM (#40999509)
I noticed the same friction while trying to integrate Answer Set Programming solvers into Python projects. The people who built the dominant ASP solver actually provide nice solutions though. Possible inspiration for Prolog tooling:

Clorm (Clingo ORM) [1] makes it easy to create facts after you define simple predicate Python classes. Here's an example project of mine which uses it to set up a scheduling problem (Python -> ASP) and to present the results (ASP -> Python).

https://github.com/raceconditionrunning/relay-scheduler

Clingo (the solver) exposes its internal AST implementation through Python bindings[2], so you can build up rules or other statements from typed components instead of strings. This simplifies the translation bits of implementing an ORM or whatever kind of wrapper a developer would prefer.

[1] https://github.com/potassco/clorm [2] https://potassco.org/clingo/python-api/current/clingo/ast.ht...

Re:Ask HN: What's Prolog Like in 2024? by networked on Friday July 19, 2024 @02:51AM (#41002626)
This is cool! I am glad to see that other people have thought in the same direction—and actually wrote the code. I have another reason to learn ASP.
Re:Ask HN: What's Prolog Like in 2024? by NegativeLatency on Friday July 19, 2024 @02:16AM (#41002392)
Don’t go looking at pony’s source code for inspiration. The api is neat but when your app starts to get complicated it begins to not work well.
Re:Ask HN: What's Prolog Like in 2024? by nerdponx on Thursday July 18, 2024 @06:06PM (#41000196)
Thank you!