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...
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.
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.)