7 ms·
Learn X in Y minutes Where X=Prolog
- 7thaccount 7y agoI think the Adventures in Prolog book is the best way to learn where you code up a text adventure game. It made things click much better than any tutorial for me. In general though I really like "learn x in y" as a resource. I like the concept of Prolog too, but to me it makes very hard things easier and easy things hard. So it doesn't make sense in many situations to use.
- balthasar 7y agoWhat is y?
- ben-schaaf 7y agoI think you have to learn prolog to find out.
- sansnomme 7y agoNo.
- msla 7y agoStop joking or someone's going to cut you. (That pun wasn't very satisfying, was it?)
- DonHopkins 7y agoHow many Prolog programmers does it take to change a lightbulb? false. https://www.j-paine.org/dobbs/prolog_lightbulb.html https://www.j-paine.org/dobbs/prolog_lightbulb.html
- ngcc_hk 7y agoIt is a serious good articles to summarise certain language
- sansnomme 7y agoMost of the Prolog books are thick academic textbooks, for a more modern take with YouTube videos, take a look at https://www.metalevel.at/prolog https://www.metalevel.at/prolog
- 7thaccount 7y agoOr Adventures in Prolog.
- JadeNB 7y agoFor textbooks, The Art of Prolog is highly accessible (https://mitpress.mit.edu/books/art-prolog https://mitpress.mit.edu/books/art-prolog), and The Craft of Prolog (https://mitpress.mit.edu/books/craft-prolog https://mitpress.mit.edu/books/craft-prolog) is not really appropriate for self instruction but is simply a delight to read (and you'll learn a lot of really, perhaps sometimes excessively, clever Prolog by reading it).
- simplify 7y agoAnother good resource is this Prolog text adventure game. Helped a lot of things click for me. https://gist.github.com/JosephLenton/3191695 https://gist.github.com/JosephLenton/3191695
- piadodjanho 7y agoWhat are the differences from Prolog for a constraint programing language such MiniZinc?
- 7thaccount 7y agoMiniZinc is a generic language and IDE for optimization problems. You can hook into a variety of solvers (LP, MILP, Nonlinear, and some kind of like Prolog). The solvers have to be able to read the the flatzinc file type that MiniZinc exports if they don't support native hooks.
- yaantc 7y agoMiniZinc is a purely declarative problem description language. It's a way to describe a problem once, and feed it to different solvers easily. You can provide hints for the search, but there is no more control on the solving process. Prolog is a "full" language. You can program any search strategy you want with it. I'd recommend starting with MiniZinc first, as it's easier. If it's not enough and you need to customize the search strategy then once can move to Prolog, particularly a modern one with constraint support.
- piadodjanho 7y agoAny suggestion on what Prolog to use?
- yaantc 7y agoEclipse CLP (no relation to the IDE ;) has good built-in support and can also interface to many external solvers. It's open source. https://eclipseclp.org/ https://eclipseclp.org/
- punnerud 7y agoI have been thinking of Prolog as SQL, but the “goals” are your data generator/table and the constraints are everything in there WHERE-clause. Made it simpler to reason about. Learning Erlang was also easier when I figured out that it is (was?) build on Prolog, with its analogy to SQL.
- FreeFull 7y agoThere is a subset of Prolog called Datalog, explicitly designed for use in databases. Datalog queries are guaranteed to terminate, and unlike Prolog it is fully declarative (order of declarations doesn't matter).
- slifin 7y agoDatalog is implemented in many Clojure(Script) databases if you'd like to try it out, Datahike is my favourite for dev/learning use but Crux, Datomic, Datascript and others exist
- felixyz 7y agoI think it's very useful to think of Prolog more as a simple database with a very powerful query language, for people who are already familiar with some programming languages and SQL databases. It's a better angle to come at it and understand the unique properties of Logic Programming.
- felixyz 7y agoRegarding Erlang, yes early versions were implemented on top of Prolog and the heritage is there for sure. Joe Armstrong talked fondly about Prolog in later years as well. For example, he described Elixir’s beloved pipe operator like this: > This is the recessive monadic gene of Prolog. The gene was dominant in Prolog, recessive in Erlang (son-of-prolog) but re-emerged in Elixir (son-of-son-of-prolog). (He was referring to so-called definite clause grammars (DCG) in Prolog.)
- Gene_Parmesan 7y agoIn terms of Erlang, my understanding is it began life as a modified Prolog, implemented in Prolog, around '86. But by the end of the decade Joe had created JAM, Joe's Abstract Machine, with others writing a runtime in C and the libraries. Nowadays Erlang runs on BEAM, which has since been improved and heavily optimized.
- fizixer 7y agoI'm told Prolog is the old way. miniKanren (by William Byrd et. al.) is trending for many years though I'd like to know what's fundamentally new about it. The fact that Byrd later worked on constraint'ed miniKanren (cKanren) means miniKanren is not as powerful? His recent talk about using it with Barliman frontend was pretty cool [1] [1] https://www.youtube.com/watch?v=RVDCRlW1f1Y https://www.youtube.com/watch?v=RVDCRlW1f1Y
- 7thaccount 7y agoI always thought minikanren was just a toy Prolog implemented in Lisp and then other languages.
- hyperpape 7y agoDefinitely not the intent: http://minikanren.org/minikanren-and-prolog.html http://minikanren.org/minikanren-and-prolog.html. (I also doubt it's the result, though I've not done enough with either language to comment too much).
- 7thaccount 7y agoI read the article and small/minimal...etc isn't that much different than a toy in some respects, but see your point of intent. I've seen a few implementations and didn't get the feeling of "production worthiness".
- deleted 7y ago[deleted]
- overlords 7y agoConstraint programming is the new way, with Minizinc as the language. OR-tools from google is the best current solver. https://www.minizinc.org/ https://www.minizinc.org/
- e12e 7y agoDoes anyone know if there's a datalog-like embeddable language that is suitable for simple integer constraints (the sum of a, b, c, and d must be e; e=10.,b>2.)? For prolog, there's apparently https://github.com/triska/clpz/ https://github.com/triska/clpz/ But I really just want some simple constraints-oriented form validation (you have 100 points, please feel free to by x's for 1 point each, y's for a cost of 5 points. You don't have to spend all points - with feedback of how many points are left as more x and y are bought. But for more variables, where there are clear rules that can be modeled naturally as constraints rather than with state and callbacks on change). Ed: specifically for forms, there's https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML... - but it feels like it gets messy with interdependent fields.
- felixyz 7y agoIf your main use case is browser form validation, have a look at Tau Prolog. It doesn't have constraint library but standard Prolog should be enough for something like this. http://tau-prolog.org/ http://tau-prolog.org/ The newly released Yarn 2 uses Tay Prolog to implement constraints on package versions and usage: https://github.com/yarnpkg/berry/tree/master/packages/plugin-constraints/sources https://github.com/yarnpkg/berry/tree/master/packages/plugin...
- schoen 7y agoYou might like a Satisfiability Modulo Theories (SMT) solver such as Z3. https://github.com/Z3Prover/z3 https://github.com/Z3Prover/z3 It has bindings for other languages and is able to make some rather sophisticated arithmetical and logical deductions in an often pretty efficient way. I've used it successfully for parts of puzzle competitions and CTFs (and I'm really only beginning to scratch the surface of what it can do). You can read more about the options in that area at https://en.wikipedia.org/wiki/Satisfiability_modulo_theories https://en.wikipedia.org/wiki/Satisfiability_modulo_theories which also links to the related tools in https://en.wikipedia.org/wiki/Answer_set_programming https://en.wikipedia.org/wiki/Answer_set_programming https://en.wikipedia.org/wiki/Constraint_programming https://en.wikipedia.org/wiki/Constraint_programming These systems can feel pretty magical and are getting more powerful all the time. (Of course there are cases where there is a better algorithm that you could find, perhaps a much more efficient one, and using these solvers will be asymptotically or worst-case slower than it had to be given more human insight.) Some of these could be overkill for your application, and Z3 doesn't have a Javascript binding, so I guess it's not as helpful for web forms.
- YeGoblynQueenne 7y agoThis is horrible! Prolog is nothing like the language described in this "tutorial". The author has completely made up a bunch of programming language semantics that have nothing to do with Prolog. Just for the most blatant example of made-up semantics: unification is not "essentially a combination of assignment and equality". Unification is not assignment: Prolog predicates are immutable. You can't assign to an immutable data structure. Unification is not equality, either. For example, in Prolog 2 = 1+1 fails because "2" does not unify with "1+1" (and not because "unification can't do arithmetic"; it's because unification is not equality). Unification is an algorithm to decide whether two Horn clauses can be resolved with each other. Resolution is the inference rule used in Prolog's automated theorem proving. This is it: ¬p ∨ q, p ---------- q The horizontal line is read as "entails". p and q are predicates. The rule says that if we can show that p is false or q is true and that p is true, then we can show that q is true. If ¬p and p unify, they can be resolved and q can be shown to be true. Resolution is used in Prolog to prove a query by refutation. Queries are the goals that the author calls "commands". These are not commands: they are predicates, just like "facts" and "rules". Prolog tries to disprove a goal by finding a clause with a head literal that unifies with the query (only "facts" and "rules" have heads, whereas goals only have bodies). If it can, it then recursively proves each literal in the body of the clause, by finding a clause with a head that unifies with the literal. Unfortunately, none of this will make sense if you try to understand Prolog in terms of assignment and equality tests, and so on. Reading this article and trying to "learn Prolog in Y minutes" will only serve to confuse any further attempts to understand and learn the language.
- dang 7y ago> This is horrible! Normally moderators would downweight a submission when this is the consensus from knowledgeable commenters. But this thread is so good that I want to leave it up. Edit: Should we change the link to https://www.j-paine.org/dobbs/prolog_lightbulb.html https://www.j-paine.org/dobbs/prolog_lightbulb.html (via the inimitable DonHopkins at https://news.ycombinator.com/item?id=22242854 https://news.ycombinator.com/item?id=22242854)? It hasn't been discussed on HN before.
- 7y ago
- The_mboga_real 7y agoLeArN x In Y mInUtEs, WhErE x=PrOlOg
- xena 7y agoWhat is a good web framework or library for Prolog?
- DonHopkins 7y agoI always wanted to write a compiler whose front-end consumes Prolog and back-end emits PostScript, and call it "PrologueToPostscript". prologue: a separate introductory section of a literary, dramatic, or musical work. postscript: an additional remark at the end of a letter, after the signature and introduced by ‘PS’.