5 ms·
I have a Prolog book, somewhere. Prolog feels like a really useful feature was hauled out of some other programming language and made to stand on its own. Lik
by at_a_remove 4y ago
I have a Prolog book, somewhere.
Prolog feels like a really useful feature was hauled out of some other programming language and made to stand on its own. Like if I pulled regular expressions out of Perl and tried to make them their own language.
- cheaprentalyeti 4y agoI highly suggest the wikipedia entry [0] on regular expressions and their history; the concept goes back to at least a couple decades before Perl, which incorporated them via a c library written by Henry Spencer a couple years before Perl even existed. [0]: https://en.wikipedia.org/wiki/Regular_expression https://en.wikipedia.org/wiki/Regular_expression
- jjtheblunt 4y agothey are their own language class...the regular languages, at least in pure form, not the pcre extended regular expressions (which would be a different language class). https://a.co/d/a5FGZRQ https://a.co/d/a5FGZRQ
- galaxyLogic 4y agoGood point. Most programming languages have RegExp support. But very few (?) have Prolog support. That might be useful in some or many cases, like ...
- bandrami 4y agoThe pattern matching capability in the ML family is arguably an embedded Prolog system.
- felixyz 4y agoIt might partially have been inspired by Prolog, in fact. But it lacks backtracking and unification so I don't think it qualifies as an embedded Prolog system. Erlang allows so-called non-linear patterns (ie using the same variable for several argument positions, implying equality), which comes slightly closer to Prolog (and of course, Erlang was originally modeled on Prolog, but the apple ended up far from the tree).
- gnulinux 4y agoAt compile-time, sure. But ML-like languages in general have no support for runtime logical programming. They don't provide an API to do things like type inference at runtime. For a good reason too, the only possible way type inference in ML-like languages work is because the computational cost is abstracted away from the runtime. Logical programming (ala Prolog) is very useful but the truth is it's asymptotically inefficient. Standard ML's type inference algorithm was, for example, asymptotically exponential. It just so happened that for useful programs it halts in a reasonable amount of time. This is not something you can provide an API for so that at runtime you can run arbitrary type inferences.
- mechanicum 4y agoIt’s not Prolog, but the related miniKanren has been widely implemented.
- varranvar 4y agominiKanren is not nearly as efficient as Prolog though.
- galaxyLogic 4y agoI understand that Prolog is good for creating parsers, right? Then could it to a large extent be a replacement for RegExps, providing more powerful ways to do string-manipulation.
- User23 4y agoEmbedding prolog in Common Lisp was pretty normal during the first wave of AI, as I understand it. There’s always been an odd irrational hostility to Lisp, so I wouldn’t be surprised if Prolog feels as it does to you exactly for the reason you suspect.
- kryptiskt 4y agoAwk is that language. Perl was created as a more capable replacement for that, Awk++ if you will.
- rjh29 4y agoYeah, imagine if Python had a 'declare these two things are equal' operator and let you just randomly summon up computations declaratively, but with all of the python standard library and data structures. That would be more approachable than Prolog imo.
- mst 4y agoTake https://p3rl.org/Language::Prolog::Yaswi https://p3rl.org/Language::Prolog::Yaswi and steal the ideas into python then, you can probably at least get close to sqlalchemy style in terms of surface syntax at the python level. (the perl community has implemented and released many strange and wonderful things, often years before other languages' communities noticed they were there (because we're weird), and while it's entirely reasonable to dislike perl as a language it's well worth looking at the things we've perpetrated over the years and stealing the parts you like for your language of choice :)
- rjh29 4y agoI'm a longtime Perl user but didn't know about that library, thanks for the link.
- mst 4y agoFunnily enough, perl has both a native prolog implementation AI::Prolog (which is not amazingly fast but serviceable for simple cases) and Language::Prolog::Yaswi, which is bindings to SWI prolog with a perl-native DSL if you want it.