4 ms·
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 so
by upghost 9mo ago
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.youtube.com/@ThePowerOfProlog
https://www.metalevel.at/prolog https://www.metalevel.at/prolog
[2] https://www.youtube.com/watch?v=nmBkU-l1zyc https://www.youtube.com/watch?v=nmBkU-l1zyc
https://www.metalevel.at/acomip/ https://www.metalevel.at/acomip/
- goku12 9mo agoThis is the sort of comment I'm on HN for. Information, especially links to appropriate resources, that only a true practitioner can offer.
- schmuhblaster 9mo agoI 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 http://github.com/deepclause/deepclause-desktop
- kamaal 9mo ago>>I have to admit that writing Prolog sometimes makes me want to bash my my head against the wall I think much of the frustration with older tech like this comes from the fact that these things were mostly written(and rewritten till perfection) on paper first and only the near-end program was input into a computer with a keyboard. Modern ways of carving out a program with 'Successive Approximations' with a keyboard and monitor until you get to something to work is mostly a recent phenomenon. Most of us are used to working like this. Which quite honestly is mostly trial and error. The frustration is understandable because you are basically throwing darts, most of the times in the dark. I knew a programmer from the 1980s who(built medical electronics equipment) would tell me how even writing C worked back then. It was mostly writing a lot, on paper. You had to prove things on paper first.
- schmuhblaster 9mo ago>> I think much of the frustration with older tech like this comes from the fact that these things were mostly written(and rewritten till perfection) on paper first and only the near-end program was input into a computer with a keyboard. I very much agree with this, especially since Prolog's execution model doesn't seem to go that well with the "successive approximations" method.
- kamaal 9mo agoBefore personal computer revolution, compute time and even development/test time on a large computers back then was rationed. One can imagine how development would work in a ecosystem like that. You have to understand both the problem, and your solution, and you need to be sure it would work before you start typing it out at a terminal. This the classic Donald Knuth workflow. Like he is away disconnected from a computer for long periods of time, focussed on the problems and solutions, and he is working them out on paper and pen. Until he has arrived solutions that just work, correctly. And well enough to be explained in a text book. When you take this away. You also take away the need to put in hard work required to make things work correctly. Take a look at how many Java devs are out there who try to use a wrong data structure for the problem, and then try to shoe horn their solution to roughly fit the problem. Eventually solution does work for some acceptable inputs, and remainder is left to be discovered by an eventual production bug. Stackoverflow is full of such questions. Languages like Prolog just don't offer that sort of freedom. And you have to be in some way serious about what you are doing in terms of truly understanding both the problem and solution well enough to make them work.