5 ms·
Prolog looks really useful for solving real world problems. Why doesn't it get used more? And can you interface to it using Python or some more mainstream lang
by collyw 10y ago
Prolog looks really useful for solving real world problems. Why doesn't it get used more?
And can you interface to it using Python or some more mainstream languages?
- ch4s3 10y agoIt makes some trivial things really hard. Fun fact though, Joe Armstrong et al wrote the original version of Erlang in prolog. There are some bindings, ymmv.
- splicer 10y agoFor Python, check out Pyke or pyDatalog.
- pjmlp 10y agoBecause like FP it requires a different way of thinking. It also didn't help that the Japan project to use Prolog a systems language for a so called 5th generation computer didn't work out. https://en.m.wikipedia.org/wiki/Fifth_generation_computer https://en.m.wikipedia.org/wiki/Fifth_generation_computer
- nickpsecurity 10y agoOr the whole AI is about to be everywhere because it's working well on a few problems thing. That led to AI winter with LISP and Prolog taking brunt of it at language level. At least we haven't seen articles like that recently, right? ;)
- exDM69 10y ago> And can you interface to it using Python or some more mainstream languages? You can and should use logic programming that way. There are libraries for doing e.g. networking and user interfaces with Prolog, but it's not a particularly good fit for that kind of programming. Many Prolog implementations are quite easy to embed to other languages and there are logic programming embedded languages for most popular programming languages. miniKanren [0] is a popular embeddable logic programming language. There's a chapter about implementing a logic programming environment in Structure and Interpretation of Computer Programs (SICP), which is pretty straightforward. For my AI courses at the uni years ago, I implemented a simple logic programming environment in Haskell [1]. It was a very fun project and it took me just a few days of work. [0] http://minikanren.org/ http://minikanren.org/ [1] https://github.com/rikusalminen/slolog https://github.com/rikusalminen/slolog
- joe_the_user 10y agoWell, The logic programming language that is used most for real world problems is SQL (the database query language). Now, SQL may be terrible as a logic programming language (in terms of purity, generality, etc) but it's one of those things where because it's there and it's capacities are good enough for a lot of purposes, it gets used more than tools that one has to go out of one's way to find/use. Further, note that SQL is widely reviled, partly for it's irregularity but also for the complexity that is inherent to large SQL expressions. It seems likely to me that if Prolog ever gained the popularity of SQL, there would be umpteen OO packages out there promising to "tame the complexity of Prolog" with one or another OO wrapper, an approach which I assume would leave pure logic programmers aghast.
- mossmoth 10y agoI do not think you are correct in saying that SQL is a logic programming language. A logic programming language is defined in terms of rules/implications[1], which SQL is not. However, it is a declarative language, which Prolog also is. In a declarative language you state what a solution is[2] (which the program then searches for), in contrast to the more traditional type of programming (imperative) that states how to obtain a solution. [1] - https://en.m.wikipedia.org/wiki/Logic_programming https://en.m.wikipedia.org/wiki/Logic_programming [2] - https://en.m.wikipedia.org/wiki/Declarative_programming https://en.m.wikipedia.org/wiki/Declarative_programming
- joe_the_user 10y agoWell, If you look at my whole post, I hope it's clear I'm not trying to say SQL is formally anything, just that it's effectively a logic programming language. IE in an ad-hoc sort-of way SQL can accomplish what a more formal logic programming language accomplish, more or less. You specify a world as a set of tuples and determine whether one set of relations determines another set of relations. That lets you do essentially what prolog can do - for example you can map all the example in the parent article to SQL pretty easily.
- tom_mellior 10y ago
- doublec 10y agoIt's popular to embed a prolog in Lisp languages. For example Picolisp and Shen. I wrote a post comparing Shen's Prolog support to SWI Prolog recently: https://bluishcoder.co.nz/2016/08/30/kicking-the-tires-of-shen-prolog.html https://bluishcoder.co.nz/2016/08/30/kicking-the-tires-of-sh...
- throwaway7645 10y agoIs the license for Shen still that you own a copy of Tarver's book?
- doublec 10y agoThere's a BSD licensed open source version, all linked from http://shenlanguage.org/download_form.html http://shenlanguage.org/download_form.html That's what I used for my post. There's "Shen Professional" which is a closed source subscription based product getting rapid development http://shenlanguage.org/professional.html http://shenlanguage.org/professional.html I have not used "Shen Professional" though.
- throwaway7645 10y agoThat's good news...curious if he has any customers for the professional version. I'm sure it's a great product, I'm just not aware of too many people who would depend on something that niche' for production work. Maybe niche production work :)
- skybrian 10y agoIn mainstream languages you can embed a rules engine [1]. But there are the usual issues with embedding another language - you don't do it for something trivial, just when you really need it. Also, if you're going to use a rules engine, something less powerful than Prolog might be a better fit. [1] http://martinfowler.com/bliki/RulesEngine.html http://martinfowler.com/bliki/RulesEngine.html
- tom_mellior 10y ago> Why doesn't it get used more? Few people know it, even fewer people like it. It tends to be taught really badly. There are not many recent books, and the old ones teach an outdated pre-ISO-standard language and tend to overemphasize use of the cut (!) operator. Practical aspects needed to build "real-world" systems are almost never discussed. (Interfacing with the operating system in various ways, exceptions and other ways of robust error handling, judicious use of mutable data structures when needed, debugging, profiling, optimization, ...) But yes, if you get over all these hurdles, it's useful for many things. > And can you interface to it using Python or some more mainstream languages? Yes, but you might have to go through foreign function interfaces that are painful from both ends. Or, depending on circumstances, you can just use text files (or pipes) to communicate with an external program written in the other language.