15 ms·
Why did Prolog lose steam? (2010)
- Kuinox 3y agoI tried to learn prolog. It's hell, I still didn't found a digestible learning material. The free tooling around it is bad, making you spend too much times debugging simple query as a beginner.
- rad_gruchalski 3y agoI made a few attempts and finally got it by having a go at Google Zanzibar problem using SWI-Prolog. I read TAOP and followed a bunch of videos on youtube. Prolog is nice.
- Kuinox 3y agoI'm not saying prolog is bad, I'm saying I struggled to learn the few things I learned about it, due to the lack of material, or it's bad indexation.
- rad_gruchalski 3y ago> I'm not saying prolog is bad Indeed. My Apologies. Take a look at The Art of Prolog.
- valenterry 3y agoJust because of performance issues. No other explanation needed really. same reason why it took some time for pure functional programming to take off too. The time for Prolog will come.
- discarded1023 3y agoProlog has many issues; for instance the lack of types and mode declarations, and backtracking almost never being what you want. This was addressed in Mercury [1] but much of the baby was thrown out with the bathwater. (IMHO Mercury ultimately landed closer to the MLs than to Prolog.) The academic literature suggests classic Prolog got fast enough in the late 1980s / early 1990s on stock hardware [2]; see also Peter Van Roy's intriguing book [3] for what happened next. IMHO it's worth learning about Prolog as a way of looking at the world -- for instance Isabelle and Lambda Prolog are essentially logic programming engines, albeit with more sophisticated terms and unification algorithms. [1] https://mercurylang.org/ https://mercurylang.org/ [2] https://www.hpl.hp.com/techreports/Compaq-DEC/PRL-RR-36.pdf https://www.hpl.hp.com/techreports/Compaq-DEC/PRL-RR-36.pdf [3] https://www.info.ucl.ac.be/~pvr/book.html https://www.info.ucl.ac.be/~pvr/book.html
- valenterry 3y agoRight, I have generalized a bit. It doesn't necessarily have to be Prolog, but I'm referring to logic-programming in general. There is even a new language that allows to embed logic programming inside of "regular" (imperative/functional) programming code. Forgot the name though.
- discarded1023 3y agoThere appears to be a lot of activity around minikanren [1]. Personally I'm so used to having a powerful metalanguage around (lambda calculus plus or minus a bit) that I can't imagine programming in pure Prolog any more. Which is to say this is probably the way to go in practice, if a subproblem can be solved using logic programming. [1] http://minikanren.org/ http://minikanren.org/
- zelphirkalt 3y agoMinikanren allows you to program in relations. That is, not only unidirectional functions, X->Y, but you can leave out the X and give the Y, getting all X, which would result in that Y. I always found that talk at RacketCon impressive [1]. I mean, of course, minikanren is also implemented somehow, using lambda, but usually one would not want to rebuild the things minikanren offers. I have not yet tried to use minikanren inside an otherwise "normal" program, but I suspect it will just work. [1]: https://invidious.baczek.me/watch?v=5vtC7WEN76w https://invidious.baczek.me/watch?v=5vtC7WEN76w (video id 5vtC7WEN76w)
- felixyz 3y agoI agree that the lack of types is a serious deficiency, but surely that can't be the reason Prolog lost steam? I mean... Python? As for modes, I'm not convinced they are really needed? I do feel they take away a lot of the beauty of Prolog, and a lot of the incentive to think in relations. (Or at least, I fear they do. I haven't actually programmed in Mercury. Would be happy to be proven wrong.)
- discarded1023 3y ago
- usrbinbash 3y ago> same reason why it took some time for pure functional programming to take off too. And when exactly did that happen? And no, I am not about imperative languages incorporating some functional programming stuff. When did a "pure functional" PL become mainstream and widely used in professional software engineering? Because as far as I can see, I see imperative languages dominating pretty much every field.
- valenterry 3y ago> Because as far as I can see, I see imperative languages dominating pretty much every field. I don't think that contradicts my understanding of "take off".
- usrbinbash 3y agoWhat is that understanding then exactly? The languages are not widely used. Rhey play a minor role at specialised applications in the industry. Almost everyone who learns programming uses imperative languages. So what exactly is the definition of "take off" here? Because, other than Haskell having a bit of media-echo a couple years ago, and an army of fans promising things like "the future of programming", I don't see any takeoff.
- valenterry 3y agoMy own feeling about the speed of adoption in languages and libraries, nothing more. Something can take off but still play a major role. Just like LLMs took off recently but still play a minor role in almost every area I know.
- usrbinbash 3y ago> Just like LLMs took off recently but still play a minor role in almost every area I know. Okay, let's do the comparison. LLMs became a big story less than a year ago. Since then, they are, among other things, powering the fastest growing app of all time. They are poised to take over pretty much every NLU functionality, products are being developed every day that wouldn't be able to otherwise, and major players in the industry throw billions at them. Their, and other ML achievements, impact on society are estimated to be so profound, that they have caused ripples in international politics, rekindled debates about UBI, made geopolitical positions about chip maufacturing and AI research even more relevant, and set lawmakers all around the globe scrambling to figure out how to deal with this new reality, regarding everything from copyright laws to regulations. So, what is going on in the purely-functional-PL space? Well, the flagship of these languages, Haskell, had it's stable release 12 years ago. Since then, the only software product that I can name without googling that's written in it, is pandoc. The language is currently Number 34 on the Tiobe index. In fact, I am not sure any of the current top20 could be called "purely functional", which would place these languages below Scratch, Fortran, and Classic Visual Basic in terms of that index. https://www.tiobe.com/tiobe-index/ https://www.tiobe.com/tiobe-index/ Regarding usefullness, what have purely functional PLs demonstrated? That they can be challenging to use coming from an imperative background, and that they can be a drag on performance. On the plus side they offer ... yeah, what exactly is it they offer, that imperative languages adopting some of their features, like functions as first class objects, cannot? So I have a hard time seeing any indicators of an impending take-off for purely functional PLs.
- Alupis 3y ago> same reason why it took some time for pure functional programming to take off too To be pedantic, almost nobody is using a pure functional language even modernly. Almost all languages that support functional programming are hybrid systems at this point in time, and still have anti-functional constructs such as classes and objects. I dare say, it would be very difficult to maintain a large system that was purely functional. Some of the concepts revolving around OOP are indeed quite good and lead to better organized, more easily understood codebases. The future is probably a hybrid approach, not a pure approach as some advocates would prefer.
- valenterry 3y agoClasses and objects don't contract PFP. Yeah every non academic language (that I know of) has escape hatches. Still, you can (and many do) write your code in a 99,99% pfp style in e.g. Scala.
- Alupis 3y agoThe idea of a class encapsulating functionality and traits is definitely at odds with PFP. PFP would prefer free functions, after all. However, a Data Class without mutability and without functionality (besides accessors) is in-line with PFP. Like I said, most modern systems are hybrids - taking the best of all paradigms instead of aligning with a singular paradigm as was done in the past.
- valenterry 3y agoNot really, at least not in my terminology. Classes (in the pfp world) are pretty much just a bundle of free functions with some predefined bindings that are available to all those free functions, and putting those functions into their own namespace. Those are valid things to do even in pfp. data classes are technically similar or even identical but conceptually a different thing (though of course also useful and needed).
- cable2600 3y agoI remember using Borland Turbo Prolog for MS-DOS. It was the bee's knees.
- pubby 3y agoIf I was a company in the 80's or 90's, I'd use spreadsheets if I need declarative data stuff, and I'd use a boring blub language like BASIC for everything else. Few business problems need the type of logical inference Prolog provides. I do like Prolog though.
- contingencies 3y agoIt seems a good place to note that BNF already existed since 1959. https://www.softwarepreservation.org/projects/ALGOL/paper/Backus-Syntax_and_Semantics_of_Proposed_IAL.pdf https://www.softwarepreservation.org/projects/ALGOL/paper/Ba... BNF provided a formal grammar allowing the declaration of precise and iterative constructs without additional complexity of algorithmic content. Original spec @ https://www.softwarepreservation.org/projects/ALGOL/paper/Backus-Syntax_and_Semantics_of_Proposed_IAL.pdf https://www.softwarepreservation.org/projects/ALGOL/paper/Ba... BNF was created by Naur, the guy who invented FORTRAN, and was critical to both many early RFCs (the most important standards that facilitated the growth of the internet) and man pages in Unix. The syntax: executable <required-arg> [optional-arg] ... is a legacy of BNF. https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form
- amoss 3y agoWhat connection are you drawing between the two? BNF is used to define language grammars. Prolog is written using Horn clauses. There is not an obvious connection.
- contingencies 3y ago"Language grammars" are the same as specifying what is valid and what is invalid. This is done using hierarchical class membership, roughly equal to mathematical sets or programming language types. I would argue that this can attract users better than the additional formalism you can obtain through logic programming, because once you have determined the validity and class (roughly "set membership") of something, you can potentially generalize about it more easily and you have a clear cognitive boundary. Speaking from experience, in practice, I often rigidly define one layer of a system and then implement algorithms less rigidly using a less formal approach. This seems standard across the industry. Think about UUIDs, network addresses, etc. I believe this type of tradeoff is ultimately what killed logic programming. If you really want to do maths, do maths. If you want to define something, do so succinctly. And if you are here to implement an algorithm, use the right tool. Don't pretend the code will write itself. Logic programming always seemed to me a sort of allusion to mathematical inference that didn't transfer well to real world programming problems. Just my opinion.
- at_a_remove 3y agoI have a Prolog book, somewhere. Prolog feels like a really useful feature was hauled out of some other programming language and made to stand on its own. Like if I pulled regular expressions out of Perl and tried to make them their own language.
- cheaprentalyeti 3y agoI highly suggest the wikipedia entry [0] on regular expressions and their history; the concept goes back to at least a couple decades before Perl, which incorporated them via a c library written by Henry Spencer a couple years before Perl even existed. [0]: https://en.wikipedia.org/wiki/Regular_expression https://en.wikipedia.org/wiki/Regular_expression
- jjtheblunt 3y agothey are their own language class...the regular languages, at least in pure form, not the pcre extended regular expressions (which would be a different language class). https://a.co/d/a5FGZRQ https://a.co/d/a5FGZRQ
- galaxyLogic 3y agoGood point. Most programming languages have RegExp support. But very few (?) have Prolog support. That might be useful in some or many cases, like ...
- bandrami 3y agoThe pattern matching capability in the ML family is arguably an embedded Prolog system.
- felixyz 3y agoIt might partially have been inspired by Prolog, in fact. But it lacks backtracking and unification so I don't think it qualifies as an embedded Prolog system. Erlang allows so-called non-linear patterns (ie using the same variable for several argument positions, implying equality), which comes slightly closer to Prolog (and of course, Erlang was originally modeled on Prolog, but the apple ended up far from the tree).
- eslaught 3y agoIf you're trying to solve boolean satisfiability, you want a SAT solver, not Prolog. If you're trying to solve more general problems, you probably want an SMT solver or other more specific solver (e.g., ILP), not Prolog. If you're trying to verify software, you want a theorem prover, not Prolog. If you want database-ish stuff you want Datalog (or something like it), not Prolog. Prolog falls into the uncanny valley of being too general of a DSL for the sorts of optimizations that more narrow solvers enjoy, while being too narrow of a DSL for most general-purpose programming. I think because it was an early DSL, people got caught up in the idea of it being more "high-level" than other languages [1], but the DSL nature of it wasn't fully appreciated at the time. [1]: For fun, take a read through https://en.wikipedia.org/wiki/Fifth-generation_programming_language https://en.wikipedia.org/wiki/Fifth-generation_programming_l... , which was a whole thing in the 1980s.
- jjtheblunt 3y agoabove is a fantastic lucid comment (not kidding)
- usgroup 3y agoI don’t think those are the problems since all sorts of solvers ship with prolog and it’s still a better way to write down a problem. I think it’s biggest headwind is that you have to be significantly more intelligent than the average developer to think in Prolog. Prolog requires you to think about code as the implication of constraints — you just have to keep a lot more in your head. Prolog also requires you to understand the execution model before you can do much of anything.
- nerdponx 3y agoWhat about Prolog as an embedded constraint-solving engine inside an application written in some other host language?
- usgroup 3y agoI think embedding Prolog is a common use case for it, but I think “constraint solver” is the wrong metaphor. Use Prolog to “reason about X”, is closer to the gist.
- usgroup 3y ago“ “The Japanese Did It” is not the correct answer to “Who Killed Prolog?”. Prolog was killed by the failure in the early 1980s of mainstream AI researchers to find out about Prolog, by their willingness to play along with the “appropriate responses” to FGCS, and by their use of FGCS’s failure as an excuse for continued neglect of a promising alternative to Lisp. “
- Manfred 3y agoIt's a natural fit for people with a logic background to validate their ideas computationally. That also meant that people in the 80's and 90's used it for AI research. For me personally it was a great way to be introduced to different programming paradigms. It's fine for a programming language to live in a niche.
- jillesvangurp 3y agoA lot of the early AI community was using lisp or lisp derivatives. I remember playing with expert systems and Bayesian believe networks in university in the mid nineties. Bayesian believe networks were basically about assigning probabilities to correlations between facts. Early ML became about trying to learn the probabilities. I also did a Prolog course and I got to teach programming as a teaching assistant in Java to philosophy students that had Prolog as their only programming experience. So, they understood logic but not loops or assignments.
- grose 3y agoI think that Prolog will rise again. If you have an hour to kill, check out this video introduction by Markus Triska about what makes Prolog unique: https://www.youtube.com/watch?v=8XUutFBbUrg https://www.youtube.com/watch?v=8XUutFBbUrg Recently I have been working on getting Trealla Prolog to run in WebAssembly. Support is quite good now, with an easy-to-use JS library[1], Go library[2], and is now one of the best-supported languages for the Spin runtime[3]. I think it's particularly nice for validations, you can write some simple Prolog rules and run the same code on the client and the server now. I would like to explore this more with a dedicated library at some point. Built-in features like DCGs make parsing/generating all kinds of data trivial. I love it. I think the biggest barrier to Prolog adoption is that it has a really steep learning curve, and most people get burnt by half-assed introductions in college that tick the 'talked about logic programming' box in the syllabus. You really have to think in a completely different way to write a good Prolog program. But, once you get the right mindset, it makes solving complex problems incredibly easy. I don't really buy the argument that Datalog is enough. Most Datalog implementations I've seen hack on a bunch of extensions to do things like list membership. It would be awesome to see some serious effort put into an efficient Prolog-based database. The closest thing I can think of is TerminusDB, which I've never used but I wish I could convince my company to try it out ;). My dream is to have some kind of magical serverless persistent Prolog interpreter in the cloud. That's where I hope to take this Wasm stuff at some point. Can you imagine how powerful it would be to use Prolog instead of GraphQL or whatever? Prolog is IMO the perfect language for querying things, with a 1:1 correspondence to how you write the data. It's like SQL without all the ugly bits (I like SQL too, of course). If this sounds cool to you, check out the paper/book on Web Prolog[4] which is a fascinating dive into what a Prolog-based networked query system could look like. [1]: http://github.com/guregu/trealla-js http://github.com/guregu/trealla-js [2]: http://github.com/trealla-prolog/go http://github.com/trealla-prolog/go [3]: https://github.com/guregu/trealla#spin-components https://github.com/guregu/trealla#spin-components [4]: https://github.com/Web-Prolog/swi-web-prolog/raw/master/book/web-prolog.pdf https://github.com/Web-Prolog/swi-web-prolog/raw/master/book...
- discarded1023 3y agoThere was a lot of work done in the 1980s and 1990s on deductive databases. Somehow it didn't work out. See [1] for a survey from 1995 (coauthored by the most cited guy in CS). There is also the semantic web with its query technology. Also didn't work out. [1] https://www.sciencedirect.com/science/article/pii/0743106694000399 https://www.sciencedirect.com/science/article/pii/0743106694...
- deleted 3y ago[deleted]
- superdisk 3y agoI think Prolog's main problem is that it presents the idea of "just declare the constraints and it will find the solution," but can't really live up to that. In reality it's an extremely leaky abstraction, and even with pure predicates you need to take its execution model into account to avoid getting stuck in an infinite loop. I still love the language, but I think there's a point where every learner realizes it's not as beautiful and ideal as they once thought.
- usgroup 3y agoI recently read “Simply Logical” —- it makes very clear that you have to take Prolog’s execution model into account from Chapter 3 onwards. You really don’t have to go far in Prolog before you have to write a meta interpreter and think about search strategies. I think this is in plain sight from the beginning.
- infogulch 3y agoSure, nobody is deceived by the reality of the execution engine. But it's hard not to see a pure statement that is fast in one mode but slow in a different mode, determined entirely by the logically arbitrary order of two clauses, and not wish that the computer could just figure out those details itself.
- hnfong 3y agoI just replied to https://news.ycombinator.com/item?id=35625640 https://news.ycombinator.com/item?id=35625640 and I am inclined to believe that someone is deceived…
- felixyz 3y agoThe fact that you need to understand the execution model is not a limitation or an accident: it's a feature. One of the aims of prolog is to PROgram in logic. There are plenty of other logical frameworks that you can use to formulate a problem, make deductions etc, but then what do you do? The point of Prolog is that the operational and declarative semantics concur (excuse the non-exact verbiage). People mistakenly think this means there shouldn't be an operational semantics, or that it's a failure if you have to learn about it. If that's what you need, Answer Set Programming (or SMT solvers etc) might be a better fit. But that's not what Prolog is aiming to be.
- dboreham 3y agoIt was replaced by C++ code in Windows: https://community.osr.com/discussion/264058/re-re-ntdev-re-ntdev-ndis-lwf-inf-file-lowerexclude https://community.osr.com/discussion/264058/re-re-ntdev-re-n...
- felixyz 3y agoA gem!
- Animats 3y agoI once wrote something in Turbo Prolong which had both chaining inference and menus. Chaining inference fit well in the language. Drop-down menus were really painful in pure Prolog. Prolog has a use case, but it's just not that big.
- dcow 3y agoYes.
- hyperthesis 3y ago"Declarative" is sometimes misappropriated by functional programming. Is there a better term? Perhaps explaining it, as in TFA ("specify what, not how")? Or explicitly distinguish from fp? Or some other way? I think it's fair to say that declarative programming can only work well for "simple" problems (i.e. not requiring turing equivalence), and the strongest wins are when a declarative approach is discerned that didn't seem possible - perhaps by slightly simplifying the problem, to cross this threshold.
- discarded1023 3y agoWhat do you mean by "misappropriated"? You can try running with what wikipedia says [1] or stack overflow [2]. You could say it's PL marketing terminology from the 1980s and 1990s (FP + Prolog v the world). Roughly these languages aren't based on the idea of changing state, but of course that idea eventually ends up in there somewhere (e.g. monads and laziness in Haskell, DCGs in Prolog). On the positive side, I'd be comfortable saying that SQL is declarative. I'd be wary about bringing Turing completeness in here. It seems irrelevant. [1] https://en.wikipedia.org/wiki/Declarative_programming https://en.wikipedia.org/wiki/Declarative_programming [2] https://stackoverflow.com/questions/129628/what-is-declarative-programming https://stackoverflow.com/questions/129628/what-is-declarati...
- hyperthesis 3y agoTo answer the first question: "Wrongly taken". fp is declarative in the shallow sense of being immutable. But you can't just state what you want (e.g. what constraint programming languages enable); you must write a program. If fp is also declarative, what word is left for describing what I mean? Thus: misappropriation. Not "Turing completeness", "Turing equivalence". Many very simple systems are turing equivalent, so they can exhibit arbitrary complexity. A mapping, from what you have to what you want, is an example of declarative programming. WYSIWYG is declarative. [But arguably this makes "declarative programming" an oxymoron... or we must call html a "programming" language] Yes, SQL is a lot more declarative; the underlying relational algebra perhaps also is. Something that I'd personally like is a term for systems that enable you to specify the outcome as-is, rather than a composition of steps to achieve it. Perhaps I just want a word for this. I'll give an example: (a+b)(x+y) -> ax+bx+ay+by (declarative: "fully expanded form") (a+b)(x+y) -> a(x+y)+b(x+y) -> ax+ay+b(x+y) -> ax+bx+ay+by (steps: "distribute (x+y), distribute a, distribute b") [1] I agree with wikipedia here: programs describe their desired results without explicitly listing commands or steps that must be performed. but not in the next sentence: Functional and logical programming languages are characterized by a declarative programming style. because functional programs specify steps to be performed e.g. g(f(x)) rather than a state of affairs to be attained. [2] Unfortunately I don't have time to fully read the SO question right now, but I note it's closed and there seems much contention in the comments.
- xvilka 3y agoThere's a nice book[1][2] about Prolog, with modern characteristics. Moreover, there are things like ProbLog[3] and DeepProbLog[4] that allow you to use probabilistic reasoning and power of machine learning. I am personally looking forward for Scryer Prolog[5] to achieve its goals. [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://github.com/ML-KULeuven/problog https://github.com/ML-KULeuven/problog [4] https://github.com/ML-KULeuven/deepproblog https://github.com/ML-KULeuven/deepproblog [5] https://github.com/mthom/scryer-prolog https://github.com/mthom/scryer-prolog
- oigursh 3y agoNo.
- tejtm 3y agoJust a note that for us non-purist-Prolog-curious there is Picat http://picat-lang.org/ http://picat-lang.org/
- felixyz 3y agoThis is a good take, and historically accurate IMO. Rule engines were indeed marketed as a more practical way of getting the benefits of declarative rules, in a form where supposedly non-programmers would be able to maintain the rule base. And yes, the relational model (in the unattractive guise of SQL) won out in the database space. Just like functional languages inspire people to write "more functional" code in other languages, I think Prolog can inspire us to think in relations (SQL) and rules. Rules engines grew into monstrosities, but more light-weight rule engines exist and can be a great tool.
- zzbn00 3y agoGoogle's Gerrit code review system had a Prolog engine but I see that it is being depreciated now... https://gerrit-review.googlesource.com/Documentation/prolog-cookbook.html#SubmitRule https://gerrit-review.googlesource.com/Documentation/prolog-...
- Guthur 3y agoLike MLs, like Lisps etc power is trumped by convenience. Whether it is syntax convenience of C, Java, C# Or batteries included convenience of Python. It's a crying shame because we are stuck with the primitive expressiveness of 3rd generation, and are unlikely to break free any time soon if ever. We'd rather get some LLM to generate the reams of boiler plate required to do anything significant.
- Jeff_Brown 3y ago> hybrid languages that also incorporate some aspects of functional programming or other programming paradigms. Mercury and Mozart/Oz seem to be two of the more prominent ones Curry also deserves a mention, I think. https://en.m.wikipedia.org/wiki/Curry_(programming_language) https://en.m.wikipedia.org/wiki/Curry_(programming_language)
- slavapestov 3y agoThe Rust compiler uses a Prolog-like query language internally for type checking generic requirements and traits: https://github.com/rust-lang/chalk https://github.com/rust-lang/chalk
- logicmoo 3y agoIf your aim is to develop an SAT solver, it is recommended to write it in Prolog. For more general problem-solving, consider writing an SMT solver or another specialized solver (such as ILP) in Prolog, as it will likely be the most efficient choice. In the case of creating type-safe software, writing the interpreter in Prolog is a good idea, as it allows for code verification during runtime. Lastly, if you wish to integrate code and database functionality, it is advisable to use Prolog to develop an enhanced Datalog system, which will offer a more powerful and flexible solution.
- mikewarot 3y agoProlog doesn't have a conventional programmer oriented introduction. You need to at least include a "Hello World" program like this main :- write('This is a sample Prolog program'), write('\nThis program is written into hello.pl file'). ?- main. ?- halt. Next up, there's the fact that math doesn't use the =, but rather uses is to do evaluations at runtime, which drove me nuts. You have to use foreach or forall to do loops, and there are subtle differences ?- forall(between(0,5,N), (A is 5-N,writeln(A))). 5 4 3 2 1 0 true. It's just not programmer friendly. At least with spreadsheets, you can see what's going on, Prolog is just weird It's hard to pick up users, if they can't get enough of a grasp of it to make sense of it.