5 ms·
Prolog was on my list of "neat to learn languages" but I never got around to it. Any Prolog fans here to sing its praises?
by pstuart 13y ago
Prolog was on my list of "neat to learn languages" but I never got around to it.
Any Prolog fans here to sing its praises?
- m0nastic 13y agoThe Prolog class I took in college wound up being one of my favorite classes (although I was alone on that amongst all of my friends). I always liked the idea of declarative programming, it felt very natural when I first learned about it. That being said, I didn't have much use for Prolog after finishing that class. (I wrote one fairly small application at my first job, but really nothing else). I think that if you're interested by any of the recent developments around the Kanrens (or Core.Logic if you're a Clojure programmer), you'll find yourself better served by at least having a passing familiarity with Prolog. I also find that SQL feels to me quite a bit like Prolog (you have to sort of squint), and I find myself liking writing SQL way more than you're apparently supposed to from how much people complain about it online. That might have nothing to do with having learned Prolog, maybe my brain is just wired wrong.
- siddboots 13y ago> I also find that SQL feels to me quite a bit like Prolog (you have to sort of squint), and I find myself liking writing SQL way more than you're apparently supposed to from how much people complain about it online. That might have nothing to do with having learned Prolog, maybe my brain is just wired wrong. It's not just you. I'm in the process of writing "Euclid's Elements in SQL". It can be a beautiful thing if you think in relations, rather than tables.
- imglorp 13y agoSome solutions are very elegant and intuitive. It's probably the right tool for a number of jobs and the wrong one obviously for others. When you get pretty far into it, you start to get into several real-world realities. First is side effects. You have to decide how pure you want to be. Another question is efficiency. The first few chapters of most books will be about look how cool this stuff is. Then much of the rest will be exposing inner workings so you can word your solution to skirt problems or give the interpreter hints. Red and green cuts come to mind. One thing I'd really like to know is how well can the unification algorithm be split across multiple cores/processors. Erlang takes many features from Prolog, such as the syntax, and also solves a number of questions such as side effects and distribution, but I'm pretty sure they've omitted the unifier. It might be neat that was in there too.
- danieldk 13y agoProlog was on my list of "neat to learn languages" but I never got around to it. Any Prolog fans here to sing its praises? It's very well fit for writing computational grammars for natural language and parsers/generators. I have used it a lot during my PhD. Terms can be used to represent attribute-value structures and e.g. agreement can be checked and larger structures can be formed through term unification. I can really recommend this book: http://www.mtome.com/Publications/PNLA/prolog-digital.pdf http://www.mtome.com/Publications/PNLA/prolog-digital.pdf It is both an introduction to Prolog and to natural language processing, and shows the power of Prolog for such applications.
- kriro 13y agoInteresting, I'm working on a project that uses rules based agents but I am actually going to use ANTLR4 instead of Prolog for the grammar/parsing. It feels very odd because this is supposed to be one of Prolog's strengths. Basically what I do is generate Prolog code (via ANTLR) from a rule description of an agent (a custom DSL). My main motivation (outside of ANTLR seems neat, I want to play with it) is that I might eventually generate non-Prolog code from the DSL-code.
- agilebyte 13y agoGo for it if you'd like to learn a natural language. Nothing worked for me as well as making a basic French language grammar parser. It is beautiful to throw some rules at it and then get the number of sentences I can construct out.
- benjamta 13y agoWe use Prolog extensively at RainBird - I could definitely be considered a fan! As always it's about using the right tool for the job. Prolog is a great choice for many symbolic type problems. We use it as the basis of our knowledge representation and inference platform. Prolog is often considered too slow for production use. Again this depends on how you're using it, use it for solving the right kind of problems and it's quick. Very quick. Using multithreaded SWI-Prolog and it's C++ foreign language interface we're able to reason over large data sets with hundreds of thousands of concepts very quickly indeed. Another common misconception is that you need to be a logician with a background in formal logic to work with Prolog. You don't. You need to get your head round declarative programming, which can take a while if you're not used to it. It's worth the effort though, even just so you've got a new technique for your toolbox.
- Argorak 13y agoLet me sing half a praise: I learned Prolog at university through three courses and learned to love it for a certain set of problems. Everything with multiple outcomes or things that map well to descriptions trough constraints are very easy in prolog. Conceptually, it is well removed from other languages and therefore worthwhile learning. Prolog naturally teaches you interesting approaches to work with data. Writing parts of my software in Prolog is still an option for me. Practically, though, it suffers from real world problems: there are quite a few of runtime systems, dropping in and out of maintenance every once in a while. Lots of things are semi-standard, for example each runtime ships with a constraint library with different behavior. (e.g. in one Prolog, applying a constraint to a variable that already has a value is an error, in others, it is allowed if the variable satisfies the constraint). Prolog is really more a family of languages, sharing a similar syntax.
- kriro 13y agoPersonally I think Prolog is excellent for anything that can be thought of in rules and it's obviously strong in constraint solving situations. Most Prologs I have used are lacking in what I'd call "plumbing". I/O in particular feels fairly strange, web libraries etc. are low level (no MVC framework I'm aware of). A combination of Java and Prolog works quite well (technically any JVM language I suppose). Most Prologs provide a good Java connector (they usually also have C/C++, sometimes .NET and Python + sockets). Tomcat+JavaScript+HTML+CSS+database of choice and Prolog for the logic is a good combination.