Live data from Hacker News

Ask HN: What's Prolog like in 2024?

news.ycombinator.com

281–289 of 289 posts

Re: Ask HN: What's Prolog like in 2024?

#282
I'm fairly familiar with Prolog, from its operations & implementation, having also thaught it to students.

Something I never really grokked however is: when to reach for it?

It seems like a powerful tool for a certain class of problems, but somehow I never seem to stumble upon them.

An obvious candidate is problems that map clearly to solvers that can limp along with sub-state-of-the-art performance. Solving sudokus is the classical classroom example. But somehow again, never really ran into something that maps to that (I have worked mostly in compilers and distributed system, with a smattering of application programming (frontend/backend)).

Any ideas or anecdotes?

Re: Ask HN: What's Prolog like in 2024?

#283

Earlier quoted context omitted.

> A few dedicated clever people and idealists and dreamers talking about ontologies and building things I don't understand I was briefly deeply interested in ontologies via OWL and I suspect Prolog has the same issues that I think plague ontologies in general. They are a fantastic tool for a system complex enough to be nearly useless. Modelling an ontology for a reasonably complex domain is unreasonably difficult. No…

I had similar discussions with people that wanted to encode published research into ontologies. I would ask researchers what they think - the answer was always great idea. I would then follow up with - How would you use it? No response. I finally concluded that it would never happen. 1. No one wanted it enough to pay for it to happen. 2. There is always a turn over of ideas coming and going which can never be suffici…

How would you use it? For searches.

If I want to find something in the brain but not in bone structures. If I want to find something in a kind of cell but that have a nucleus.

They are also extremely useful for automated annotation. Your automated system may annotate with a upper term because it doesn't have enough information to be more precise. That's already a big help for a human to come and put a more precise term.

We are at a convergence of technologies, with ontologies, graphs, llms and logic programming. A lot of people were too early on this and discouraged from pursuing further by people that couldn't grasp why it was so important.

Re: Ask HN: What's Prolog like in 2024?

#284

Earlier quoted context omitted.

First, my other comments for reference; https://news.ycombinator.com/item?id=41013798 and https://news.ycombinator.com/item?id=41015406 I had explicitly stated above that "he conceived Erlang as Prolog-Ideas+Functional/Procedural+Concurrency+Fault-Tolerance." Here i am not making an equivalence between Prolog and Erlang but emphasizing the inspiration that Prolog provided for the design of Erlang (that is what is to…

>> It is in this sense that Prolog to Erlang comparisons should be understood. What I'm saying is that this is the entirely wrong thing to focus on, i.e. syntactic similarities. Prolog is a language of the logic programming paradigm, one of the first ones. Its syntax is that of (a restriction of) the first order predicate calculus. Its programs are First Order Logic theorems. Its interpreter is an automated theorem p…

You are on a completely different tangent here. To repeat myself, we are not making a equivalence comparison between Prolog and Erlang. That their computation models are different is well-known. The OP is already studying Prolog and therefore has some familiarity with its computation model. He/She is asking for advice on what more to study. What is being suggested is that since Erlang was inspired by Prolog (to whatever extent) it would be useful for the OP to study that too since it has more usage/acceptance in the industry given the concurrent/distributed architectures in vogue today.

> Knowing Erlang will not help you learn Prolog just because the syntax looks similar.

That is not what is being suggested. This is your fundamental misconception which permeates the rest of your post. The OP is already studying Prolog and is being advised to look into Erlang too in addition to that. It is not "instead of" but "in addition to" (due to the history of Erlang). Furthermore Erlog allows you to embed Prolog within Erlang giving the OP the best of both worlds.

> you won't understand that if you just stop at the syntax.

Again this is your misconception. That is not what is being suggested. Nobody in their right mind will say "stop at the syntax". But syntax is the gateway into the study of computer languages i.e. you first show the syntax and then explain its semantics. Humans learn new things using analogies/similes/metaphors/etc. Here similar syntax is a great help since it eases the cognitive load while learning new concepts. When the semantic model varies, the dissonance may not be too great and so we can better modify our mental models and understanding.

The website listing the syntax comparisons of various languages is actually pretty useful when looked at with the above viewpoint. Start with your known syntax in a language you know, see how it maps to the same/similar syntax in the language you want to study and then lookup/compare/contrast the semantics of it in both the languages. It is like a cheat-sheet while studying a proper programming language textbook.

Re: Ask HN: What's Prolog like in 2024?

#285
post #5

Prolog itself is still developed and used in various settings (mostly swi-prolog?), but other languages and logic engines solve domain specific but similar problems better (rule engines, formal proof verifiers, etc). For exploratory work it can be useful. I have tried to use it in combination will LLMs unsuccessfully, partly because the domain was not specific enough. Otherwise you need a lot of real world knowledge…

Hi! Are you Jim Hendler (or related to him), my Reagan-era AI professor from UMD? https://en.wikipedia.org/wiki/James_Hendler My Prolog programming assignment #4, a Prolog "nehcihsahA" detector (maternal uncle: a mother's brother, or any equivalent relative) seemed designed to make me hate Prolog with a passion, involving bending over backwards by defining ridiculous predicates like siblish, sibloid, relatoid, sistoi…

No. Good catch though! I am not Jim, though I have talked with him!

Re: Ask HN: What's Prolog like in 2024?

#287

Earlier quoted context omitted.

>> It is in this sense that Prolog to Erlang comparisons should be understood. What I'm saying is that this is the entirely wrong thing to focus on, i.e. syntactic similarities. Prolog is a language of the logic programming paradigm, one of the first ones. Its syntax is that of (a restriction of) the first order predicate calculus. Its programs are First Order Logic theorems. Its interpreter is an automated theorem p…

You are on a completely different tangent here. To repeat myself, we are not making a equivalence comparison between Prolog and Erlang. That their computation models are different is well-known. The OP is already studying Prolog and therefore has some familiarity with its computation model. He/She is asking for advice on what more to study. What is being suggested is that since Erlang was inspired by Prolog (to whate…

>> You are on a completely different tangent here.

I don't think so. In your comment above you keep saying that it's not about syntax, then immediately after you switch to explaining how it really is. Notice this for instance. I say:

>>> Knowing Erlang will not help you learn Prolog just because the syntax looks similar.

You say:

>> That is not what is being suggested.

Then you go on to say:

>> But syntax is the gateway into the study of computer languages i.e. you first show the syntax and then explain its semantics. Humans learn new things using analogies/similes/metaphors/etc. Here similar syntax is a great help since it eases the cognitive load while learning new concepts.

And:

>> Start with your known syntax in a language you know, see how it maps to the same/similar syntax in the language you want to study and then lookup/compare/contrast the semantics of it in both the languages. It is like a cheat-sheet while studying a proper programming language textbook.

So it's hard for me to see how you're not suggesting that syntax will help you learn Prolog, when you're arguing that syntax helps you learn a new language.

And what I'm saying is that knowing something about the syntax of Erlang will not help you learn anything about Prolog. I don't think you can accept that at all, but it's true and it's my experience of many years watching people, including myself, trying to learn Prolog using their knowledge of other languages, either their syntax or semantics. My experience includes working as a teaching assistant for a Prolog course during my PhD. The truth is that Prolog is not an easy language to learn because it works very differently than any other programming language and you won't be able to use your knowledge of any other programming language to learn it. If you want to learn Prolog you have to start by finding a way to set aside most of what you know about programming. That is very hard to do, and so it's very hard to learn Prolog, except at a very superficial level.

I appreciate that's not easy to accept without long time experience.

But I don't think we're getting anywhere with this conversation so I'll respectfully bow out and thank you for the patient and civil exchange of views.

Re: Ask HN: What's Prolog like in 2024?

#289

Earlier quoted context omitted.

You are on a completely different tangent here. To repeat myself, we are not making a equivalence comparison between Prolog and Erlang. That their computation models are different is well-known. The OP is already studying Prolog and therefore has some familiarity with its computation model. He/She is asking for advice on what more to study. What is being suggested is that since Erlang was inspired by Prolog (to whate…

>> You are on a completely different tangent here. I don't think so. In your comment above you keep saying that it's not about syntax, then immediately after you switch to explaining how it really is. Notice this for instance. I say: >>> Knowing Erlang will not help you learn Prolog just because the syntax looks similar. You say: >> That is not what is being suggested. Then you go on to say: >> But syntax is the gate…

Again, the OP is moving from Prolog -> Erlang and not the other way around. You keep repeating "So it's hard for me to see how you're not suggesting that syntax will help you learn Prolog," but that is not OPs path. Erlang evolved out of Prolog and hence some of the syntax/semantics are very similar.

To settle this once and for all; in your previous post you gave the example of assignment which actually proves my point that you can easily go from Prolog to Erlang. Why? Because the behaviour is the same in Erlang i.e. there is no assignment but only pattern-matching. You can open a Erlang shell and type in X=a, X=b and it will barf. To show it even more convincingly type in Y=1+2, Y=3 and Y=4 and it will barf only on the last line. Lhs=Rhs are pattern-matched and variables are single assignment. A person with prior exposure to Prolog already knows this and hence can easily map it to Erlang. Only people coming from imperative languages (eg. C) need to adjust their mental model of the "=" operator. When i started with Erlang years ago that was what i had to learn first but thankfully all Erlang books cover it in the introductory chapter itself. Also functions in Erlang are written as a series of clauses which are pattern-matched.

I presume you do not have experience with Erlang and so your experience with only Prolog blinds you to the similarities. I highly recommend you get a Erlang book (Joe Armstrong's book is a good one since he uses much of the terminology like "terms", "clauses" etc. from Prolog) and with the help of the cheatsheet just try out the basic syntax in the Erlang shell and see what maps to Prolog. I am quite sure that you will find it convincing.

Finally w.r.t. Prolog's computation model being based on Predicate Calculus/First-Order Logic and so the model/semantics are very important is not being denied. I myself came to Predicate Calculus from the "Program Correctness" viewpoint of Floyd/Hoare/Dijkstra and hence an quite aware of its intricacies. But for most programmers without such a background in Set theory/Relations/Logic model building takes time and so syntax is their entry point and understanding happens over a period of time with study and trial-and-error.

Post reply on HN