Live data from Hacker News

Ask HN: What's Prolog like in 2024?

news.ycombinator.com

241–250 of 289 posts

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

#241
Prolog is very, very dead. I love Prolog with all my heart, but it excells at problems that are solved today much more efficiently using neuronal networks. So it's utterly obsolete.

The issue of Prolog is that you need to code your rules manually. Doing ML with Prolog is possible, but very clumsy. Better stick to Python.

Speed is irrelevant, because most problems suitable for Prolog are exponential. Implementation is irrelevant, because SWI-Prolog does all you need with good integrations, except that it's a bit slower. But that's irrelevant, see above.

Learning Prolog is a great experience for any advanced computer science student. It amazes, doesn't it?

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

#242

Don't forget the Datalog subset! In the 2000s I was interested in inference over RDF and wanted something a bit more than RDFS and OWL and found out about Datalog: https://en.wikipedia.org/wiki/Datalog There wasn't a lot of literature on it or implementations then but a few years later people realized it's a great query language for complex queries that does a great job on transitive closures, can do math (unlike OWL…

There was a massive parallel implementation of Prolog running on literally 256 processors: BA-Prolog (http://fraber.de/bap/). Unfortunately the hardware platform was abandoned some years later by Inmos.

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

#244
post #241

Prolog is very, very dead. I love Prolog with all my heart, but it excells at problems that are solved today much more efficiently using neuronal networks. So it's utterly obsolete. The issue of Prolog is that you need to code your rules manually. Doing ML with Prolog is possible, but very clumsy. Better stick to Python. Speed is irrelevant, because most problems suitable for Prolog are exponential. Implementation is…

Prolog was never good at the things they thought it would be at, like AI, which is better done by ML today, specifically often like you said, with NNs. But it turned out to be good for other things, and those use cases are still alive today, even though there are many competitors. Look at Tiobe index, Prolog's usage is constant just under 1 percent, and has been for decades. So it's good for something.

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

#245

Earlier quoted context omitted.

Sure, Erlang was prototyped on Prolog because Prolog has excellent built-in facilities for domain-specific languages: you can define new unary or binary operators along with priorities and associativity rules (you can use this to implement JSON or other expression parsing in like two lines of code, which is kindof shocking for newcomers, but comes very handy for integrating Prolog "microservices" into backend stacks)…

In The Development of Erlang Joe Armstrong says "We concluded that we would like something like Prolog with added facilities for concurrency and improved error handling". See pdf linked here - https://news.ycombinator.com/item?id=40998632

You're reading too much into that quote. This is in a section titled "early experiments". It was an initial goal.

There is a lot of historical connection to Prolog, due to the original implementation, and there are syntactic similarities and non-linear pattern matching and dynamic types and a general declarative vibe, but the actual end result of Erlang's evolution, despite the goal of "something like Prolog", is not very much like Prolog at all. Erlang is a functional language, not a logic language. Prolog is a logic language, not a functional language. General goals like in that quote can change over the decade-long development of a language.

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

#246
post #69

Earlier quoted context omitted.

> Prolog uses depth-first search and backtracking, which can lead to infinite loops if the rules are not carefully ordered Is this an issue in practice? Most languages can create programs with infinite loops, but it's easy to spot in code reviews. It's been over a decade since I encountered an infinite loop in production in the backend. Just wondering if the same is true for Prolog.

Here's an infinite loop in Prolog, getting the length of a list: length(List_of_animals, Len) Oops, List_of_animals hasn't been bound to any value, so length/2 will backtrack forever making it a longer and longer list of empty placeholders. Nothing will warn you that the variable wasn't declared because that's also a normal thing to do. Here's another, checking if something is in a list: member(cat, List_of_animals)…

> Nothing will warn you that the variable wasn't declared because that's also a normal thing to do.

Minor nitpick regarding an otherwise good answer: Prolog systems will warn you about "singleton variables", that is, variables with exactly one occurrence. This does catch the usual cases of this kind of error.

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

#247

Earlier quoted context omitted.

The domain-specific Prolog code bases you're going to create still can become large and represent a significant development effort. Prolog being an ISO standard with many conformant (or at least mostly conformant) implementations available and relatively strong mindshare and ecosystem compared to extremely niche "CP solver packages and OR-tools" (which one exactly?) significantly reduces project risks such as not bei…

I agree with your point, I just would like to point out maybe the OR-tools they meant is the one made by Google, so a specific one: https://developers.google.com/optimization

Yes that's the one sorry. I typed the comment hastily and didn't go back to edit it later.

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

#248

Earlier quoted context omitted.

At this point, why not use one of the many other CP solver packages out there and the layers on top like OR-tools?

The domain-specific Prolog code bases you're going to create still can become large and represent a significant development effort. Prolog being an ISO standard with many conformant (or at least mostly conformant) implementations available and relatively strong mindshare and ecosystem compared to extremely niche "CP solver packages and OR-tools" (which one exactly?) significantly reduces project risks such as not bei…

> extremely niche "CP solver packages and OR-tools" (which one exactly?) significantly reduces project risks such as not being able to find experts, the system not meeting functional or performance requirements, or becoming obsolete down the road. The same cannot be said for some mythical "CP solver packages and OR-tools"

"Mythical CP solver packages and OR-tools"? Lol!

Google's OR-Tools [1] has been winning golds in the MiniZinc Challenge since 2013 [2]. In 2023 it won Gold in most categories and the only Prolog to win, SICStus Prolog, took one Silver back. I'm curious where you're spending time in the community if you can word a comment like this as OR-Tools is the behemoth in this area and Prolog is the weird hacker siren call that appeals to people who certainly aren't about to publish anything novel in the space.

I say this as someone who has tinkered a lot with Prolog over the years and finds Prolog's execution model to work really well with the way I think about programming. Prolog and its hybrid solver model just isn't good enough at any one thing to make it SOTA. It's fun to tinker with, but I just don't think in 2024 it has enough to offer anyone who's not interested in the language or the WAM to make it worth exploring, especially not as an embedded constraint solver.

[1]: https://developers.google.com/optimization/

[2]: https://www.minizinc.org/challenge/

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

#249
post #231

Prolog is a really interesting language. It's like lisp in that, it's definitely worth learning very well, even if you don't find a use-case for it, because the things you learn help you think about programming in a whole new way. The prolog community is pretty active. SWI has a discourse group. There's SWISH, CLP(FD/Z), abduction via CHR (a rewrite system) or libraries like ACLP. Prolog is homoiconic, and it achieve…

You can also change the search strategy used in Prolog, ie using library(search), supporting BFS and iterative deepening. Tabling is also supported.

Another useful tool for homoiconicity is clause/2:

?- assertz((foo(X) :- append(X, _, [1,2,3]))).

true.

?- clause(foo(X), Body).

Body = append(X, _, [1, 2, 3]).

If you really like Haskell and OCaml's pattern matching, you'll probably really love Prolog. Prolog's pattern matching is much more powerful.

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

#250

Earlier quoted context omitted.

For me this kind of criticism is very familiar. It comes from theoretical computer scientists who have these purist ideological convictions about how a declarative language should look and behave, that are as unrealistic, because impossible to implement on a real-world computer, as they are uninteresting for practicing programmers because strictly a matter of aesthetics. Such critics have never made anything useable…

This comment is idiotic.

No, what's idiotic is the trite bullshit in the quote in the GP's comment- and from a logician from Aix-Marseille, no less!

Prolog is "well adapted" to the "maintenance of databases". The only reason this nonsense keeps being repeated is because Prolog programs are stored as rows in a database. It's like people look at a list of keywords, pick out "database" and go "ah, so Prolog is a language for databases". Zero understanding of what the database is in there for: because your program and your data are one.

Or take the "attempts" that "were made to improve its efficiency". What the illustrious academic is kvetching about here is the cut (!/0) an extra-logical construct used in Prolog to cut choice points (like markers in program state where execution backtracks to) and so lets the programmer control the program. Again, what we seem to have here is a bingo-card understanding of Prolog: someone wrote down the keyword "control", the academic looked at the cut and thought "ah, that's what 'control' means!". No, it means that an algorithm can be thought of as logic, that is always the same, and control, that depends on the executing machine. That's what "algorithm = logic + control" means, not that you get to cut choice points with a "control" structure.

That's what's idiotic, and btw that's the common misunderstandings that clueless Prolog "critics" have been making since forever. It's trite, tired, boring bullshit that makes it clear the "critic" has no idea what they're talking about and are just looking for something to say to show they're knowledgeable and smart.

Post reply on HN