31 ms·
Why Learn Prolog in 2021?
- dgb23 6y agorelated: https://github.com/clojure/core.logic/wiki/A-Core.logic-Primer https://github.com/clojure/core.logic/wiki/A-Core.logic-Prim...
- bra-ket 6y agowhat are some good resources to learn Prolog
- Jtsummers 6y agoHere are some resources: https://github.com/klaussinani/awesome-prolog#resources https://github.com/klaussinani/awesome-prolog#resources I recall going through the Adventure in Prolog one (free online resource) a while ago and enjoying it, helped direct a lot of exploration into the Prolog language and its capabilities for me. I have Clocksin & Mellish's Programming in Prolog (2003, 5th ed.) and liked it as a good introduction (or more expansion, I had dabbled in it previously and "knew" the language but not the full depth of it). I've read good things about The Art of Prolog by Sterling and Shapiro, but have not read it.
- simongray 6y agoThis inspired me. What's the best book for modern prolog?
- dgb23 6y agoThe blog post refers to this: https://www.metalevel.at/prolog https://www.metalevel.at/prolog
- simongray 6y agoBy book, I meant a dead tree version that I can read in bed or in a sofa. I'm not great at taking in large amounts of new information from a website. Sorry if I wasn't specific on that.
- bmitc 6y agoI recently started going through the book Thinking as Computation: A First Course by Hector Levesque, and I am finding it rather nice. It goes slow, but I like slow. It uses Prolog as the computational implementation of the thesis that presents thinking as computation. https://mitpress.mit.edu/books/thinking-computation https://mitpress.mit.edu/books/thinking-computation Other books I have but haven't gone through yet are Adventure in Prolog and The Art of Prolog.
- stass 6y agoFor starting out I'd recommend Clause and Effect by Clocksin. It's a very short but practical introduction with really good examples along the way (including symbolic differentiation and FFT).
- flubert 6y agoI liked "The Art of Prolog" for learning. And then if you dive deeper, "The Craft of Prolog". I'm curiously amused that the price for used versions on Amazon is so high. https://mitpress.mit.edu/books/art-prolog-second-edition https://mitpress.mit.edu/books/art-prolog-second-edition https://isbn.nu/0262192500 https://isbn.nu/0262192500 https://mitpress.mit.edu/books/craft-prolog https://mitpress.mit.edu/books/craft-prolog https://isbn.nu/9780262512275 https://isbn.nu/9780262512275
- simongray 6y agoI did some further research and it seems like The Art of Prolog gets the most love even though it's from the mid-nineties - and still hella expensive like you say! The only thing I'm wondering about are skipping any important developments made in the last 25 years, but I guess I can always jump into the more up-to-date online resources by then.
- i_don_t_know 6y agoThe Art of Prolog is available as a free download (PDF) on the MIT Press website under „Open Access“. AFAIK the biggest item that’s missing is constraint logic programming. Markus Triska discusses CLP in his Power of Prolog book.
- simongray 6y agoThank you for pointing that out.
- i_don_t_know 6y agoThe Art of Prolog is available as a free download (PDF) on the MIT Press website under „Open Access“.
- IThinkImOKAY 6y agoProlog is very bad to learn.
- Jtsummers 6y agoIt can be hard to learn, as it's a bit mind bending to think about writing programs more as objectives and relations, than as imperative code. But it's certainly not bad to learn. It's helped me out a few times over the years, using it directly or using the ideas of it for a specific application (sort of a Greenspun's tenth rule applied to Prolog).
- the_only_law 6y agoMind expanding on why you think this is so?
- rhodozelia 6y agoI was surprised to learn prolog is used in inductive automation's ignition SCADA product when it barfed out a prolog error after I entered an invalid expression. https://inductiveautomation.com/ https://inductiveautomation.com/
- 7thaccount 6y agoWith a name like "inductive", it kind of makes sense :) I wonder if it's used for their alarming logic.
- KMag 6y ago> I wonder if it's used for their alarming logic. If you need easily verifiable rules for your rules engine, it's hard to go wrong with Prolog.
- qart 6y agoI wonder... is it still justified to learn Prolog now? Aren't there better alternatives for logic programming in many other common programming languages? I mean http://minikanren.org/ http://minikanren.org/
- triska 6y agoHow is this a better alternative? A major attraction of Prolog is that one can remove almost arbitrary parts of any pure program and still infer useful conclusions that hold for the original program. For example, one can remove a clause and thereby make the program more specific. One can remove a goal and thus make the program more general. This is possible due to the way the language is designed, the interplay of syntax and semantics enables this. The program fragments serve as explanations that can be shown to programmers to pinpoint mistakes in the code. Thus, when narrowing down mistakes, it becomes possible to focus on smaller portions of the code that are therefore easier to understand.
- iso8859-1 6y agoWhy wouldn't that be the case for e.g. LogicT? Prolog is _larger_ than LogicT. It is the additional syntax and runtime system in a custom Prolog implementation that needs to be defended, not the lack of it!
- qart 6y agoI meant "better" in the sense that one can do logic programming from whatever language one is familiar with already, instead of installing and learning a whole new ecosystem. We would still have to learn logic programming.
- YeGoblynQueenne 6y ago>> For example, one can remove a clause and thereby make the program more specific. One can remove a goal and thus make the program more general. Woa. I'm pretty sure that the subsumption order and the implication order are not common knowledge among Prolog programmers. Have you been reading Plotkin by any chance? :)
- 6y ago
- st1x7 6y agoHow do you guys think about the opportunity cost of learning dead/dying/new/unpopular languages? Even with newer languages that are gaining popularity and are likely to be used in the future, I struggle to justify the time investment. I could be wrong but some of my concerns are: - my time is better spent getting deeper into some more popular language that I already know to some extent - unused skills deteriorate with time so by adding a new language that you don't need professionally right now, you also need to add the future time and effort of practicing and maintaining that skill - I could be wrong but I feel that it's a red flag to have too many of the more esoteric languages on your resume. I do enjoy tinkering with a new language but very often it just feels like a distraction. Thoughts?
- kaba0 6y agoLearning another language with basically the exact same mental model behind them is not as worthy to spend time on. But learning a language with an entirely different paradigm is really eye opener and will make you a better programmer even if you’ll never write a line of code in it. For example, learning Haskell is a really good way to learn about FP and then you can easily apply it in a not strictly FP language. Prolog is interesting because it is really niche, and “learning it” as in solving a few easy problems will definitely not take much time but will add another way to think about a problem to your toolkit.
- tiew9Vii 6y agoI agree. For me it also came with a huge down side. I spent the last six to seven years using Scala, learning FP concepts, getting familiar with Haskell and it's concepts as well as other functional languages. This is after 7+ years prior doing lots of typical Java, Javascript, PHP which I was quite happy to use. Now I'm in the situation after learning languages which provide far more useful day to day principals, abstractions and safety I struggle or rather get frustrated very quickly when I go back to C style languages i.e Java, Javascript, PHP, Python. My huge problem now is I'm in Sydney, Australia. 4-5 years ago there was a reasonable strong enthusiasm for Scala and functional programmers in general. No, I've been looking to change jobs for the past year and absolutely nothing has popped up. It seems the only roles available are traditional Java with Spring Boot, Javscript, Python and C#. Even with DevOps stuff which I have a bunch of experience for everyone want Ansible when after discovering NixOS/Nix it completely removes the need for Ansible giving declarative deterministic infrastructure/deployments without fragile line upon line of YAML files. Of course all the functional programming work I've learnt is usable and can be applied everyday in other languages. Functional programming isn't new predating all the new shiny popular languages. The problem is having used better languages which treat these principals as first class it isn't the same as trying to hack together something in a language never designed to support it. It seems I've now learnt myself out of a job. If I want a job I need to take a step backwards and use tools that now frustrate me and seem clunky / broken. It's at the point where I'm starting to look at a career change outside of software to start enjoying work again.
- mths 6y ago> To be honest, at the moment such problems are too rare to justify learning Prolog. But I don’t believe that this has to remain so. And then the whole following section on unfulfilled potential.. Is there any reason to believe the paradigm will somehow come into its own in the future? The way this question was addressed by the article was way too wishy-washy for my taste.
- chubot 6y agoI wrote about my experience here, and linked to an older article with related observations about why Prolog is a niche technology: https://news.ycombinator.com/item?id=25653425 https://news.ycombinator.com/item?id=25653425
- deleted 6y ago[deleted]
- jeofken 6y agoLearning Prolog is a lot of fun! It will not take more than an a day or two - it’s simpler than python. Download SWI prolog, and get an editor that allows interactive programming with it. Emacs is of course the best for any obscure hacker language, but there may be plug-ins for other editors. Predicates are like functions but instead of returning you simply leave some parameter as a variable, and the “return value” is prolog finding what the value of that parameter can be. Making web apps with the built in libraries and library(persistence) is a lot of fun - you can make a real webapp with a relational database with zero dependencies but prolog. Programs are small. Highly recommend for anyone who loves programming. Only thing I wish for is no effects but instead it being pure like Elm, and a type system rather than runtime type errors.
- hawk_ 6y agoWhich makes me wonder is there a statically typed prolog like language out there?
- themanaknight 6y agoCheck out Mercury https://mercurylang.org/index.html https://mercurylang.org/index.html
- barnacled 6y agoI used prolog in anger when I first started at a startup some years ago (why that was is another story) and while I found it interesting, it was really quite an ineffective experience for me. Firstly, by being so declarative if was very easy to end up with O(a^n) algorithms by mistake and secondly I found, at least in what I was doing, that for example the ordering of declarations would change program behaviour which made it imperative in a very non-ovvoous way. I also found it hard to debug and diagnose the code or find decent resources online for it. Perhaps I didn't do a good job with it or was missing details on exactly how best to use it but I found it was almost too declarative to the point of the rubber never hitting the road in a controllable way.
- xiphias2 6y agoI had the same problem when trying out Haskell: they give abstractions that are not constant multipliers in terms of speed or memory usage compared to a low level solution (like garbage collection and dynamic typing). Rust gives just the opposite type of abstraction over C++: memory safety without adding any unpredictability in execution (and of course updates in the language design). While relational algebra (SQL) is equivalent to logic algebra, it's easier to reason how it executes.
- barnacled 6y agoyou can still get tripped up on SQL (accidentally doing a table scan etc.) but there is explicit tooling to help you analyse that - e.g. looking at the execution plan. Haskell I can't comment on, though I can totally see that happening there, there might be better means of managing complexity and giving hints to actual implementation. With prolog the means of expression seems capable only of posing the 'question' rather than indicating that it should be not be implemented in the most naive possible way. As interesting and mind-bending a language as prolog is I just couldn't get past that and it has made me think it's just not a practical language to use for anything real. But I am happy to be proven wrong!
- PortlandMEnerd 6y agoOnly a handful of people can earn a living becoming academics and we're in a time where many people are being "pushed" into credentialing up. Forcing people who are going back to school to further their professional careers to learn a language that isn't marketable makes the degree they're trying earn worth less. Please think harder about why you're offering this class and consider offering something else instead that will provide more value to the adults trying to compete in this flat world.
- Twisol 6y agoI've profitably used the domain modeling and program design lessons I've learned from Prolog multiple times, please and thank you. You don't need to use a language in production for it to be a valuable addition to your toolkit.
- deleted 6y ago[deleted]
- xyzelement 6y agoI didn't read this article but I did decide to use Prolog (which I didn't know prior) for this year's Advent of Code. I ended up solving the first 8 days (so, 16 puzzles) and it was fun. What I got out of the experience: 1. Intellectual confidence - it's not often that we get to learn not just a new way of doing something but a new paradigm. I am 38, and while I try to challenge myself in all areas of life, how often is something a true mind-bender? The fact that I was able to wrap my head around (some of) the Prolog way of doing things proves to me that I "still got it" and is good exercise for keeping it that way. 2. One specific thing about Prolog is heavy reliance on recursion. I probably "get" recursion better than an average CS grad but this took me to the next level - I will be able to apply it in other languages. 3. There's something about Prolog that makes programing feel like this: a ton of thinking up front, but once you do it, the implementation is bug-free (versus lots of fiddling around in other languages). I guess that's probably true of non-imperative languages in general, but it was a nice change of pace. I am not a full-time programmer anymore (product manager) so for me coding is mainly fun/intellectual and doing it in a way that removes the fiddling is great. 4. Prolog feels very retro, I can't really explain it but it doesn't try to be cool - it's the opposite of say the latest JS framework that is polished to the 9s. Prolog feels more like the cockpit of a fighter jet - sparse and powerful, but you have to know how to use the tools. 5. The community is cool. I found the IRC channel and folks were very generous with their time, though to be fair I asked questions like: "I implemented X like this, is that canonical?" vs "how do I do X?" 6. I am glad to have Prolog in my toolkit. I can imagine problems down the road where logic programming is the best tool and I know I can reach for it now. Bonus: a few posters in this thread asked about the ROI of learning a retro language given that they could be learning something else. I think it's totally up to you, but looking back on the list above, almost none of the benefits I enjoyed are that I now know Prolog. So I guess you have to pick and chose your challenges, I wouldn't get the same value from learning Fortran77 and I wouldn't expect anyone else to either. Prolog is different enough from whatever else you're doing that it can grow you beyond learning some minute detail of React Hooks (which are great, btw!)
- legerdemain 6y agoTo save you a click: - Because the author likes it. - Because it's different. - Because very few other people like it. Is this really an effective pitch to students who are looking for an efficient way to use their limited resources?
- jmnicolas 6y agoThe article is much more convincing than what you reduced it to.
- simplify 6y agoEvery developer should learn Prolog or a logic language in their career. It's mind-bending in the best way, and opens your eyes to how a computer can do work for you by you describing the problem instead of the solution. SQL is a language that could have been a Prolog. In fact, querying in Prolog in general is absolutely beautiful. Prolog is homoiconic like lisp; extending the language with new features is trivial as it requires no new syntax.
- ausbah 6y agoat a higher level, don't all programming languages do some amount of work for you? like fundamentally all programming boils down to manipulating electrons in a circuit board or something, it's just different programming languages from assembly to SQL provide different ranges of abstraction for what they handle vs what the programmer had to handle
- solaxun 6y agoI've wondered this a few times myself - I like learning languages (even if not directly applicable to paid work) and Prolog has been on the list, but I wonder if the concepts are better left on their own rather than packaged into a DSL. If I understand constraint propagation and backtracking, why not just use those concepts when it fits the problem rather than an entirely new language meant specifically for that narrow range of problems?
- chubot 6y agoYeah I think that is a better solution. Somebody who worked on the Mercury logic language for 10 years ago said the same thing here: https://old.reddit.com/r/ProgrammingLanguages/comments/9kb9z5/logic_programming_languages/ https://old.reddit.com/r/ProgrammingLanguages/comments/9kb9z... I have worked on and with Mercury for about 10 years. I had very little logic programming experience before this, while others tend to learn Prolog first. I like Mercury, but not for the logic programming features, in practice they aren't used very often, there's not many parts of a program that require backtracking. So on reflection, I don't think it's something I'd include in a new language, it's not worth the implementation and maintenance costs. Not for most programs most of the time anyway. On learning logic programming: It might sound like I'm discouraging anyone interested in this, far from it. Logic programming is a great paradigm to learn, another conceptual tool in your toolbox etc. via https://news.ycombinator.com/item?id=18376593 https://news.ycombinator.com/item?id=18376593
- inkyoto 6y agoProlog excels at solving NP complete problems (e.g. the SAT solver) or combinatorial problems in general that would normally require polynomial-vs-exponential time to find a solution whereas the use of Prolog allows to arrive at the same solution in the linear-vs-quadratic time. It is not really possible to accomplish it with a DSL. Another amusing property of Prolog is that a typical Prolog program can be run forward... and backward, i.e. it is possible to «ask» a question and receive an «answer», or if the «answer» is known, the program can arrive at a set of all possible «questions». Hence heavy Prolog use to build expert systems and alike. Back in the days, we used to giggle that if the 42 answer was fed into a Prolog problem solver to arrive at a full and exhaustive set of questions about the meaning of life, the universe and stuff, that would instantly create a singularity at the point in time and space where the solver was run and henceforth result in a collapse of the universe unto itself.
- chubot 6y agoA couple years ago I hacked on a Python type inferencer someone wrote in Prolog. I wasn't enlightened, despite expecting to be, from a bunch of HN posts like this. https://github.com/andychu/hatlog https://github.com/andychu/hatlog For example, can someone add good error messages to this? It didn't really seem practical. I'm sure I am missing something, but there also seemed to be a lot of deficiencies. In fact I think I learned the opposite lesson. I have to dig up the HN post, but I think the point was "Prolog is NOT logic". It's not programming and it's not math. (Someone said the same thing about Project Euler and so forth, and I really liked that criticism. https://lobste.rs/s/bqnhbo/book_review_elements_programming https://lobste.rs/s/bqnhbo/book_review_elements_programming ) Related thread but I think there was a pithy blog post too: https://news.ycombinator.com/item?id=18373401 https://news.ycombinator.com/item?id=18373401 (Prolog Under the Hood) Yeah this is the quote and a bunch of the HN comments backed it up to a degree: Although Prolog's original intent was to allow programmers to specify programs in a syntax close to logic, that is not how Prolog works. In fact, a conceptual understanding of logic is not that useful for understanding Prolog. I have programmed in many languages, and I at least have a decent understanding of math. In fact I just wrote about the difference between programming and math with regards to parsing here: http://www.oilshell.org/blog/2021/01/comments-parsing.html#what-programmers-dont-understand-about-grammars http://www.oilshell.org/blog/2021/01/comments-parsing.html#w... But I had a bad experience with Prolog. Even if you understand programming and math, you don't understand Prolog. I'm not a fan of the computational complexity problem either; that makes it unsuitable for production use.
- tejtm 6y agoGoing to give a shout out to "PiCat" as a gentler introduction to getting your Prolog brain installed. http://picat-lang.org/ http://picat-lang.org/
- _wldu 6y agoI used Datalog a good deal in grad school (CS). It was frustrating at first, but once I figured it out, I liked it a lot. If you've never tried a declarative programming language, you should give Datalog a try.
- cfallin 6y ago+1 to Datalog -- it is fantastic for static analysis in particular! There are a bunch of papers from Yannis Smaragdakis' group on this; I built my thesis work on top of their system Doop [1] which is a whole-program points-to analysis written completely in Datalog. In general it's very nice to be able to prototype queries/inference rules quickly and then tweak clause ordering, etc for performance later if needed. [1] https://bitbucket.org/yanniss/doop/src/master/ https://bitbucket.org/yanniss/doop/src/master/
- simongray 6y agoProbably worth mentioning for those interested in Datalog that there's actually a growing selection of databases for Clojure that use Datalog as their query language. These Clojure variants of Datalog (they model triples as Clojure data structures) are basically becoming as ubiquitous in Clojure as SQL is elsewhere. I have documented them here: https://github.com/simongray/clojure-graph-resources#datalog https://github.com/simongray/clojure-graph-resources#datalog
- bambataa 6y agoIf I may hijack the Clojure reference, how does Clojure’s core/logic compare to Prolog? Do they broadly fit in the same problem space?
- simongray 6y agoI think core.logic is basically just a Clojure implementation of miniKanren. I'm not too familiar with logic programming myself, but my impression is that miniKanren, core.logic, and Prolog all use basically the same algorithm, operate on the same type of data, and try to solve the same set of problems. The advantages/disadvantages are probably external to the core problem space, e.g. do you prefer an embedded DSL better to a full-blown logic programming language and so on. I'm a hardcore Clojure advocate (it's a fantastic programming language with a great ecosystem of libraries), but there's no doubt that the amount of resources available for learning the API of core.logic is less than what's available for Prolog. If the objective is to learn logic programming from the available resources, Prolog is probably the better option.
- ianferrel 6y agoNo.
- macintux 6y agoI caught Chris Martens' talk at Strange Loop 2013 on linear logic programming. Sadly what I understood I've long since forgotten, but if you're interested in looking at some of the logic programming space outside Prolog itself, worth a gander. https://www.infoq.com/presentations/linear-logic-programming/ https://www.infoq.com/presentations/linear-logic-programming... https://thestrangeloop.com/2013/linear-logic-programming.html https://thestrangeloop.com/2013/linear-logic-programming.htm...
- rscho 6y agoIf you want to make/prototype any sort of complex text manipulation (parser, interpreter, compiler, etc.) or have a desire to make purely functional list processing programs, Prolog is by far the best in terms of flexibility and ease of use. DCGs are miles ahead of everything else in this area, and this is not surprising since that was exactly the expected use case when Prolog was designed.
- Tistel 6y agoProlog is great and kind of weird in a good way. One other benefit is that you can pick up erlang really quickly if you know prolog. Erlang was first prototyped in prolog and that prototype’s host language heavily influenced erlang’s syntax. Why learn erlang? Check out the high scalability of WhatsApp.
- mncharity 6y agoIt might be easier to learn prolog, if non-essential costs were removed, by using a more familiar language as a wrapper[1], or for metaprogramming. Prolog's value lies in its database core. But much of the cost of learning a new language is elsewhere, in dealing with yet another different set of ways to do familiar things. With prolog, those differences are relatively uninteresting, so why not punt? Not having to deal with "how do I read a csv file in prolog?" and such, frees time for richer ideas, like prolog search is a poor fit for most problems, but prolog is a nice language for writing problem-appropriate search. [1] https://github.com/yuce/pyswip https://github.com/yuce/pyswip
- galaxyLogic 6y agoThat's my hunch too. Prolog is a different world and you still want to keep one foot in more mainstream languages. The idea should be use Prolog where it gives real advantages and use mainstream languages where it doesn't. So how do you divide your application into those two "islands"? Answer: Use persistent Datalog for database/persistence but do the rest in you bread-and-butter language. Basically saying replace SQL with Datalog. That is just what I think I'd like to do. I don't know what would be the most practical platforms to do that, which mainstream language + which Datalog database. Any recommendations?
- mncharity 6y agoNo recommendations, sorry, merely a couple of thoughts. Prolog and datalog start out as rather different beasts, though prolog tabling gets them closer. It's an area of current research[1]. A datalog implementation can serve as DSL, learning tool, and/or efficient solver of large problems. For the first two, most languages have a little datalog implementation or three. For datalog engines, perhaps Z3 and its fixpoint engine from python?? Or maybe Soufflé from python?? But I really have no idea what's plausible. I too would be interested. > database/persistence That's something with a big diverse active market. Datalog engines, not so much. So I'm unclear that datalog is a place to go for that? But I also pay no attention to non-open-source offerings. [1] https://arxiv.org/pdf/1909.08246.pdf https://arxiv.org/pdf/1909.08246.pdf
- donpdonp 6y ago"The Power of Prolog" is a youtube channel for learning about Prolog https://www.youtube.com/channel/UCFFeNyzCEQDS4KCecugmotg/videos https://www.youtube.com/channel/UCFFeNyzCEQDS4KCecugmotg/vid...
- klausnrooster 6y agoBecause you will likely be glad you did. Then go look at PicoLisp, which has Prolog baked into it. https://picolisp.com/wiki/?home https://picolisp.com/wiki/?home
- 7thaccount 6y agoIs pilog just a mini logic programming language implementation or what you would call a full prolog engine?
- klausnrooster 6y agoSorry, I'm not qualified to say. I cut short my dives into both Prolog and PicoLisp. Too many segfaults (myfaults) in PicoLisp. I need more hand-holding or time. I'm keeping my Prolog books though. Will return to them _someday_. Firmly of the opinion that if I could learn one prog-lang Matrix-style (plugged into my neck), it would be PicoLisp. Then I'd port it to run on the BEAM.
- 7thaccount 6y agoI also like the concept of picolisp, but ran into a lot of segfaults myself and eventually gave up. The learning material needs more handholding for sure. Also, I'll never be able to run that in production at my place of employment, so I could only use it for hobby projects.
- KMag 6y agoI'm not convinced there's great utility in smart contracts, but if there is, I think there's a huge utility in contracts being declarative and statically typed, to avoid many of the problems we've seen with existing contracts. In that case, a statically typed Prolog dialect would be a good starting point. The contract would be a set of declarative rules describing acceptable next states of the contract. To make the contracts verifiable in linear time, the submitter would submit the next state of the contract, plus a compact binary representation of the path taken through the rules set, so no backtracking would occur in the verifier. You could allow recursion, as verification time would still be linear in the size of the submitted compact path representation, just not linear in the size of the contract. If you disallow recursion, then verification would also be linear in the size of the contract. Granted, many of the problems with Ethereum Solidity contracts are more to do with all of its use of implicit behavior (in a misguided attempt to hide the complexity of contracts) rather than directly consequences of Solidity being imperative. Here's a quick plug for Mercury[0], a statically typed dialect of Prolog with an optimizing native code compiler. Supposedly it's 5 to 10 times faster than commercial Prolog compilers or available interpreters. [0] https://github.com/Mercury-Language/mercury https://github.com/Mercury-Language/mercury
- dfischer 6y agoSimilarly down this path I found Factor. A different approach but supports backtracking. https://factorcode.org/ https://factorcode.org/
- KMag 6y agoI'm familiar with factor. The thing about factor is that its execution semantics depend on execution order (i.e. imperative), which makes it impractical / unsafe to allow clients to provide verifiers with an optimal execution order for verifying a contract.
- dcolkitt 6y agoInteresting point. The biggest counter-argument I see is the need for fine-grained optimization of gas usage. Especially given the crazy high fees as of late. Hand-tuned imperative C enjoys a performance advantage over functional and declarative alternatives. So I’d imagine that imperative smart contracts are inherently easier to optimize than Prolog-style contracts.
- tallgiraffe 6y agoProlog is a wonderful language to dabble into, if for nothing else but to learn how to think more logically.
- johnisgood 6y agoI learnt Prolog before so Erlang's syntax does not look so scary to me.
- infogulch 6y agoProlog implementations are too heavily reliant on the stated order of predicate rules in order to make execution progress. Many predicates are non-terminating or extremely inefficient when faced with goal inversion, but are often 'fixed' by simply reversing the order of some of its rules (but making it useless in the original direction in the process). This is disappointing when trying to maximize prolog's biggest potential: building true total relations that can project in any direction with a single definition. There are technical reasons why the pursuit of term reordering is problematic, namely 'cut', which is a kind of out-of-bounds alteration of the program's execution. Previous attempts to get rid of 'cut' apparently ran into other problems. IMO the root of the issue is that prolog has no way to declare a "closed" predicate, and then optimize execution based on their presence. I think cut papers-over (heh) the lack of "closed predicates".
- tom_mellior 6y agoDefine "closed"?
- galaxyLogic 6y agoIsn't Datalog the solution to much of that?
- YeGoblynQueenne 6y ago>> Many predicates are non-terminating or extremely inefficient when faced with goal inversion, but are often 'fixed' by simply reversing the order of some of its rules (but making it useless in the original direction in the process). This is disappointing when trying to maximize prolog's biggest potential: building true total relations that can project in any direction with a single definition. I don't think that's a commonly agreed-upon "biggest potential" of Prolog. Prolog is a general-purpose language with the syntax and the semantics of the first-order predicate calculus, albeit limited to Horn clauses and with many other restrictions that are necessary to make for a language that can be used in the real world, for real programming tasks. I cannot easily think of an example where changing the order of clauses (not "goals") in a predicate definition prevents the program from "runnign backwards". For example, take the typical append/3 predicate: append([],Zs,Zs). append([X|Xs],Ys,[X|Zs]):- fappend(Xs,Ys,Zs). Moving the first clause, append([],Zs,Zs), after the second, still allows three calling modes: ?- fappend([a,b],[c,d],Xs). Xs = [a, b, c, d]. ?- fappend([a,b],Xs,[a,b,c,d]). Xs = [c, d]. ?- fappend(Xs,[c,d],[a,b,c,d]). Xs = [a, b] ; false. And complexity does not seem to be affected. Can you give an example where this is not the case? >> IMO the root of the issue is that prolog has no way to declare a "closed" predicate, and then optimize execution based on their presence. I think cut papers-over (heh) the lack of "closed predicates". I, like tom_mellor, am also not sure what you mean by "closed predicates". Could you clarify?
- fleur-de-lotus 6y agoWhen I hear "Prolog", it reminds me of the quote about Prolog: "The elegant solution is not efficient. The efficient solution is not elegant"
- s_gourichon 6y agoCommon nitpicking, here for fun: both sentence kind of repeat one another, as they mean nearly the same thing. They could be expressed as one more symmetrical sentence, something like: "the set of efficient solutions and the set of elegant solutions are disjoint" (they have no common element).
- jmnicolas 6y ago"Efficiency like quantity has a quality of its own"
- zephyrfalcon 6y agoOn the other hand, Richard O'Keefe claims in _The Craft of Prolog_, that "elegance is not optional": """ Elegance is not optional. There is no tension between writing a beautiful program and writing an efficient program. If your code is ugly, the chances are that you either don’t understand your problem or you don’t understand your programming language, and in neither case does your code stand much chance of being efficient. In order to ensure that your program is efficient, you need to know what it is doing, and if your code is ugly, you will find it hard to analyse. """ https://programmingisterrible.com/post/39499310419/elegance-is-not-optional https://programmingisterrible.com/post/39499310419/elegance-...
- mateioprea 6y agoThis brings up memories from 7 years ago. While in Uni, we had a homework: "Searching in an infinite space using Prolog". Unfortunately, the comments are in my native language, but the assignment was to search for a box in an infinite space and bring it back to (0, 0). It was fun: https://github.com/mateioprea/Searching-In-An-Infinite-Space-Prolog/blob/master/t3.pl https://github.com/mateioprea/Searching-In-An-Infinite-Space...
- deleted 6y ago[deleted]
- timonoko 6y agoI still do not understand why they do not make Prolog that can do infinite. The calculation should be lazy parallel instead of serial. I think this might solve confusing problems that arise with bigger Prolog programs. For example WRITE-statements can be lazy parallel too -- They would only start producing text when the answer is definite. Does not happen in any particular sequence anymore, but you must account that and use appropriate headings.
- 2sk21 6y agoEven more than Prolog, I am really excited by the possibilities of Answer Set Programming as exemplified by Clingo (See https://potassco.org https://potassco.org) The main feature of ASP that I like is the ability to handle Now, ASP is not a full-fledged language but instead should be viewed as a workable pure-logic based notation for expressing some kinds of problems. In particular negation is handled really well. Its not easy to learn but is well worth the effort.
- joeberon 6y agoPlease improve the style of your webpage. It seems to just serve up the text directly, leading to far too many characters per line, and making it extremely difficult to read. Ideally your line length should be somewhere around 70 to 90 characters.
- anentropic 6y agoYou could always resize your window to a comfortable width...
- cesaref 6y agoI learnt Prolog in the late 80s at Uni, when even then, it was a pretty odd thing to be interested in. It's nice that the community has kept going with it as an intellectual idea. I'm wondering what contributions it has made to the wider programming community. I guess things like the warren engine may have helped inform efficient methods of interpreting other languages, or the parallel prolog investigations probably again helped other languages. It's pretty clear to me that functional languages from the time (e.g. Miranda) which live on it Haskel have had a massive impact on modern programming languages, and approaches to resolve complex threading problems. I've a feeling the prolog innovations may be quite wide too, just maybe less obvious.
- gjvc 6y agoWe were taught Prolog in the late 1990s at university. Lisp or scheme would have been a better choice.
- tpoacher 6y agoI remember asking a similar question to my Prolog lecturer back in 2008 during my masters. He was visibly taken aback from it, I think he didn't expect it. It went something along the lines of "I've never heard of this language, does anyone even use it, what's the motivation for wasting a term on it" (yes, it was one of my more douchebaggy moments...). He had to go do market research and come up with an answer in the next lecture, hahah. Yet, once it all clicked, I loved it, and it opened up a new way of thinking for me, which was different from both imperative and, dare I say, functional paradigms. I also learned that, while fairly specialised, it has very real industrial applications (e.g. there's a super important critical infrastructure component in Microsoft built entirely on prolog if I remember correctly). Though, admittedly, I think most prolog finds uses as 'pluggable components to larger non-prolog projects' these days. Also, another interesting direction in Prolog is its fuzzy / probabilistic derivatives. Very cool stuff.
- yvdriess 6y agoLogic programming is one of those paradigms where if you haven't learned it you're doomed to repeat its mistakes. As with Lisp, Prolog makes you a better programmer even if you never end up using it.
- YeGoblynQueenne 6y ago>> I also learned that, while fairly specialised, it has very real industrial applications (e.g. there's a super important critical infrastructure component in Microsoft built entirely on prolog if I remember correctly). Was - in Windows NT. It was used for netowkr configuration and it was only partly programmed in Prolog: Microsoft's Windows NT operating system uses an embedded Prolog interpreter to configure its local and wide-area network systems. Interdependent software and hardware components are abstracted into a simplified object-oriented framework using declarative information provided by each component's installation script. This information, along with the Prolog algorithm, is consulted into the embedded interpreter, which is then queried to construct the most usable configuration. The algorithm which solves the plumbing problem is described, including its positive and negative constraints, Prolog database and efficiency considerations. The results of the query, stored into NT's configuration database, inform each component of its load order and binding targets. A description of theC++ wrapper class is given and portation considerations are discussed. The Small Prolog interpreter is briefly described. https://web.archive.org/web/20040603192757/research.microsoft.com/research/dtg/davidhov/pap.htm https://web.archive.org/web/20040603192757/research.microsof... I'm not sure how "super important" that was to be honest. My impression has always been that the programmer in question simply wanted to use Prolog in his day job (a feeling I can very much sympathise with).
- thargor90 6y agoI've worked with Prolog and ASP (Answer Set Programming) in some planning/optimization projects. In my experience in every case ASP had better expressiveness. If you are seriously considering logic programming, please do not stop with prolog, but also take a look at ASP. For anyone with a different experience than mine - what is your reason to stick to prolog instead of use ASP?