Live data from Hacker News

The Power of Prolog

metalevel.at

21–30 of 69 posts

Re: The Power of Prolog

#21
Does anyone know if Prolog has been used in video games? I keep wondering if complex histories like those in Dwarf Fortress are coded via a Prolog-like approach to keep them consistent and correct.

Re: The Power of Prolog

#22
Prolog is cool but has exponential complexity which makes it impractical for real world use.

The rete algorithm was supposed to be a solution but has anyone applied rete to a prolog implementation yet?

Re: The Power of Prolog

#23

Earlier quoted context omitted.

On the other hand, with dozens of lines of Prolog you can solve some problems that would take many thousands of lines in other languages (and a lot of calm study before you can map them into a real logic or imperative algorithm). I still avoid it, because yeah, once you solve that problem and avoid those thousands of lines, you are stuck. If you try make the rest of your system in Prolog, it will become a non-viable…

There was a functional JVM language with built-in datalog that came through the other day. Datalog brings a lot of the value of pure prolog.

https://flix.dev/

Re: The Power of Prolog

#24

Prolog is cool but has exponential complexity which makes it impractical for real world use. The rete algorithm was supposed to be a solution but has anyone applied rete to a prolog implementation yet?

Isn't RETE a forward-chaining algorithm while Prolog is a backward-chaining language? I'm not sure you could use RETE for the actual Prolog semantics. Currently, fast implementations of Prolog use a virtual machine, the most popular is WAM, that can be compiled then to machine code (GNU Prolog does it). Also some implementations have JIT indexing, which improves performance too.

Re: The Power of Prolog

#25
post #17

Earlier quoted context omitted.

Prolog is a deep language and can teach so you a lot. The main problem is that any prolog program bigger than, say, a thousand lines of code become difficult to debug and understand. There are ways to make things better e.g. avoid impure prolog etc. but it is still problematic. Engineers are always looking for technologies to hop onto. Prolog is niche for a reason: I don’t think Prolog scales. In some ways it is too…

Are there any Prolog scripting engines or embeddable runtimes? It feels like the kind of thing where you might use it to solve a small part of your problem domain and leave the rest to a conventional language.

Off the top of my head:

Javascript: http://tau-prolog.org/

Java: https://apice.unibo.it/xwiki/bin/view/Tuprolog/ (also SWI, Ciao and Sicstus have Java bridges)

Go: https://github.com/ichiban/prolog

Common Lisp: https://www.cliki.net/Prolog

Racket: https://docs.racket-lang.org/racklog/

Guile: https://gitlab.com/gule-log/guile-log

Erlang: https://github.com/rvirding/erlog

Also SWI and Ciao have a pretty straight forward FFI for C.

Re: The Power of Prolog

#26
post #17

Earlier quoted context omitted.

Are there any Prolog scripting engines or embeddable runtimes? It feels like the kind of thing where you might use it to solve a small part of your problem domain and leave the rest to a conventional language.

Off the top of my head: Javascript: http://tau-prolog.org/ Java: https://apice.unibo.it/xwiki/bin/view/Tuprolog/ (also SWI, Ciao and Sicstus have Java bridges) Go: https://github.com/ichiban/prolog Common Lisp: https://www.cliki.net/Prolog Racket: https://docs.racket-lang.org/racklog/ Guile: https://gitlab.com/gule-log/guile-log Erlang: https://github.com/rvirding/erlog Also SWI and Ciao have a pretty straight forwar…

Oh nice, looks like Tau just put out a new point release last week

https://github.com/tau-prolog/tau-prolog/blob/master/RELEASE...

this looks handy https://github.com/tau-prolog/tau-prolog/issues/295

Re: The Power of Prolog

#27
post #4

Prolog is the only language that I've ever learned that feels like magic. Of course, it's not, but it feels like that. I'm still learning it, but I feel it and the logic paradigm are underused. I wonder if it's fair to consider it constraint-based programming rather than just logic programming. I used the book Thinking as Computation to learn it (and still am), and that's what it felt like we were doing in the book:…

What scenarios have you used it for?

After some time using it you understand it works for everything. Essentially, it features simpler and powerful loops and recursions. So you wrote those differently and end up writing many things differently.

That said, I used it for a simple game AI at university. My AI was the best of the class and it was something like 30 LOC. I remember thinking I would have spend 5x more time writing the same thing in C instead of 1 hour (plus some tests and play session)

Re: The Power of Prolog

#28
I have only had passing experience with Prolog, many moons ago. It feels like ... and this is hard to express without sounding like I am trivializing it ... it feels like Prolog has a pretty good future as domain-specific language as input to a library called by, well, other programming languages, but on its own, it's a "wow, that's neat" kind of language.

Re: The Power of Prolog

#29
I've been using Prolog on and off for 20+ years (I actually bought and used Turbo Prolog by Borland under MS-DOS). I have to confess though, I've never quite understood Prolog or what it's for. I've followed Markus Triska and his Power of Prolog videos (watched all of them). I'd like to thank him for his work. This fellow is super smart about programming, and he appears to be singlehandedly re-inventing Prolog. His videos are of the highest quality content. I've learned so much from his work, particularly in the area of CLP. I've now come to understand Prolog as a search language, and he's convinced me that CLP+Prolog are the next generation of Prolog as compelling tool. (I do a bunch of work in personnel scheduling/optimization and have mostly used genetic algorithms to this point. I'm seeing more and more uses of Prolog in this area thanks to Mr. Triska.)

Re: The Power of Prolog

#30
post #17

Earlier quoted context omitted.

Prolog is a deep language and can teach so you a lot. The main problem is that any prolog program bigger than, say, a thousand lines of code become difficult to debug and understand. There are ways to make things better e.g. avoid impure prolog etc. but it is still problematic. Engineers are always looking for technologies to hop onto. Prolog is niche for a reason: I don’t think Prolog scales. In some ways it is too…

Are there any Prolog scripting engines or embeddable runtimes? It feels like the kind of thing where you might use it to solve a small part of your problem domain and leave the rest to a conventional language.

May I interest you in microKanren? You can just roll your own. Here’s a shameless self-plug for a close reading I did of the paper that introduces microKanren: https://github.com/ashton314/muKanren_reading
Post reply on HN