logoalt Hacker News

upghosttoday at 3:50 AM2 repliesview on HN

Author: "Not my favorite language"

Prolog: "Mistakes were made"

As an avid Prolog fan, I would have to agree with a lot of Mr. Wayne's comments! There are some things about the language that are now part of the ISO standard that are a bit unergonomic.

On the other hand, you don't have to write Prolog like that! The only shame is that there are 10x more examples (at least) of bad Prolog on the internet than good Prolog.

If you want to see some really beautiful stuff, check out Power of Prolog[1] (which Mr. Wayne courteously links to in his article!)

If you are really wondering why Prolog, the thing about it that makes it special among all languages is metainterpretation. No, seriously, would strongly recommend you check it out[2]

This is all that it takes to write a metainterpreter in Prolog:

  mi1(true).
  mi1((A,B)) :-
          mi1(A),
          mi1(B).
  mi1(Goal) :-
          Goal \= true,
          Goal \= (_,_),
          clause(Goal, Body),
          mi1(Body).
Writing your own Prolog-like language in Prolog is nearly as fundamental as for-loops in other language.

[1] https://www.youtube.com/@ThePowerOfProlog

https://www.metalevel.at/prolog

[2] https://www.youtube.com/watch?v=nmBkU-l1zyc

https://www.metalevel.at/acomip/


Replies

schmuhblastertoday at 7:46 AM

I also have a strange obsession with Prolog and Markus Triska's article on meta-interpreters heavily inspired me to write a Prolog-based agent framework with a meta-interpreter at its core [0].

I have to admit that writing Prolog sometimes makes me want to bash my my head against the wall, but sometimes the resulting code has a particular kind of beauty that's hard to explain. Anyways, Opus 4.5 is really good at Prolog, so my head feels much better now :-)

[0] http://github.com/deepclause/deepclause-desktop

show 1 reply
goku12today at 7:02 AM

This is the sort of comment I'm on HN for. Information, especially links to appropriate resources, that only a true practitioner can offer.

show 1 reply