7 ms·
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 declarativ
by GregDavidson 2y ago
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 standard Prolog provides no way to reify the environment.
Some LP resources:
https://minikanren.org/ https://minikanren.org/
https://mercurylang.org/ https://mercurylang.org/
https://www.curry-lang.org/ https://www.curry-lang.org/
https://en.m.wikipedia.org/wiki/Constraint_logic_programming https://en.m.wikipedia.org/wiki/Constraint_logic_programming
https://logtalk.org/ https://logtalk.org/
- cess11 2y agoI take it you have some gripe with https://www.scryer.pl/clpz https://www.scryer.pl/clpz? Could you explain in more detail?
- derdi 2y ago> Prolog has poor features for abstraction That's actually what this article presents as its strength and simplicity. The straightforward choice in Prolog is to use global "who may do what" tables. In contrast, the author overengineers a Kotlin solution and then says "look, this is overengineered". I think global tables would make the Kotlin code half as long and much simpler too. > Mercury and Curry fix some of these limitations At the cost of introducing new ones. Mercury makes it effectively impossible to pass around partially instantiated structures.
- Pet_Ant 2y agoDoesn’t Mercury declare each form of a rule independently?
- upghost 2y agoRespectfully 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 https://youtu.be/h5Xy4YjCZxM [2] https://youtu.be/5KUdEZTu06o 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#discussioncomment-11691870 https://github.com/mthom/scryer-prolog/discussions/2347#disc...
- humanfromearth9 2y agoAnd I have yet to understand this.
- upghost 2y agoMaybe watch the second link I posted?
- smarx007 2y agoWell, 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.
- fifilura 2y agoI am assuming it is a close relative to Norvigs solver https://norvig.com/sudoku.html https://norvig.com/sudoku.html
- javcasas 2y agoMy 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.
- upghost 2y agoThere are multiple ways to accomplish this, but the one that is the most straightforward is to simply make an object mapping of the type you are familiar with via AVL trees[1]. Easy way to get the "this.maze" semantics. You can get global context and local context via "blackboard"[2] semantics. However quite frankly the most powerful way to do this is not obvious because it doesn't translate well to other languages: meta-interpreters[3]. [1]: https://www.scryer.pl/assoc https://www.scryer.pl/assoc [2]: https://www.scryer.pl/iso_ext.html#bb_get/2 https://www.scryer.pl/iso_ext.html#bb_get/2 [3]: https://youtu.be/nmBkU-l1zyc https://youtu.be/nmBkU-l1zyc
- rscho 2y agoHow does MiniKanren fix some limitations? MiniKanren corresponds to the purely relational subset of Prolog.
- GregDavidson 2y agoBy allowing you to use the features of the host language to complement the features of miniKanren. Having good support for multiple programming paradigms is better than trying to make one paradigm fit all needs. Poplog[1] was an earlier attempt to provide such synergies but it failed to gain market share. It's now free software so take a look! The Racket ecosystem is another approach where each module can choose a language with some of them being Prolog-like[2]. [1] https://en.m.wikipedia.org/wiki/Poplog https://en.m.wikipedia.org/wiki/Poplog [2] https://racket-lang.org/languages.html https://racket-lang.org/languages.html
- rscho 2y agoOk, but MiniKanren isn't intrinsic to Scheme. I agree Racket makes it especially easy to embed sub languages, but you could embed core relational Prolog just as well as MiniKanren. My understanding of your statement is that Scheme and MiniKanren share sexp syntax, but the same applies: you could embed an sexp-based Prolog just as well. The only remaining MiniKanren advantage is then to have a complete search strategy, this I concede.
- GregDavidson 2y agoI didn't connect miniKanren to Scheme. I said "Host Language." I did suggest the value of a multi-paradigm host language.
- fithisux 2y agoVery thankful for listing here. I think Picat also falls in this category. Also Racket and Julia have a Prolog implementation.
- qu1j0t3 2y agoNot forgetting Picat! https://www.hakank.org/picat/ https://www.hakank.org/picat/