Learn Prolog Now
40 comments
·November 12, 2025ux266478
Prolog really is such a fantastic system, if I can justify its usage then I won't hesitate to do so. Most of the time I'll call a language that I find to be powerful a "power tool", but that doesn't apply here. Prolog is beyond a power tool. A one-off bit of experimental tech built by the greatest minds of a forgotten generation. You'd it find deep in irradiated ruins of a dead city, buried far underground in a bunker easily missed. A supercomputer with the REPL's cursor flickering away in monochrome phosphor. It's sitting there, forgotten. Dutifully waiting for you to jack in.
lmf4lol
When I entered university for my Bachelors, I was 28 years old and already worked for 5 or 6 years as a self-taught programmer in the industry. In the first semester, we had a Logic Programming class and it was solely taught in Prolog. At first, I was mega overwhelmed. It was so different than anything I did before and I had to unlearn a lot of things that I was used to in "regular" programming. At the end of the class, I was a convert! It also opened up my mind to functional programming and mathematical/logical thinking in general.
I still think that Prolog should be mandatory for every programmer. It opens up the mind in such a logical way... Love it.
Unfortunately, I never found an opportunity in my 11 years since then to use it in my professional practice. Or maybe I just missed the opportunities?????
samuell
I love Prolog, and have seen so many interesting use cases for it.
In the end though, it mostly just feels enough of a separate universe to any other language or ecosystem I'm using for projects that there's a clear threshold for bringing it in.
If there was a really strong prolog implementation with a great community and ecosystem around, in say Python or Go, that would be killer. I know there are some implementations, but the ones I've looked into seem to be either not very full-blown in their Prolog support, or have close to non-existent usage.
mattbettinson
In university, Learning prolog was my first encounter with the idea that my IQ may not be as high as I thought
vidarh
I also found it mindbending.
But some parts, like e.g. the cut operator is something I've copied several times over for various things. A couple of prototype parser generators for example - allowing backtracking, but using a cut to indicate when backtracking is an error can be quite helpful.
chanux
I thoroughly enjoyed doing all the exercises. It was challenging and hence, fun!
I don't think I ever learned how it can be useful other than feeding the mind.
ge96
intro to quantum physics for me (which is only sophomore) I noped out of advanced math/physics at that point, luckily I did learn to code on my own
droningparrot
I had more success with the Prolog language track on https://exercism.org/tracks/prolog
It's a mind-bending language and if you want to experience the feeling of learning programming from the beginning again this would be it
_spduchamp
I remember a project I did in undergrad with Prolog that would fit connecting parts of theoretical widgets together based on constraints about how different pieces could connect and it just worked instantly and it felt like magic because I had absolutely no clue how I would have coded that in Pascal or COBOL at that time. It blew my mind because the program was so simple.
waynecochran
I remember writing a Prolog(ish) interpreter in Common Lisp in an 90's AI course in grad school for Theorem proving (which is essentially what Prolog is doing under the hood). Really foundational to my understanding of how declarative programming works. In an ideal world I would still be programming in Lisp and using Prolog tools.
travisgriggs
> In an ideal world…
I see this sentiment a lot lately. A sense of missed nostalgia.
What happened?
In 20 years, will people reminisce about JavaScript frameworks and reminisce how this was an ideal world??
zemptime
I've recently started modeling some of my domains/potential code designs in Prolog. I'm not that advanced. I don't really know Prolog that well. But even just using a couple basic prolog patterns to implement a working spec in the 'prolog way' is *unbelievably* useful for shipping really clean code designs to replace hoary old chestnut code. (prolog -> ruby)
ramses0
I keep wishing for "regex for prolog", ie: being able to (in an arbitrary language) express some functional bits in "prolog-ish", and then be able to ask/query against it.
let prologBlob = new ProLog()
prologBlob.add( "a => b" ).add( "b => c" )
prologBlob.query( "a == c?" ) == True
(not exactly that, but hopefully you get the gist)There's so much stuff regarding constraints, access control, relationship queries that could be expressed "simply" in prolog and being able to extract out those interior buts for further use in your more traditional programming language would be really helpful! (...at least in my imagination ;-)
svieira
You might be interested in Flix:
https://play.flix.dev/?q=PQgECUFMBcFcCcB2BnUBDUBjA9gG15JtAJb...
is an embedded Datalog DB and query in a general-purpose programming language.
More examples on https://flix.dev/
dflock
There are a bunch of libraries that will do this - here's one example of a python one: https://github.com/yuce/pyswip - and a ruby one: https://github.com/preston/ruby-prolog
dragonwriter
While usually using native syntax rather than strings, somethign like that exists for most languages of any popularity (and many obscure ones), in the form of miniKanren implementations.
zemptime
I've wished for the same kind of 'embed prolog in my ruby' for enumerating all possible cases, all invalid cases, etc in test suites. Interesting to know it's not just me!
dflock
There are a bunch of libraries that will do this - here's one example of a python one: https://github.com/yuce/pyswip - and a ruby one: https://github.com/preston/ruby-prolog
naasking
Maybe try a Ruby Kanren implementation:
uKanren is conceptually small and simple, here's a Ruby implementation: https://github.com/jsl/ruby_ukanren
ecshafer
I really enjoyed learning Prolog in university, but it is a weird language. I think that 98% of tasks I would not want to use Prolog for, but for that remaining 2% of tasks it's extremely well suited for. I have always wished that I could easily call Prolog easily from other languages when it suited the use case, however good luck getting most companies to allow writing some code in Prolog.
rootnod3
That is where Lisp or Scheme weirdly shines. It is incredibly easy to add prolog to a Lisp or a Scheme. It’s almost as if it comes out naturally if you just go down the rabbit hole.
“The little prover” is a fantastic book for that. The whole series is.
arein3
We had it in university courses and it seemed useless. DSL for backtracking.
echelon
There are declarative languages like SQL and XSLT.
And then there are declarative languages like Prolog.
jackallis
is prolog a use-case language or is it as versatile as python?
qsort
Python wins out in the versatility conversation because of its ecosystem, I'm still kinda convinced that the language itself is mid.
Prolog has many implementations and you don't have the same wealth of libraries, but yes, it's Turing complete and not of the "Turing tarpit" variety, you could reasonably write entire applications in SWI-Prolog.
WillAdams
Right, Python is usually the second-best choice for a language for any problem --- arguably the one thing it is best at is learning to program (in Python) --- it wins based on ease-of-learning/familiarity/widespread usage/library availability.
ux266478
Personally I find Python more towards the bottom of the list with me, despite being the language I learned on. Especially if the code involved is "pythonic". Just doesn't jive with my neurochemistry. All the problems of C++ with much greater ambiguity, and I've never really been impressed with the library ecosystem. Yeah there's a lot, but just like with node it's just a mountain of unusably bad crap.
I think lua is the much better language for a wide variety of reasons (Most of the good Python libraries are just wrappers around C libraries, which is necessary because Python's FFI is really substandard), but I wouldn't reach for python or lua if I'm expecting to write more than 1000 lines of code. They both scale horribly.
ecshafer
I don't know if I would say its second-best. It just happened to get really popular because it has relatively easy syntax, and Numpy is a really great library making all of those scientific packages that people were using Fortran and C++ for before available in an easier language. This boosted the language, right when data science became a thing, right when dynamic programming became popular, right when there was a boost in Learn 2 Code forget about learning fundamentals was a thing. Its an okay language I guess, but I really think it was lucky that Numpy exists and Numby or Numphp.
aeonik
More like 3rd to 5th best is most categories. There's just a lot of categories.
Its ease of use and deployment give it a lot more staying power.
The syntax is also pretty nice.
zimpenfish
In theory, it's as versatile as Python et al[0] but if you're using it for, e.g., serving bog-standard static pages over HTTP, you're very much using an industrial power hammer to apply screws to glass - you can probably make it work but people will look at you funny.
[0] Modulo that Python et al almost certainly have order(s) of magnitude more external libraries etc.
bigfishrunning
> you can probably make it work but people will look at you funny
Don't threaten me with a good time
I am once again shilling the idea that someone should find a way to glue Prolog and LLMs together for better reasoning agents.
https://news.ycombinator.com/context?id=43948657
Thesis:
1. LLMs are bad at counting the number of r's in strawberry.
2. LLMs are good at writing code that counts letters in a string.
3. LLMs are bad at solving reasoning problems.
4. Prolog is good at solving reasoning problems.
5. ???
6. LLMs are good at writing prolog that solves reasoning problems.
Common replies:
1. The bitter lesson.
2. There are better solvers, ex. Z3.
3. Someone smart must have already tried and ruled it out.
Successful experiments:
1. https://quantumprolog.sgml.net/llm-demo/part1.html