Question

I would like to listen from people who have real world programming experience in using swi-prolog's semantic library.

Edit: The reason for this question is, among the many people I talked to with prolog experience, most of them seem to have used it for some AI programming in their academic projects. I wanted to know if someone have used it widely in a production environment. Because real time maintainability, performance is different from having a project done to get good grades.

How did you integrate with a programming language like Java?

Edit: As mentioned in the answer, it seems REST Services or usage of swi prolog's foreign interface are the two best options.

What did you use prolog libraries for (in context of semantic web)?

Probably will not get a definite answer for this here. May be, this question belongs to semantic overflow. I have a fair idea now and will continue this discussion in more appropriate forum.

What development environment was used? Emacs or its variant provided by swi prolog seems to be the overwhelming answer.

I never wanted an IDE like Intellij IDEA for java. After all what would I do, auto complete? I understand the necessity of rule based language. Then again, the reason why I discussed development environment, is to help me trace my rule (debug ) and also probably identify anomalies in my knowledge sets.Swi prolog graphical tracer takes care of the first requirement, but at least to me, it appeared shoddy and limited. But I do not believe there is anything else.

I really like the idea of using swi prolog but will steer away from it, if it affects productivity.

As mentioned in the answer, prolog should be used to perform what it is good at. I always knew this and hence my question on integration with other programming language. It seems the biggest productivity hog is the quality of developers and is in development phase. Problems in your system might be dormant and not easily fixable, but it could be handled by using a set of questions for checking the validity of your system.

Note: when I mention answer, I mean the answer provided by @littletable. Also for people interested in swi prolog for semantic web, thea looks interesting.

Was it helpful?

Solution

Disclaimer: I did not use SWI-Prolog in a commercial/production environment, I did not try the SWI/Java interface (although it was reported on the SWI-Prolog mailing list to work reasonably well), and I have no interest in the semantic web.

That said, I did write a large and non-trivial project using SWI-Prolog, and it wasn't a toy application - I needed it to work in order to finish my research. Therefore I have some credentials for answering this question, even if not all of the required ones.

In the context of a large project, it is best to treat Prolog as a domain-specific language for writing search routines - Not unlike SQL and storage. Prolog does one thing extremely well, and that it solving search problems. If your problem can be narrowed down to finding a valid assignment to a set of variables given a set of facts and rules, Prolog is your weapon-of-choice: You won't have to worry about anything else in your coding other than tweaking the queries and rules. It will also run reasonably fast, especially if you compile the predicates. Prolog is often slow not because it is inherently slow, but because it runs search routines over a large search space.

Keeping that in mind, you can integrate it with Java in a similar manner you integrate SQL: Prolog takes care about solving the search. It stores the permanent data and the rules, and run the queries. The Java app takes care of anything else.

Development environments are a bit of a soft-spot for Prolog. You won't get a fancy IDE - Simply because there are very few things to be fancy about. Prolog programs rarely have full compile-time information, so you won't get perfect auto-completion. I simply used Emacs, with the Prolog shell always open. For most things, the Prolog textual tracer/debugger will do the trick. SWI comes with its-own graphical debugger, but I haven't tried it.

Prolog has several rarely-known advantages: A built-in parsing framework (DCG rules), a great macros system (term expansion), and meta-predicates (call, findall, etc.). If you know how to use them, these are real aces in your deck.

To summarize: Does Prolog boosts or damages productivity? That depends on what currently blocks your productivity. If you waste too much time wondering how to implement knowledge representation and search routines in Java - Just use Prolog; It's not as if you implement your-own red-black trees instead of using SQL. If you're looking for soft-realtime performance and a spoiling IDE - Try something else.

OTHER TIPS

I did not really use it in a production environment either, but I integrated it into the Java/Eclipse based Bioclipse workbench, to be used in real-world scenarios, as part of my thesis work. Also, the thesis work focused much on testing the performance and usability of the prolog integration in Bioclipse.

I will give short answers to the questions you asked below, but for anyone interested, the most information can be found in my thesis report named "SWI-Prolog as a Semantic Web Tool for semantic querying in Bioclipse: Integration and performance benchmarking", as well as in my relevantly tagged blog posts. The source code is available in a github repo.

How did you integrate with a programming language like Java?

I used the the JPL Java Prolog interface

What did you use prolog libraries for (in context of semantic web)?

I used it to do some pattern matching against an RDF database of some 60000 NMR spectra, containing peaks of distinct heights. I used this to test the performance of SWI-Prolog for this operation, compared to other Semantic Web tools such as Pellet and Jena (Java based). (BTW, SWI-Prolog by far outperformed both of these tools).

What development environment was used?

Eclipse RCP

I really like the idea of using swi prolog but will steer away from it, if it affects productivity.

My experience is that in addition to increased productivity for certain problems, the performance for certain operations is also far better than tools written in conventional programming languages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top