Prolog feels like one of those things I definitely couldn't write a whole app in, but I often wish it was just there in other languages the same way regex is.
I agree that embedding Prolog is a compelling use case. I ported Trealla Prolog to WASM to help the cause. It's super cool being able to store some business rules as a chunk of Prolog text and run them on both the backend and the frontend as-is.
Want to explore your code, maybe test out some quick changes? Prolog comes with a nice REPL. Want to modify the knowledgebase? Add some clauses with assertz/1 and dump out the full program code with listing/0; no need to wrangle the text yourself. Want to make a previously static relationship more dynamic? Just throw in a new rule: as far as Prolog is concerned rules and facts are equal citizens. It's like a database that lets you intermix static and dynamic row definitions anywhere you want. Testing it is easy: Prolog will happily give you every possible result for a general query. Want to generate error messages from chunks of code, or run your queries backwards? Just throw in a little metainterpreter[1].
I think Prolog is the perfect companion language to static and difficult-to-extend languages like Go. I think that if we want Prolog to become more popular, we should focus on a great embedding experience for developers. That's my current goal :)
I went through a struggle trying to implement an MMI for a telecom product using Prolog, it was just not performant enough.
Around the same time, Joe Armstrong of Ericsson was experimenting with Prolog to build a switching system. Erlang came out of that effort, essentially stripping out the backtracking - wish I had thought of that.
Elixir is built on Erlang and is definitely a production language.
None of this should be its own language, I'm not sure why people are still working in that direction when it's been clear for nearly decades that it's barely possible to use as a standalone language. Like if somebody implemented Tensorflow in its own separate weird language and insisted that's the best and only way to use it.
I think people are far too constrained by adhering to what Prolog is standardized as, making sure there's literally no advancement whatsoever. We just need a more practical formal logic library or type or something for your average language without any stupid string definitions or passing literal prolog in for execution. I mean is that too much to ask?
I so wish there was a complete prolog implementation exactly like this in pretty much any language I use. Unfortunately they always end up being woefully incomplete.
> Prolog feels like one of those things I definitely couldn’t write a whole app in, but I often wish it was just there in other languages the same way regex is.
Embedding prolog (or limited versions, like Datalog, or versions of Prolog or Datalog extended with probabilistic, temporal, or other features), or other logic sublanguages like MiniKanren, in other languages isn’t particularly uncommon.
Totally. I wrote a network management system with a prolog rules engine years ago.
It was amazing when my colleague and I figured out how to integrate that system with our Oracle database in real-time. Having a prolog engine embedded that way made it incredibly powerful to manage and alert on pretty complex relationships.
I agree, that's why I made this : https://github.com/smallbard/SharpLogic to embed it in c# (in order to use it as easily as Linq).
It's a work in progress (a very fun one!)
I'd like a spec language which takes constraints and compiles code them into target language. This way, we can design features at a higher level and don't have to get lost in forests of ifs, tree searches, caching mechanisms and multi layer state machines.
One clever hack I've seen is Yield Prolog (https://yieldprolog.sourceforge.net/) which basically translates the querying/backtracking execution model into mainstream language syntax - such as JS, Python or C# - using the `yield` keyword and loops. Supports things like variable unification, too.
Having a compiler that supports multiple full languages with required consistent ABI at those boundaries is something we really could use. Then you could have a prolog layer for things where it makes sense mixed with an Algol or ML or whatever based language for the rest of the logic. Similar to what .NET has done-ish, but wider ranging is what I'd love to see.