News for hackers. Stuff that matters.
Re:The Simplicity of Prolog by lionkor on Sunday January 26, 2025 @03:46AM (#42828787)
How can I use Prolog to actually get something done, other than academic tasks?

Say I want to use it as a database query language, presumably that's not going to happen, right?

Re:The Simplicity of Prolog by vixen99 on Sunday January 26, 2025 @04:57AM (#42829079)
Ditto!
Re:The Simplicity of Prolog by aktuel on Sunday January 26, 2025 @05:00AM (#42829093)
Re:The Simplicity of Prolog by Twey on Sunday January 26, 2025 @05:21AM (#42829174)
In a sense, Prolog _is_ a database query language. The base facts in Prolog are equivalent to the rows of a table. You can also ‘table’ predicates with variables (over a finite subset of values) by memoizing the results.
Re:The Simplicity of Prolog by tgamblin on Sunday January 26, 2025 @06:45AM (#42829493)
> Datalog is a declarative logic programming language. While it is syntactically a subset of Prolog, Datalog generally uses a bottom-up rather than top-down evaluation model. This difference yields significantly different behavior and properties from Prolog. It is often used as a query language for deductive databases.

https://en.m.wikipedia.org/wiki/Datalog

Re:The Simplicity of Prolog by 2-3-7-43-1807 on Sunday January 26, 2025 @10:47AM (#42830806)
do you know what you are writing about? I mean have you actually done something with datalog? and then _which_ datalog? if yes, then you are probably someone working with it academically or the answer is no. because try to even set a toy project up with it (for the purpose of learning how to use it) and you'll quickly run into unmaintained interpreters, discussions of what datalog is and what not and you can choose between difficult to understand academic papers or simplistic introductions that lead you no where.
Re:The Simplicity of Prolog by UltraSane on Sunday January 26, 2025 @02:56PM (#42833423)
Have you tried Datomic?
Re:The Simplicity of Prolog by 2-3-7-43-1807 on Sunday January 26, 2025 @03:39PM (#42833847)
no.

https://github.com/Datomic/codeq : last update to that repo was 12 years ago.

it's JDK which I find unappealing.

also, how close is it to Datalog?

https://github.com/gns24/pydatomic : last update 11 years ago.

and that's representative of pretty much anything regarding Datalog.

So, I'll just stick to Prolog then.

---

have you?

would you recommend it?

Re:The Simplicity of Prolog by UltraSane on Sunday January 26, 2025 @07:29PM (#42835896)
I tried using Datomic Pro for a CMDB. I liked how logical queries were but I ended up going with Neo4j instead because finding paths between two nodes is incredibly useful in IT.

https://central.sonatype.com/artifact/com.datomic/local/1.0....

Re:The Simplicity of Prolog by 2-3-7-43-1807 on Monday January 27, 2025 @04:25AM (#42839052)
mhm ... sounds like you don't know what you are talking about if you conflate Neo4j/Cypher with Datalog ... because "in IT".
Re:The Simplicity of Prolog by UltraSane on Monday January 27, 2025 @01:00PM (#42843823)
I'm fully aware they are very different things. I'm just saying I have tried using datomic and I really like it's query language but it cannot find a path between two objects like Neo4j which is a killer feature in a CMDB. My dream DB would be a hybrid of Neo4j and Datomic.

An example of where Neo4j really shines is I found a site with BGP route dumps. The file contains over 57 million very redundant Autonomous System paths that are just sequences of a IP prefix and the AS path it is reachable by. By loading each IP prefix and AS hop as

(Prefix)-[:ANNOUNCED_BY]->[:AS]-[:BGP_NEXT_HOP]->[:AS]

I can easily trace paths from one prefix to another by going

MATCH path = (p1:Prefix)-[:*]->(p2:Prefix) return path

which will return which AS announce the prefixes and all BGP paths between them. It really is very powerful.

Re:The Simplicity of Prolog by upghost on Sunday January 26, 2025 @07:44PM (#42836021)
Ok just to clarify, Datomic is a Clojure thing. It is free to use but closed source. It is an excellent database that is used, owned, and financed by Nubank, the largest and most rapidly growing bank in Brazil.

It is not Datalog syntax but heavily inspired by Datalog.

I'm throwing this in here just for clarification, I don't want to see Datomic as collateral damage in this conversation.

Re:The Simplicity of Prolog by fithisux on Monday January 27, 2025 @08:16AM (#42840791)
There is Datascript. I am not a Clojure guy, so it is not clear to me if it pulls datomic as a dependency.
Re:The Simplicity of Prolog by upghost on Monday January 27, 2025 @09:27AM (#42841444)
Datascript is very similar to Datomic, except that it runs in ClojureScript and is an in-memory datastore with no concept of history or point-in-time queries. The schemas are also much looser than Datomic.

Otherwise, many syntax and semantics are similar.

No dependency on Datomic as Datomic is Java and DataScript is JavaScript.

Re:The Simplicity of Prolog by fithisux on Tuesday January 28, 2025 @04:58AM (#42850640)
Ah thank you.
Re:The Simplicity of Prolog by akritid on Monday January 27, 2025 @05:09AM (#42839372)
I have found two somewhat usable (your point still stands): soufflé (high performance but more limited) and DES, which works well for some simple personal data management, after some code massage (it’s written in Prolog). Any other recommendations? And since the prolog experts are here: what do you think about Ciao? Seems quite polished but also adventurous to (non-expert) me
Re:The Simplicity of Prolog by upghost on Sunday January 26, 2025 @07:53AM (#42829782)
No, unless you count cancer research[1], particle physics experiments[2], and government funding allocations[3].

[1]: https://dcnorris.github.io/precautionary/index.html

[2]: https://github.com/mthom/scryer-prolog/discussions/2441

[3]: https://link.springer.com/chapter/10.1007/978-981-97-2300-3_...

Regarding how, check out Power of Prolog on YouTube.

Re:The Simplicity of Prolog by smarx007 on Sunday January 26, 2025 @08:53AM (#42830110)
Re:The Simplicity of Prolog by kevindamm on Sunday January 26, 2025 @10:17AM (#42830589)
Consider also checking out Datomic, though technically it's datalog not prolog, and not for connecting to your already-in-use SQL system, but it is a good example of taking the expressive power of logic programming to interface with a database.
Re:The Simplicity of Prolog by kevindamm on Sunday January 26, 2025 @01:49PM (#42832719)
EDIT: (too late to edit above)

s/logic programming/relational programming/

it isn't as expressive as LP or CLP and works best embedded in a functional-biased language

Re:The Simplicity of Prolog by LoneGeek on Sunday January 26, 2025 @04:56PM (#42834569)
For example: Void Linux installer implemented in GNU Prolog (https://github.com/sdbtools/void-pi).
Re:The Simplicity of Prolog by YeGoblynQueenne on Sunday January 26, 2025 @08:18PM (#42836259)
>> How can I use Prolog to actually get something done, other than academic tasks?

Choose the task, download Prolog and start coding. That's, generally, how you "get something done".

As to using Prolog as a database query language, I'd say that's like using a piano as a lawn ornament, but you can certainly replace a traditional relational DB with Prolog. The SWI-Prolog website does that and the developers explain how to do it in this article:

Can I replace a LAMP stack with SWI-Prolog?

https://www.swi-prolog.org/FAQ/PrologLAMP.md

And here's some more about using Prolog for good, old-fashioned, web development, in the sense of creating sites that run on the web and have visitors etc etc, particularly the SWI-Prolog website itself:

Eat Your Own Dog Food

https://www.swi-prolog.org/dogfood.html