Live data from Hacker News

The Power of Prolog

metalevel.at

61–69 of 69 posts

Re: The Power of Prolog

#61
post #32

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…

I'm not familiar with Prolog and this statement sounds insane. I'm not doubting you exactly, it's just not something I can concieve. Can you provide an example of a problem that would only take a few dozen lines of Prolog which would take several thousand lines in another, "normal", language?

Basically any problem involving a complex search of a solution space is a strong candidate for the above statement. There are specialized tools for doing that in other languages, but a) they specialize on a single optimization/search topic and b) their use is generally quite complex vs. prolog.

Re: The Power of Prolog

#62
post #38

Earlier quoted context omitted.

So You are saying that there is really not much difference between prolog and lets say constraint solver written in Java (DSL on top of another language)? Because if this really true than now I understand why this language never caught on.

Oh, well, Prolog is just a good DSL for a constraint solver. Usually written in C, but you can do it on Java too. As I said, I have never seen one integrated with any language (oh, well, now I have seen Flix).

See Racklog in racket, that predates Flix by a long time.

Re: The Power of Prolog

#63

Prolog always seemed to me like a database query language that can be tricked into computation.

I was expecting a comment like this and came looking... Can someone give a couple of examples of Prolog resembling a database query language, specifically SQL if possible.

Trying not to sound contentious, but I've often thought that SQL (DDLs/DMLs/DQLs) would be a really good way to interact with systems beyond just databases/datastores. And the general tone of this topic has been about how Prolog can solve/simplify so many problems/issues. Relating some Prolog to some SQL might help me (and others) see this light that everyone seems to be talking about.

There has recently been a lot of working examples of SQL being used beyond databases; IaSQL (Infrastructure-as-SQL), KSQL (streaming SQL), so on.

Re: The Power of Prolog

#65

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?

Prolog itself does not have exponential complexity. It depends on the problem you're solving.

Re: The Power of Prolog

#66
post #44

Earlier quoted context omitted.

I have studied Prolog from time to time over the years and occasionally I run across problems where it strikes me Prolog would be useful but I've never been able to justify adding it. Lately I've encountered more offline/batch processing problems and I am planning to work on some reimplementations of my solutions in our usual languages using Prolog (as soon as I have some free time, so none too soon).

Doctor Dobb's Journal had a cool article once about using Prolog to prescribe medications, in particular avoiding conflicts with other prescriptions. It would have been in the early 2000s. According to the author, they used Prolog to rewrite the app from a tangled mess of nested if statements. After the rewrite, the rules could be managed by pharmacists instead of programmers. It seemed like a good application to me.…

That's a cool case study!

It hits right at the core of the appeal (these kind of solvers need to be designed, if you grow them organically you get the if statement from hell) and also the challenges (not many managers would run with the idea of "the users will be doing something that looks a lot like writing code").

Re: The Power of Prolog

#67

Prolog always seemed to me like a database query language that can be tricked into computation.

I would love a Prolog database query language. Itch for it every time I use SQL.

Isn't that what Datalog all about? I've only heard of it, and didn't go into the specifics, but at least this is how it was pitched to me.

Re: The Power of Prolog

#68
post #63

Prolog always seemed to me like a database query language that can be tricked into computation.

I was expecting a comment like this and came looking... Can someone give a couple of examples of Prolog resembling a database query language, specifically SQL if possible. Trying not to sound contentious, but I've often thought that SQL (DDLs/DMLs/DQLs) would be a really good way to interact with systems beyond just databases/datastores. And the general tone of this topic has been about how Prolog can solve/simplify…

https://blog.algorexhealth.com/2018/11/a-practo-theoretical-...

Re: The Power of Prolog

#69

I've been using it to try and figure out the longest consecutive bus route journey in London (648-649-651, disappointingly short) and some other bus related shenanigans - all of this was much easier than using pretty much anything else. But on the other hand, it can be really faffy to figure out why your recursive list printer is failing halfway through and restarting three items back...

Just realised I typed 648-649-651 which makes no sense as a consecutive route. It should be 648-649-650-651 instead.
Post reply on HN