TuProlog: Making Prolog Ubiquitous
cs.nmsu.edu
cs.nmsu.edu
I just don't see how those kinds of optimisations could be done in a declarative language. Do I just have an unusual use-case, or are these languages seriously constrained with respect to the types of programs that they can be used for?
Declarative languages tend to lend themselves to being used at a much higher level, for example easily encoding rules regarding salary payments rather than low level bit twiddling.
Not to be an ass, but why not? All of your examples are, in principle, doable in a declarative language.
He's not saying it can't be done, he wants to ask "someone that knows something about declarative programming".
(ps i work in games and vfx - similar restrictions)
although i guess there is no reason why you can't make declarative performance constraints ...
"Programming Prolog" (Mellish & Clocksin), "The Art of Prolog" (as a first/second book), "The Craft of Prolog" (as an advanced book for later)
I don't own the first one but "Art of Prolog" was a little over my head when I got it (maybe I'm not that smart) and the typical "family database" examples are kind of tedious. I've worked through a couple of books now and the first book I'd recommend these days is "Prolog Programming for Artificial Intelligence". Don't let the AI in the title distract you, Part 1 is a very good introduction to Prolog (the best I'm aware of) and Part 2 covers typical AI topics (also very interesting of course).
I try to create things with Mercury but it's so fresh that it's rather hard; almost no-one is using it so when something goes wrong (which it will do when trying to do real-life stuff and linking libraries to do) there are not many people to ask and the people who are working with it are rather busy.
Anyway; Prolog is a nice language for some use cases; try it.
Cascalog, Prolog-inspired data processing and querying library for Clojure: https://github.com/nathanmarz/cascalog
Marelle, test-driven devops in SWI-Prolog: https://github.com/larsyencken/marelle
Any Prolog fans here to sing its praises?
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.
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.
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.
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
It is both an introduction to Prolog and to natural language processing, and shows the power of Prolog for such applications.
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.
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.
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.
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.
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.
it utterly boggles my mind how this is not the first thing mentioned or used. maybe it is just in there anyway and i need to find out. will definitely take a look at this as a fan of prolog anyway. :)
SWI-Prolog provides C interface for instance...