News for hackers. Stuff that matters.
Re:Who killed Prolog? by wazoox on Tuesday August 31, 2010 @08:34AM (#1649151)

  > I think it would be best to have a Prolog-like language 
  > as a library (like Lua or SQLite), to embed it for rules 
  > & scripting. 
You may be interested to know that there are various prolog Perl modules on CPAN, particularly AI::Prolog and Language::Prolog::Yaswi .
Re:Who killed Prolog? by silentbicycle on Tuesday August 31, 2010 @08:48AM (#1649177)
Perl isn't really my thing* , but I'll take a look at how they're implemented. I was thinking a C library with a C API that will make it easy to use from Lua, Python, Ruby, etc. Yaswi is probably just a wrapper to SWI-Prolog. There are a few of those, and I'm tempted to write one for Lua.

I think designing a Prolog-like language primarily for embedding, rather than wrapping a standalone Prolog, will have an interesting effect on the design though - Lua, for example, benefits tremendously from being able to leave certain issues to C. An embedded logic language could likewise focus on what it does best.

* Somebody is probably going to pop out of the woodwork and say that my impression of Perl is based on Perl 10 years ago. They're right, as that's roughly when I switched to Python. It'd be tough to convince me to switch back, though. I'm fine with awk for "tiny Perl script" hacks, and prefer other languages for larger stuff.

Re:Who killed Prolog? by sharkbot on Tuesday August 31, 2010 @10:46AM (#1649534)
Check out js-prolog: http://ioctl.org/logic/jsprolog-history

It's a quick-and-dirty implementation of a Prolog interpreter, but it's a great resource for prototyping. JavaScript ports very well to Lua, so you should be able to port the code in a busy afternoon.

I made a couple of suggestions to increase the speed of the interpretation, but I'm not sure Jan ever integrated them into the code. The big one was using a trace to destructively modify environments rather than recreating them on choice points; WAM and tabling would be great, but it's a non-trivial piece of work following Warren's tech report, even with the help of the (very good) tutorial.

Re:Who killed Prolog? by silentbicycle on Tuesday August 31, 2010 @11:00AM (#1649570)
Thanks! That looks fun.

I'm planning on doing a C VM-based implementation with tabling* . I'm not sure about coroutines, and the VM will not necessarily follow the WAM design verbatim - Peter Van Roy has several suggestions for improvements in his thesis.

* Prolog-ese for memoization

Re:Who killed Prolog? by _delirium on Tuesday August 31, 2010 @03:04PM (#1650524)
The nicest embeddable Prologs I've found are, for whatever reason, in Java. I use Tuprolog (http://alice.unibo.it/xwiki/bin/view/Tuprolog/) a bit, which embeds a Prolog interpreter pretty cleanly. There's also a compiler, PrologCafe (http://kaminari.scitec.kobe-u.ac.jp/PrologCafe/), though I find it a little harder to use seamlessly.

I agree that something as easy to embed from C or languages with C-embedding hooks would be nice.

Re:Who killed Prolog? by silentbicycle on Tuesday August 31, 2010 @05:21PM (#1650908)
It's odd that there isn't a C one, really. I've done very little with Java and the JVM, but hopefully those will prove helpful to someone else.

I don't have a time frame for a C-embedded Prolog (I've already got several other projects I'm trying to finish), but it's high on my list.

Re:Who killed Prolog? by ableal on Tuesday August 31, 2010 @12:22PM (#1649880)
I saw this one pass by a few weeks ago, it may interest you:

http://yieldprolog.sourceforge.net/

"Yield Prolog lets you embed Prolog programs directly in Python, C# [1] or Javascript [2] by using the yield keyword."

Re:Who killed Prolog? by silentbicycle on Tuesday August 31, 2010 @12:50PM (#1650004)
If it's implemented in C with a simple API, it should be easy to use from anything that has a C FFI. I'd rather not make it too language-specific - there's a huge duplication of effort as new languages appear.

Lua and SQLite are both great examples of libraries whose APIs make them straightforward to embed in other languages.