8 ms·
Learn Prolog Now
- dang 8y agoA discussion from 2015: https://news.ycombinator.com/item?id=9246897 https://news.ycombinator.com/item?id=9246897 And one from 2010: https://news.ycombinator.com/item?id=1976127 https://news.ycombinator.com/item?id=1976127
- njn 8y agoI was going through this recently because my brother is going through the CS program that I went through, which is the only time I've encountered anyone mention Prolog. I still can't really envision how to create comprehensive systems in this, but it seems the logic paradigm could be applied to some really useful new areas that it hasn't reached yet, similar to how the influence of functional languages is pretty much expected for any trendy new language today (Rust, ES6).
- Koshkin 8y agoI think it helps to think of Prolog as something similar to SQL. See, for example, https://stackoverflow.com/questions/2117651/comparing-sql-and-prolog https://stackoverflow.com/questions/2117651/comparing-sql-an....
- tom_mellior 8y agoIt doesn't really help to think that way. The accepted answer to that StackOverflow question sounds very much like the poster didn't really know what Prolog is (and possibly confused it with Datalog). Here is code to append two lists in Prolog: append([], Xs, Xs). append([X|Xs], Ys, [X|Zs]) :- append(Xs, Ys, Zs). You can use this as follows ("?-" is the user input prompt, equations are the system's answers): ?- append([a,b], [c,d], Zs). Zs = [a, b, c, d]. ?- append(Xs, Ys, [a,b,c]). Xs = [],Ys = [a, b, c] ; Xs = [a],Ys = [b, c]; Xs = [a, b],Ys = [c]; Xs = [a, b, c],Ys = []. How would you express the notion of lists in SQL? How would you express the notion of appending two lists? And how would you express the notion of searching for all possible pairs of lists that, when appended, yield the list [a,b,c]?
- ausjke 8y agofor expert system prolog is the king
- marcosdumay 8y agoYes. But others (like Haskell) aren't much behind.
- vmchale 8y ago> the influence of functional languages is pretty much expected for any trendy new language today (Rust Rust is barely influenced by functional languages.
- nemaar 8y ago>Rust is barely influenced by functional languages. That is arguable. Rust supports and in a lot of ways prefers functional solutions for problems, for example the iterator trait in std and a gazillion similar library APIs. Functional programming works very well with Rust's type system.
- mrccc 8y agoA friend of mine wrote a Chrome extension for better styling: https://chrome.google.com/webstore/detail/learn-prolog-now-enhanced/gojfoljalmhohccaganmbgbffmfffhcg https://chrome.google.com/webstore/detail/learn-prolog-now-e...
- deleted 8y ago[deleted]
- yardie 8y agoWow. I wish this existed when I was in middles school, trying to write science fair project in prolog. It sent me down an academic rabbit hole that was way above my depth of knowledge. And the books I could find were really dry academic oriented. But I powered through and wrote a prolog program to help identify poisons.
- xte 8y agoNice! I've study a super-little-bit prolog at university time but I do not really understand it... I still have to understand "why prolog?" at all but perhaps sooner or later I'll try to review it a bit with this site-book :-)
- arthurcolle 8y agoProlog is great for a thing called constraint satisfaction. You define a bunch of predicates, which may or may not have meaning in the implicit dependencies, and then the language is able to extract logical relationships between those atoms in these defined predicates. You might have had an instructor who himself hadn't really mastered the language, or maybe he didn't grok it - because it's very beautiful and intuitive when its laid out properly. It was the language I picked up the fastest in all of my coursework, just super elegant and bare bones. OT, but another point to note is that the original Erlang VM and interpreter was implemented in Prolog, which (because of Joe Armstrong's affinity for the language) might be why there are so many subtle syntactical similarities between the two languages. This tutorial does a pretty good job at first glance, but I feel like there could be some more sophisticated examples that more concretely illustrate why it's such a powerful technique to use
- ineedasername 8y agoYes, I remember that Prolog was suppose to be good with semantic applications, but I thought Lisp was similarly (if not quite as well) suited along with being better in other respects. Though it is interesting (as I learned from another comment) that a variant of prolog is used as a database query language. It does seem like a very nice fit.
- xte 8y agoWell I (not really) "learn" for a side course just to get some extra credits (I do not know if this mechanism exists outside western EU) so... I can practically say that I only have seen it's syntax and play with it at a so ignorant level that I do not really understand it's motivations... Constraint satisfaction to my eyes seems a bit of an obscure concept that is substantially present in any functional programming language, however since prolog is still there and popup regularly I understand that it's me that miss something and so I'm curious and perhaps sooner or later I'll try to reread docs and try to really understand while keep it a bit down in my priority list...
- qwerty456127 8y agoWhy? No, really, subjectively Prolog looks lovely to me, but sort of "Chapter 0" explaining why should people learn Prolog and how they can apply it practically could make an awesome addition.
- worldsayshi 8y agoYes. I'd love to know more about real world use cases.
- tom_mellior 8y agohttps://en.wikipedia.org/wiki/Amadeus_IT_Group https://en.wikipedia.org/wiki/Amadeus_IT_Group More than 200 million airline bookings, 850 million total (travel and hotel) bookings per year. They are known to run their airline reservation system on Sicstus Prolog, though I don't know how well that is publicly documented in writing.
- deleted 8y ago[deleted]
- YeGoblynQueenne 8y agoWhy learn something new? To increase your knowledge. If that's not reason enough then nothing else is.
- ineedasername 8y agoThat's an ungenerous interpretation of the question. Consider this variation: Why learn Prolog instead of spending the finite commodity of time to learn something that may be equally engaging on an intellectual level but also more practical? To me, that variation is implicit within such a question. Edit: I'm reasoning from the HN comment guidelines [0]: "Please respond to the strongest plausible interpretation of what someone says, not a weaker one that's easier to criticize. Assume good faith." This guideline is in fact a restatement of one of the fundamental principles of reasoned discourse, the principle of charity [1] [0] https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html [1] https://en.wikipedia.org/wiki/Principle_of_charity https://en.wikipedia.org/wiki/Principle_of_charity
- ghufran_syed 8y agoDatalog is a form of prolog, used currently by a database called datomic as it's query language. If you wanted to play with datalog, the best way is to do the free tutorial at www.learndatalogtoday.org you don't need to anything about datomic or clojure in order to do the tutorial, and I found it really helpful to get an idea of how it would be really helpful for certain types of queries, compared to an analogous query in SQL (which I also like btw...) [Edit] - funny, someone just posted this other tutorial to HN too, haven't done it yet but looks fun and educational, it's a murder mystery! https://xmonader.github.io/prolog/2018/12/21/solving-murder-prolog.html https://xmonader.github.io/prolog/2018/12/21/solving-murder-...
- slifin 8y agoAll my upvotes, it's criminal how under hyped Datomic is Hyperfiddle is a paradigm shift on the front end too, using the same concepts, imagine real time GraphQL on steroids where the query doesn't need a horrible SQL translation on the backend and that doesn't even begin to cover it, no worrying about multiple round trips, SQL injection gone, cache invalidation solved, supports recursion, nested data Everyone outside of Clojure/Datomic should be looking in for things to steal
- brudgers 8y agoDatomic's popularity is constrained by the decision to make it closed source commercial software. That's not a knock. It's not saying Datomic is not worth the money. Profitability in exchange for popularity is a very reasonable decision. The decision not to play around with the free version of proprietary software is also reasonable. Vendor lock-in is a trade off many developers are not interested in making.
- pkteison 8y agoThe thing that intrigued me the most about Prolog was that true and false are not opposites. True means it could prove it, but false means it couldn’t prove it in time, not strictly necessarily really false as in not true. Thinking about that distinction, that you can have a language where the default logic can’t be used for Boolean algebra, blew my mind when I was in college and has been fun to ponder ever since.
- taneq 8y agoSounds more like true and null? Or does it not definitively disprove things?
- YeGoblynQueenne 8y agoProlog uses the closed world assumption: if something cannot be proven, it is considered false. https://en.wikipedia.org/wiki/Closed-world_assumption https://en.wikipedia.org/wiki/Closed-world_assumption
- tom_mellior 8y agoThe parent is mistaken. A "false" answer definitely means that no (further) solution exists. You can ask for time or depth limits in practical Prologs, but in basic standard Prolog "false" doesn not mean "could not prove it in time". Of course some things cannot be disproven, and in those cases (again, if you don't request otherwise) you will get nontermination.
- xvilka 8y agoThere is also more modern Power of Prolog[1][2]. Another interesting language is ProbLog[3] - Probabilistic Prolog, seems used in bioinformatics. [1] https://www.metalevel.at/prolog https://www.metalevel.at/prolog [2] https://github.com/triska/the-power-of-prolog https://github.com/triska/the-power-of-prolog [3] https://dtai.cs.kuleuven.be/problog/ https://dtai.cs.kuleuven.be/problog/
- mathnmusic 8y agoAlso, there is MiniZinc: https://www.minizinc.org/ https://www.minizinc.org/
- justbaker 8y agoI tried swipl prolog and enjoyed it but poor PostgreSQL support scared me away. Any prolog developers have any advice? I really like prolog but need an implementation with good db support for specifically Postgres but haven’t found anything.
- YeGoblynQueenne 8y agoYou don't need SQL if you have Prolog. Prolog itself can store and retrieve all your data, except that data is also your program at the same time. For instance, see: Can I replace a LAMP stack with SWI-Prolog? http://www.swi-prolog.org/FAQ/PrologLAMP.html http://www.swi-prolog.org/FAQ/PrologLAMP.html
- justbaker 8y agoThis is a really great answer, thank you.
- YeGoblynQueenne 8y agoCheers. Note also that you can relatively easily move all your SQL tables to Prolog by exporting them as text files with Prolog facts of the form: <table_name>(<column 1, row 1>, <column 2, row 1>, ...., <column n, row 1> ) ... <table_name>(<column 1, row m>, <column 2, row m>, ...., <column n, row m> ) So each table becomes a predicate with the table name as its predicate symbol ("functor" in Prolog), the number of the columns in the table as its arity (the number of arguments of the predicate) and where each row of the table is a separate clause of the predicate. Many tables exported this way will not be necessary any more, particularly those ubiquitous tables used to map other tables' keys between them ("Customer_ID_Ticket_Id" etc) and in most cases primary key fields will no longer be necessary and so on- but you can move all your data to Prolog, with very little change, is what I'm trying to say. Mer' Christmas :)
- justbaker 8y agoNice! That gives me faith for using it for my personal projects. I enjoyed erlang when I programmed in it in my fledgling days and I like the tenseness of the prolog-influenced languages. Having a very easy way to port to a platform(or off, sometimes) is certainly a valid concern of mine when choosing my tooling. Merry Christmas to you as well :)
- momofarm 8y agoSo for the end of year 2018, is there still people using Prolog in profession field instead of academic?
- jonahx 8y agoFor those wanting to kill the "learn logic programming" and "learn a golfing language" birds with one stone, check out: https://github.com/JCumin/Brachylog https://github.com/JCumin/Brachylog
- tjpnz 8y agoProlog is a language I have fond memories of but haven't touched in a long time. How applicable is it outside of academia given all of the alternatives?
- eismcc 8y agoSWI-Prolog to WebAssembly: https://github.com/JanWielemaker/swi-prolog-wasm/blob/master/README.md https://github.com/JanWielemaker/swi-prolog-wasm/blob/master...
- User23 8y agoI quite enjoy watching successive generations of programmers rediscover prolog in particular and rule-based programming in general. It's well worth learning even if you never really use it, because it expands your understanding of the art.
- me2too 8y agoThis is the website I used to learn Prolog and all I can do is to highly recommend it
- raphinou 8y agoI dived into prolog this year, and I really liked it. However, I didn't find a very active community to answer questions. The lack of energy in the community, and my wondering where I could use prolog for a practical application, tempered my enthousiasm, and I switched to learning something else (category theory).
- tu7001 8y agoWhat sources do you have to learn category theory?
- raphinou 8y agoI watched Bartosz Milewski's videos https://m.youtube.com/playlist?list=PLbgaMIhjbmEnaH_LTkxLI7FMa2HsnawM_ https://m.youtube.com/playlist?list=PLbgaMIhjbmEnaH_LTkxLI7F... The pdf generated from his blog is also interesting : https://github.com/hmemcpy/milewski-ctfp-pdf https://github.com/hmemcpy/milewski-ctfp-pdf These are the best resources I found about the subject.
- tu7001 8y agoVideos are awesome, I started watching them and ended up binge watching!
- IceDane 8y agohttps://github.com/hmemcpy/milewski-ctfp-pdf https://github.com/hmemcpy/milewski-ctfp-pdf
- tu7001 8y agoThanks.
- deleted 8y ago[deleted]
- segmondy 8y agoCheckout the prolog channel on freenet
- aindriu80 8y agoback in the day !!