Live data from Hacker News

The Simplicity of Prolog

bitsandtheorems.com

21–30 of 134 posts

Re: The Simplicity of Prolog

#21

I have a long standing love affair with Prolog and frustration for its failure to grow. Prolog has poor features for abstraction and is actually not declarative enough! Prolog's limitations can be great for starting to get the paradigm but then you hit a wall. (Kind of like standard Pascal!) Mercury and Curry fix some of these limitations as does miniKanren. Integrating CLP is important yet so far always clumsy as st…

Doesn’t Mercury declare each form of a rule independently?

Re: The Simplicity of Prolog

#22
I always enjoy reading positive pieces about Prolog but without touching on the implications of the principles on display, this article may do more harm than good.

You would ask reasonable questions like, "for God's sake, why?". It feels like you wouldn't use Prolog for anything besides an intellectual game.

Regarding the why:

Some of those reasons include Definite Clause Grammars, Meta-Interpreters, 1st class constraint logic programming, reified conditionals, and term/goal expansion.

There are a lot of exciting modern advances with Prolog, especially Scryer Prolog.

Check out Power of Prolog and get your mind blown: https://youtube.com/@thepowerofprolog

Re: The Simplicity of Prolog

#23

I have a long standing love affair with Prolog and frustration for its failure to grow. Prolog has poor features for abstraction and is actually not declarative enough! Prolog's limitations can be great for starting to get the paradigm but then you hit a wall. (Kind of like standard Pascal!) Mercury and Curry fix some of these limitations as does miniKanren. Integrating CLP is important yet so far always clumsy as st…

Respectfully have to disagree. Prolog has the best features for abstraction of any language I've used, I suspect it may be near an optimal fixed point for metaprogramming expression[3]. I will say the other side of that wall is breathtaking.

Also not sure what you mean, CLP is a first class consideration in many Prologs, esp Scryer Prolog. Check these crazy demos out:

[1] https://youtu.be/h5Xy4YjCZxM

[2] https://youtu.be/5KUdEZTu06o

Just look at this Sudoku solver code (see [2] for explanation):

  sudoku(Rows) :-
        length(Rows, 9),
        maplist(same_length(Rows), Rows),
        append(Rows, Vs), Vs ins 1..9,
        maplist(all_distinct, Rows),
        transpose(Rows, Columns),
        maplist(all_distinct, Columns),
        Rows = [As,Bs,Cs,Ds,Es,Fs,Gs,Hs,Is],
        blocks(As, Bs, Cs),
        blocks(Ds, Es, Fs),
        blocks(Gs, Hs, Is).

  blocks([], [], []).
  blocks([N1,N2,N3|Ns1], [N4,N5,N6|Ns2], [N7,N8,N9|Ns3]) :-
        all_distinct([N1,N2,N3,N4,N5,N6,N7,N8,N9]),
        blocks(Ns1, Ns2, Ns3).
I have yet to see more elegant code in a general purpose language.

[3]: https://github.com/mthom/scryer-prolog/discussions/2347#disc...

Re: The Simplicity of Prolog

#24
post #11

How can I use Prolog to actually get something done, other than academic tasks? Say I want to use it as a database query language, presumably that's not going to happen, right?

No, unless you count cancer research[1], particle physics experiments[2], and government funding allocations[3].

[1]: https://dcnorris.github.io/precautionary/index.html

[2]: https://github.com/mthom/scryer-prolog/discussions/2441

[3]: https://link.springer.com/chapter/10.1007/978-981-97-2300-3_...

Regarding how, check out Power of Prolog on YouTube.

Re: The Simplicity of Prolog

#25
post #9

Earlier quoted context omitted.

Using SQL is perfectly fine. Datalog on the other hand is absurdly hard to work with.

To each their own. Others would say datalog elegant and makes it easy to compose statements whereas SQL has an ugly syntax. I mean, ORMs were invented to try to avoid writing SQL but they too have their own problems.

> SQL has an ugly syntax

Speak for yourself. I’ve always found it to be very clear and concise.

    SELECT  FROM  [[type of] JOIN other_table ON ?, …] [WHERE ? [boolean operator], …] [ORDER BY ? [DESC]] [LIMIT ?]

Re: The Simplicity of Prolog

#26
post #23

I have a long standing love affair with Prolog and frustration for its failure to grow. Prolog has poor features for abstraction and is actually not declarative enough! Prolog's limitations can be great for starting to get the paradigm but then you hit a wall. (Kind of like standard Pascal!) Mercury and Curry fix some of these limitations as does miniKanren. Integrating CLP is important yet so far always clumsy as st…

Respectfully have to disagree. Prolog has the best features for abstraction of any language I've used, I suspect it may be near an optimal fixed point for metaprogramming expression[3]. I will say the other side of that wall is breathtaking. Also not sure what you mean, CLP is a first class consideration in many Prologs, esp Scryer Prolog. Check these crazy demos out: [1] https://youtu.be/h5Xy4YjCZxM [2] https://yout…

And I have yet to understand this.

Re: The Simplicity of Prolog

#27
post #23

Earlier quoted context omitted.

Respectfully have to disagree. Prolog has the best features for abstraction of any language I've used, I suspect it may be near an optimal fixed point for metaprogramming expression[3]. I will say the other side of that wall is breathtaking. Also not sure what you mean, CLP is a first class consideration in many Prologs, esp Scryer Prolog. Check these crazy demos out: [1] https://youtu.be/h5Xy4YjCZxM [2] https://yout…

And I have yet to understand this.

Maybe watch the second link I posted?

Re: The Simplicity of Prolog

#28
post #22

I always enjoy reading positive pieces about Prolog but without touching on the implications of the principles on display, this article may do more harm than good. You would ask reasonable questions like, "for God's sake, why ?". It feels like you wouldn't use Prolog for anything besides an intellectual game. Regarding the why : Some of those reasons include Definite Clause Grammars, Meta-Interpreters, 1st class cons…

one example that changed my view of prolog was http://faculty.cooper.edu/smyth/cs225/ch7/prolog.htm (a toy compiler in prolog)

Re: The Simplicity of Prolog

#29
post #23

I have a long standing love affair with Prolog and frustration for its failure to grow. Prolog has poor features for abstraction and is actually not declarative enough! Prolog's limitations can be great for starting to get the paradigm but then you hit a wall. (Kind of like standard Pascal!) Mercury and Curry fix some of these limitations as does miniKanren. Integrating CLP is important yet so far always clumsy as st…

Respectfully have to disagree. Prolog has the best features for abstraction of any language I've used, I suspect it may be near an optimal fixed point for metaprogramming expression[3]. I will say the other side of that wall is breathtaking. Also not sure what you mean, CLP is a first class consideration in many Prologs, esp Scryer Prolog. Check these crazy demos out: [1] https://youtu.be/h5Xy4YjCZxM [2] https://yout…

My little pet peeve with prolog is the lack of context parameters (which can be thought as a type of abstraction).

For example, imagine I'm writing a maze solver. The maze solver predicate receives obviously, but it has to pass as a parameter the maze again and again to all sub-predicates. There is no concept of "current maze", like in OO you would have with this.maze, or in Haskell you would do with a reader monad. As a result, all the "internal" predicates in a module get full of parameters all they do is pass around until some final predicate uses it to do some calculation.

Either that or you do the assert/retract dance and now you have bigger problems.

Re: The Simplicity of Prolog

#30
post #23

Earlier quoted context omitted.

Respectfully have to disagree. Prolog has the best features for abstraction of any language I've used, I suspect it may be near an optimal fixed point for metaprogramming expression[3]. I will say the other side of that wall is breathtaking. Also not sure what you mean, CLP is a first class consideration in many Prologs, esp Scryer Prolog. Check these crazy demos out: [1] https://youtu.be/h5Xy4YjCZxM [2] https://yout…

And I have yet to understand this.

Well, that's why language paradigms are a thing - if you are not familiar with any language in the logic paradigm but are an expert in the OO-paradigm, this could take a little bit to wrap your head around. Triska is an excellent teacher of Prolog, be sure to check out his videos linked.
Post reply on HN