http://web.archive.org/web/20030213072337/http://www.vanx.or...
Here's a (rather snarky) LtU comment by Peter Van Roy pointing to other designs improving on the WAM - http://lambda-the-ultimate.org/classic/message1618.html#1108...
> 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 .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.
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.
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
I agree that something as easy to embed from C or languages with C-embedding hooks would be nice.
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.
http://yieldprolog.sourceforge.net/
"Yield Prolog lets you embed Prolog programs directly in Python, C# [1] or Javascript [2] by using the yield keyword."
Lua and SQLite are both great examples of libraries whose APIs make them straightforward to embed in other languages.
I guess for C the API would need to be very different like Lua's C API, but that's life.
I'm thinking something like Lua's C API, both because I know it well and because its design does a particularly good job of bridging C and a dynamically-typed language.
I don't think Prolog is practical as a fully standalone language, though. Like SQL, it has a model that strongly skews it towards certain kinds of problems, and which makes I/O and side effects awkward. 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. (Writing one is on my project TODO list. I've been reading quite a bit about Prolog implementation.)
To me, the single most interesting aspect of Prolog is computing with partial information via logic variables: variables that are constant, but don't necessarily have to be bound immediately. Conceptually, the variables always have some specific value, but you didn't know until they were bound. You can pass around structures with holes in them to use as templates in pattern matching, append lists by binding the "hole" at the end of a list to another's head ("difference lists"), etc., while still keeping the advantages of immutability. Most languages descended from Prolog (Mercury, Erlang) drop logic variables, though Oz keeps them.
Another kind of computing with partial information is constraint programming, which makes Prolog much, much less dumb. Generate-and-test is great for prototyping, but quickly shows its limits with combinatorial problems - where constraint programming excels. Most major Prolog implementations come with constraint programming extensions, and they address many of its weak points.
There's also Erlang. Erlang seems like a very modern, practical evolution of the declarative + concurrent direction that some logic programming research was going. If you remove backtracking (which makes handling concurrency far more difficult), then I/O also becomes feasible. Erlang keeps much of Prolog's declarative-ness, and adds several powerful features of its own.