31 ms·
The only languages I know that can do prolog-like-constructs as-a-library are lisps, or at least langs that have reasonable symbol constructs. Usability is way
by JoelMcCracken 9mo ago
The only languages I know that can do prolog-like-constructs as-a-library are lisps, or at least langs that have reasonable symbol constructs. Usability is way way worse if you can’t talk about variables as first class objects.
I was talking to Bob Harper about this specific issue (context was why macro systems are important to me) and his answer was “you can just write a separate programming language”. Which I get.
But all of this is just to say that doing relational-programming-as-a-library has a ton of issues unless your language supports certain things.
- vlovich123 9mo agoI believe Rust uses datafrog, Datalog as a library to implement some of its next gen solvers for traits and lifetimes. Not a lisp and maybe this still isn’t as elegant as you had in mind? Curious how this library compares for you. https://github.com/rust-lang/datafrog https://github.com/rust-lang/datafrog
- eru 9mo agoHaskell can do the same, and does with a lot of little embedded DSLs.
- JoelMcCracken 9mo agoYea I’ve wanted to try using logict to do some larger logic programming stuff. I’ve done it with list monad but found a lot of speed issues, never quite figured out why it was so slow.
- eru 9mo agoWell, lists are really slow. To be more precise: lists in your code can be really fast, if the compiler can find a way to never actually have lists in the binary it produces. If it actually has to have lists at runtime, it's generally not all that fast.
- JoelMcCracken 9mo agoYeah I figured that, but the combinations I was dealing with really weren’t that many. The problem was https://xmonader.github.io/prolog/2018/12/21/solving-murder-prolog.html https://xmonader.github.io/prolog/2018/12/21/solving-murder-... and trying to solve it with list monad. Someday I hope to get back to it.
- brabel 9mo agoIf you want to see what it looks like when you actually embed Datalog in your language, have a look at Flix: https://flix.dev/ https://flix.dev/ (Select the "Usinag Datalog..." example in the code sample dropdown) The Rust code looks completely "procedural"... it's like building a DOM document using `node.addElement(...)` instead of, say, writing HTML. People universally prefer the declarative alternative given the choice.
- debugnik 9mo agoThe experimental "Polonius" borrow checker was first implemented with datafrog, but I believe it's been abandoned in favour of a revised (also "Polonius") datalog-less algorithm.