

TuProlog: Making Prolog Ubiquitous - mjn
http://www.cs.nmsu.edu/ALP/2013/10/tuprolog-making-prolog-ubiquitous/

======
demallien
I have a question that I have often wanted to ask of someone that knows
something about declarative programming. In my day job, I spend most of my
time worrying about trying to make my code run faster (I do low-level user-
interface work - building the libraries that application UIs then use, so it's
all about moving pixels as fast as possible, getting data to the app as fast
as possible etc. If I need to make a SW blit run faster, I go into the
function doing the blit, and I may replace some of the C code with some SSE-
style vectorised assembler. Or I may choose to run an expensive SQL query once
a day, storing the result in a binary file that is then used to feed
application data requests, or other things of that nature.

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?

~~~
maaku
> I just don't see how those kinds of optimisations could be done in a
> declarative language.

Not to be an ass, but why not? All of your examples are, in principle, doable
in a declarative language.

~~~
louthy
> Not to be an ass, but why not?

He's not saying it can't be done, he wants to ask "someone that knows
something about declarative programming".

------
lylejohnson
We used tuProlog for rule-based intelligent agents in several applications and
it worked pretty well, but its poor performance eventually led us to look for
alternative implementations. That was about five years ago, though, and
perhaps it has improved.

~~~
xerophtye
Nice to see SOMEONE mentioned its use in rule-based AI. I find it rather
confusing how everyone only mentions its use in NLP and harldy ever AI. Anyone
care to comment on it?

------
kriro
For anyone interested in Prolog the usual book recommendations are:

"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).

------
tluyben2
I really like Mercury[1] so good to see anything Prolog up here. Prolog was
the first language I learnt from a theoretical point of view (first learning
the in depth language theory before writing a line of code) at university and
I have always liked it since.

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.

[1] [http://mercurylang.org/](http://mercurylang.org/)

------
alexatkeplar
A couple of other interesting applications of Prolog I haven't seen mentioned
yet:

Cascalog, Prolog-inspired data processing and querying library for Clojure:
[https://github.com/nathanmarz/cascalog](https://github.com/nathanmarz/cascalog)

Marelle, test-driven devops in SWI-Prolog:
[https://github.com/larsyencken/marelle](https://github.com/larsyencken/marelle)

------
pstuart
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
The 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
> 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.

------
jheriko
i see no mention of a C ABI interface - this is the one truly cross platform
interface we have which has no prior dependency, and it is at the native
level.

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...

~~~
lylejohnson
tuProlog does not offer an interface directly to C code. It's implemented in
Java and does provide a decent interface to Java code. I suppose you could
develop a JNI interface to your C library code, and then interface tuProlog
with that, but that's admittedly a complicated approach.

