152 points · by yeesian · 3y ago · 176 comments
If you're trying to solve more general problems, you probably want an SMT solver or other more specific solver (e.g., ILP), not Prolog.
If you're trying to verify software, you want a theorem prover, not Prolog.
If you want database-ish stuff you want Datalog (or something like it), not Prolog.
Prolog falls into the uncanny valley of being too general of a DSL for the sorts of optimizations that more narrow solvers enjoy, while being too narrow of a DSL for most general-purpose programming. I think because it was an early DSL, people got caught up in the idea of it being more "high-level" than other languages [1], but the DSL nature of it wasn't fully appreciated at the time.
[1]: For fun, take a read through https://en.wikipedia.org/wiki/Fifth-generation_programming_l... , which was a whole thing in the 1980s.
But again and again one uses extralogical constructs in Prolog programming.
Case in point: basically all your mentioned alternatives (Datalog, SMT, I'd add ASP) have implementations that use the Prolog syntax or something close to it with very similar semantics. But not being tied to that specific execution model can give you (better) answers or more complete answers, termination guarantees, or other things we might need.
To clarify, datalog is a restriction of Prolog excluding functions of more than 0 arguments (i.e. constants). For example, P(x,y) :- Q(f(x), g(y)) is Prolog but not datalog. There's also a restriction in the sharing of variables between head and body literals that ensures termination. The point of datalog is that because of its function-free structure it's decidable. You could simply ground a datalog program and get its entire Herbrand model.
SMT, I don't know much about. It's got nothing to do with Prolog, as far as I know. It's not a programming language, but a framework for boolean constraint solving. I don't know why it (or SAT) is compared to Prolog which has nothing to do with boolean satisfiability problems.
ASP also has nothing much to do with Prolog. It's a strictly first-order language (Prolog is higher-order) that is based on the idea of stable model semantics. Very briefly, a stable model is often the set of queries to which Prolog will answer "true" (or "yes" depending on the interpreter). ASP programs share some syntax with Prolog, but are not definite programs. For one thing, ASP allows classical negation, alongside Prolog's Negation-As-Failure. ASP is said to be well-suited to optimisation problems but to me it's more interesting as a formal treatment of reasoning under uncertainty in a strictly logic framework.
Note that datalog is incomplete (obviously, since it doesn't have functions) and ASP solvers are NP-complete. They are also special-purpose languages, so for example nobody is going to write a web server in ASP anytime soon. By comparison, the SWI-Prolog website runs on a web server written in Prolog (https://eu.swi-prolog.org/dogfood.html).
SMT and SAT are certainly less expressive than Prolog (or more abstract systems, like LambdaProlog, Isabelle/HOL, etc.), so they cannot express the same structures/abstractions. However, given any "concrete" query/program, we can collapse all of its structure, in-line/unroll all of its higher-order parts, etc. to get a SAT formula (modulo the halting problem).
The resulting term is usually exponentially-larger than the original; but SAT solvers have become fast enough to handle such giant problems. (SMT solvers are usually wrappers around a SAT solver too)
sure, that's all true and most of that is part of my day-to-day research. But the post I replied to mentioned very specific problems where Prolog could be suitable at first glance but other models of computation / problem statement are usually preferred.
But most of those do have implementations that use Prolog-like syntax.
I think Prologs big strength amongst others is the meta interpreter and higher order functions which I think are essentially tied to SLD.
Prolog has predicates, not functions. (It has uninterpreted function symbols -- aka functors in this context.) It's based on first-order logic, i.e., it has nothing higher order in it, if you want to take it (formally) seriously. But of course there is `call/1` and so forth, which are just hacks... err, "non declarative".
There are some interesting higher-order logic programming languages, e.g. Mercury. I like the approach taken by HiLog [1] as it struck me as (semantically) honest and simple. I don't know if it's usable.
I think it’s biggest headwind is that you have to be significantly more intelligent than the average developer to think in Prolog.
Prolog requires you to think about code as the implication of constraints — you just have to keep a lot more in your head. Prolog also requires you to understand the execution model before you can do much of anything.
This is arguably wrong. Thinking in Prolog is much easier than knowing how to solve a problem beforehand. In Prolog you just state the facts and known rules, but you have no clear idea what would be the best way to solve it. Prolog solves it for you then, if possible. No intelligence needed. A "dumb" friend of mine on the 80ies only used Prolog for his work and was very happy with it. Lisp, Pascal or C was too hard for him.
The problem with Prolog is mostly that you'll through too hard problems at it, mostly with exponential complexity. Tiny changes have huge influences then, it either works or not. Also the tabling and SAT/SMT integration sucks.
You’ll have to gain an intuition of how the language actually tries so solve the problem under the hood.
sometimes the problem you encounter doesn’t match the capabilities of the language, and then you’ll have to state the problem in a roundabout way to coax the language to do what you intended.
It’s probably great for the small number of toy problems that it was designed to solve, but in my limited experience prolog doesn’t do well on real world problems that have all sorts of edge cases and dirty inputs.
While Prolog streamlines certain aspects of problem-solving due to its declarative nature, it still necessitates a clear understanding of the desired solution and the proper organization of facts and rules. Although Prolog's approach abstracts some implementation details, a well-planned strategy remains essential.
-------- > No intelligence needed.
Prolog might make some tasks seem simpler, but intelligence and a deep comprehension of logic programming are still needed to efficiently create and maintain solutions.
-------- > A "dumb" friend of mine on the 80ies only used Prolog for his work and was very happy with it. Lisp, Pascal or C was too hard for him.
I may be the "dumb" friend you referred to?
Consider this: someone skilled in producing valuable software using Prolog is likely knowledgeable and proficient enough to program professionally in various other languages, such as C, Lisp, C#, C++, Scala, Java, Pascal, Python, Assembly, and more.
As an experienced programmer with a strong background in multiple languages, I often receive requests to translate my Prolog software into languages like Python, Java, or C#. However, I usually decline and claim that "it would be too hard"
-------- > The problem with Prolog is mostly that you'll throw too hard problems at it, mostly with exponential complexity.
Prolog isn't inherently prone to exponential complexity problems. The complexity depends on the problem being solved and how the facts and rules are structured. It's crucial to understand the problem domain and optimize the Prolog code accordingly
The complexity of a problem and fluid nature of flow control shifts during software runtime often make it unfeasible to implement the software in alternative languages. So consequently, in the rare instances when I or others have attempted this, we have either developed or found a Prolog interpreter in the target language and executed the original code.
Had these tasks not been so daunting, others would have already implemented solutions to them in different languages, and there would be no need for people to continually request my assistance!
-------- > Tiny changes have huge influences then, it either works or not.
While it is true that small changes can sometimes have significant impacts on the behavior of a Prolog program, this is not unique to Prolog. Any programming language can experience similar issues if the underlying logic is not well-designed or properly tested. It is the developer's responsibility to understand the problem domain and design the logic appropriately to avoid unintended consequences.
-------- > Also the tabling and SAT/SMT integration sucks.
Tabling is a technique used in Prolog to store intermediate results of a computation to avoid redundant sub-computations, thus improving the efficiency of certain types of queries. While it may have some limitations, it is generally considered a valuable feature of Prolog that can enhance performance for specific types of problems.
Prolog's integration with SAT (Boolean Satisfiability) and SMT (Satisfiability Modulo Theories) solvers is not inherently flawed. Prolog can be used effectively in combination with these solvers to tackle complex problems in various domains. Integrating Prolog with these solvers might require a good understanding of the solver's functionality and the problem domain, but the same can be said for integrating any other programming language with these solvers. It's important to leverage the latest Prolog tools and libraries to optimize these aspects of your program.
> the facts and known rules, but you have no clear idea what would be the best way to solve it.
>
Prolog is a programming language that takes a unique approach to problem-solving due to its declarative nature. While this can simplify certain aspects, it is important to have a solid understanding of the problem you are trying to solve and how to properly organize the facts and rules. Even though Prolog can abstract some of the implementation details away, having a well-thought-out plan and strategy is still necessary to effectively use the language.
>
> No intelligence needed.
>
Although Prolog might make some tasks appear more straightforward, it is important to remember that intelligence and a comprehensive understanding of logic programming are still required to efficiently create and maintain solutions within the language.
>
> A "dumb" friend of mine in the 80s only used Prolog for his work and was very happy with it. Lisp, Pascal or C
> was too hard for him.
>
I may be the "dumb" friend you referred to?
Consider this: someone skilled in producing valuable software using Prolog is likely knowledgeable and proficient enough to program professionally in various other languages, such as C, Lisp, C#, C++, Scala, Java, Pascal, Python, Assembly, and more.
As an experienced programmer with a strong background in multiple languages, I often receive requests to translate my Prolog software into languages like Python, Java, or C#. However, I usually decline and claim that "it would be too hard" Had these tasks not been so daunting, others would have already implemented solutions to them in different languages, and there would be no need for people to continually request my assistance!
>
> The problem with Prolog is mostly that you'll throw too hard problems at it, mostly with exponential complexity.
>
Prolog is not inherently more susceptible to problems with exponential complexity than other programming languages. The complexity of a problem depends on the specific problem being addressed and how the facts and rules are organized within the Prolog code. To optimize Prolog code, it is essential to have a deep understanding of the problem domain and to structure the code in a way that minimizes complexity.
>
> Tiny changes have huge influences then, it either works or not.
>
It is true that small changes in a program can sometimes have a significant impact on its behavior. This is not a characteristic unique to Prolog; it can happen in any programming language if the underlying logic is not well-designed or properly tested. It is the responsibility of the developer to understand the problem domain and design the logic in such a way that it avoids unintended consequences, regardless of the programming language used.
>
> Also the tabling and SAT/SMT integration sucks.
>
Tabling is a technique in Prolog that stores intermediate results of a computation to prevent redundant sub-computations, thereby improving the efficiency of certain types of queries. Although it may have some limitations, tabling is generally considered a valuable feature of Prolog that can enhance performance for specific types of problems.
Prolog's integration with SAT (Boolean Satisfiability) and SMT (Satisfiability Modulo Theories) solvers is not inherently flawed. Prolog can be used effectively in combination with these solvers to tackle complex problems in various domains. Integrating Prolog with these solvers might require a good understanding of the solver's functionality and the problem domain, but the same can be said for integrating any other programming language with these solvers. It's important to leverage the latest Prolog tools and libraries to optimize these aspects of your program.
This is true of most (all?) languages. Prolog's control flow is ultimately not too different from the usual stack-based semantics people are used to from imperative languages like C (if you're not too ambitious with the backtracking; if you are, best of luck!). The tricky part is perhaps understanding the dataflow that arises from unification. That can be arbitrarily complex but it seems people tend to go no further than difference structures, which are easy to comprehend in terms of pointers. (Yes yes I know, but logic variables are essentially just single-assignment pointers.)
The thing I find deeply weird about the logic programming literature is that if you want to reason about your program you're told to use things like Hoare logic [1] or intended interpretations [2] and not fundamental logical concepts like implementations implying specifications (ala Lamport and many others who grappled with refinement).
[1] see Krzysztof Apt's papers
[2] see e.g. https://people.eng.unimelb.edu.au/lee/papers/dd.html
Well no, I’d go as far as to say that your average JS/Python dev will know very little about how their code is executed — and doesn’t need to know necessarily. SQL on the other hand is a different story . Noobs don’t know , but pros know and consider the execution graph of a query.
You don’t really have a choice in Prolog —- gotta know what the interpreter is doing from the beginning otherwise you can’t debug.
This is very true!
Use Prolog to “reason about X”, is closer to the gist.
The real problem is that Prolog doesn't play nice with relational databases. (Too bad the people behind the short-lived NoSQL fad didn't know about Prolog, though.)
Only about 33% serious here, but… still a bit serious.
Or I guess you can see it as a DSL where the "Domain" is the entire set of programs computable by a Universal Turing Machine. It's a DSL for writing programs that manipulate programs that manipulate programs.
But, not really. It's just not a DSL.
I still love the language, but I think there's a point where every learner realizes it's not as beautiful and ideal as they once thought.
You see the same thing with the C preprocessor - there's a very good reason that basically no language since has copied that design, and it's infamous for being full of footguns.
A far simpler and more manageable solution is to generate the same data structure (the final manifest) in a language which can actually represent those data structures directly. That might be a dedicated language like Cue or Jsonnet, or it could just be a general purpose programming language. You can generate the data structure using whatever tools you like, and then render it to JSON or YAML to be consumed by whatever tool is uploading it to kubernetes (kubectl apply, helm, etc).
It looks like you can plugin in your own templating script to the helm stuff though, I was thinking that something like https://yglu.io could retain the essential YAML-ness for comprehensibility to others while not being completely ridiculous like using a text templating system is.
Jsonnet is one of the alternatives.
You really don’t have to go far in Prolog before you have to write a meta interpreter and think about search strategies.
I think this is in plain sight from the beginning.
What makes this problem really bad is that everything about your problem that isn't directly related to logic programming is much harder to do in pure prolog. Just reading in a list of facts from a CSV file is non-trivial in prolog.
In the end Prolog makes trivial but hard problems easy, while non-trivial hard problems remain hard to solve, and easy problems, even some trivial ones, also remain hard.
I still love Prolog as well because it really does change the way you think about programming, but it is very far from even Haskell in allowing you to extend these new ways of thinking to solving real world problems.
It's the sort of thing where people produce versions that seem to work, but fall into infinite loops or inconsistent extra outputs if you go past the first answer. I'm not sure it's actually possible without meta-programming.
:- use_module(library(clpfd)).
rle([], []).
rle([H],[[H, 1]]).
rle([H | T], [[H, CountPlus1] | More]) :-
Count #> 0,
CountPlus1 #= Count+1,
rle(T, [[H, Count] | More]).
rle([H | T], [[H, 1], [Element, Count] | More]) :-
Count #> 0,
dif(Element, H),
rle(T, [[Element, Count] | More]).
Even though I'm the one who was making the execution model complaint, this implementation seems to work for me. ?- rle([1,1,1,2,3,1,1],X), rle(Y, X).
X = [[1, 3], [2, 1], [3, 1], [1, 2]],
Y = [1, 1, 1, 2, 3, 1, 1] ;
false.But, why not use the cut? It's a feature of the language and it's there exactly so you don't have to bust your head trying to find a way to do things the hard way.
I honestly don't understand what's the fuss with the poor cut. If you want an efficient language that runs on a computer then you have to be pragmatic and recognise that concessions have to be made to accommodate the limitations of the hardware. If you want something pure and ideal, then you should probably not be trying to do that on a computer. You should probably not be trying to do it at all. There are no pure formal systems, or if there are, we can't explain or understand them because they can't communicate with the external world (hey, no side effects, OK?). See Haskell, for instance. The article above says something really strange about Haskell, that it:
>> ... finally broke through the wall of pure-functional programs being seen as ivory-tower languages that were impractical, or at least really awkward, for any system that needed to do I/O or interact with users
Which to me is insane. I think it's talking about monads. Monads, as an escape from the ivory tower, impractical, or at least awkward formalisms of... what, LISP? I mean for the love of dogs.
Prolog is a balanced language. People complain about it because it's not unbalanced, that's the problem. If it were 100% declarative and nobody could program anything in it, it would have legions of dotting admirers praising it for its perfection, and whining because they have to do all their work in languages that are hardly 10% declarative, like Rust, or Python or Ruby (and I'm being generous). People have to get their head around this: our computer science is primitive and it is full of holes, dark pits of despair and undecidability, intractability, and terminal inefficiency. To be practical, a language has to give up a little part of its true, pure self, that it could achieve in a perfect world. So Prolog has the cut, and you can use it to control its backtracking, which you need because it's implemented as a depth-first search, because that's efficient and convenient. So use the cut, it's a feature.
Also, XSB Prolog and SLG resolution[1] should be mentioned. It solves some of the problems with Prolog that force you to think about the execution model when you'd rather not. To some extent, this can be thought of as getting the good parts of both Datalog and Prolog.
SLG resolution was introduced in SWI-Prolog as well fairly recently[2].
[1]: https://www3.cs.stonybrook.edu/~sbprolog/manual1/node2.html [2]: https://www.swi-prolog.org/pldoc/man?section=tabling
[1] https://www.metalevel.at/prolog
[2] https://github.com/triska/the-power-of-prolog
[3] https://github.com/ML-KULeuven/problog
Just like functional languages inspire people to write "more functional" code in other languages, I think Prolog can inspire us to think in relations (SQL) and rules. Rules engines grew into monstrosities, but more light-weight rule engines exist and can be a great tool.
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.
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.
(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 :)
In the case of creating type-safe software, writing the interpreter in Prolog is a good idea, as it allows for code verification during runtime.
Lastly, if you wish to integrate code and database functionality, it is advisable to use Prolog to develop an enhanced Datalog system, which will offer a more powerful and flexible solution.
I do like Prolog though.
BNF provided a formal grammar allowing the declaration of precise and iterative constructs without additional complexity of algorithmic content. Original spec @ https://www.softwarepreservation.org/projects/ALGOL/paper/Ba...
BNF was created by Naur, the guy who invented FORTRAN, and was critical to both many early RFCs (the most important standards that facilitated the growth of the internet) and man pages in Unix. The syntax:
executable <required-arg> [optional-arg]
... is a legacy of BNF. https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_formI would argue that this can attract users better than the additional formalism you can obtain through logic programming, because once you have determined the validity and class (roughly "set membership") of something, you can potentially generalize about it more easily and you have a clear cognitive boundary.
Speaking from experience, in practice, I often rigidly define one layer of a system and then implement algorithms less rigidly using a less formal approach. This seems standard across the industry. Think about UUIDs, network addresses, etc.
I believe this type of tradeoff is ultimately what killed logic programming. If you really want to do maths, do maths. If you want to define something, do so succinctly. And if you are here to implement an algorithm, use the right tool. Don't pretend the code will write itself. Logic programming always seemed to me a sort of allusion to mathematical inference that didn't transfer well to real world programming problems.
Just my opinion.
Prolog has a use case, but it's just not that big.
I think it's fair to say that declarative programming can only work well for "simple" problems (i.e. not requiring turing equivalence), and the strongest wins are when a declarative approach is discerned that didn't seem possible - perhaps by slightly simplifying the problem, to cross this threshold.
"Declarative" is in my eyes an umbrella term for logic/relational and functional programming, but the word gets used in many ways.
Yes, the word gets used in many ways, that's basically it.
BTW there's injective programming (only one-to-one relations), so programs are reversible.
You can try running with what wikipedia says [1] or stack overflow [2]. You could say it's PL marketing terminology from the 1980s and 1990s (FP + Prolog v the world). Roughly these languages aren't based on the idea of changing state, but of course that idea eventually ends up in there somewhere (e.g. monads and laziness in Haskell, DCGs in Prolog).
On the positive side, I'd be comfortable saying that SQL is declarative.
I'd be wary about bringing Turing completeness in here. It seems irrelevant.
[1] https://en.wikipedia.org/wiki/Declarative_programming
[2] https://stackoverflow.com/questions/129628/what-is-declarati...
fp is declarative in the shallow sense of being immutable. But you can't just state what you want (e.g. what constraint programming languages enable); you must write a program. If fp is also declarative, what word is left for describing what I mean? Thus: misappropriation.
Not "Turing completeness", "Turing equivalence". Many very simple systems are turing equivalent, so they can exhibit arbitrary complexity. A mapping, from what you have to what you want, is an example of declarative programming. WYSIWYG is declarative. [But arguably this makes "declarative programming" an oxymoron... or we must call html a "programming" language]
Yes, SQL is a lot more declarative; the underlying relational algebra perhaps also is. Something that I'd personally like is a term for systems that enable you to specify the outcome as-is, rather than a composition of steps to achieve it. Perhaps I just want a word for this. I'll give an example:
(a+b)(x+y) -> ax+bx+ay+by
(declarative: "fully expanded form")
(a+b)(x+y) -> a(x+y)+b(x+y) -> ax+ay+b(x+y) -> ax+bx+ay+by
(steps: "distribute (x+y), distribute a, distribute b")
[1] I agree with wikipedia here: programs describe their desired results without explicitly listing commands or steps that must be performed.but not in the next sentence: Functional and logical programming languages are characterized by a declarative programming style.
because functional programs specify steps to be performed e.g. g(f(x)) rather than a state of affairs to be attained.
[2] Unfortunately I don't have time to fully read the SO question right now, but I note it's closed and there seems much contention in the comments.
A distinction from functional programming can be made by noting that in functional programming the input is a proof term, and in logic programming the output is a proof term (evaluation is proof search).
But excluding optimized domain-specific solvers which are making performance/expressiveness/termination tradeoffs, it doesn't seem obvious that programming via proof search has any definite complexity disadvantages in theory (assuming you encode the algorithm in a comparable way), though I admit in practice the existing implementations of logic programming are anemic when it comes to libraries, polish, etc.
Recently I have been working on getting Trealla Prolog to run in WebAssembly. Support is quite good now, with an easy-to-use JS library[1], Go library[2], and is now one of the best-supported languages for the Spin runtime[3]. I think it's particularly nice for validations, you can write some simple Prolog rules and run the same code on the client and the server now. I would like to explore this more with a dedicated library at some point. Built-in features like DCGs make parsing/generating all kinds of data trivial. I love it.
I think the biggest barrier to Prolog adoption is that it has a really steep learning curve, and most people get burnt by half-assed introductions in college that tick the 'talked about logic programming' box in the syllabus. You really have to think in a completely different way to write a good Prolog program. But, once you get the right mindset, it makes solving complex problems incredibly easy.
I don't really buy the argument that Datalog is enough. Most Datalog implementations I've seen hack on a bunch of extensions to do things like list membership. It would be awesome to see some serious effort put into an efficient Prolog-based database. The closest thing I can think of is TerminusDB, which I've never used but I wish I could convince my company to try it out ;).
My dream is to have some kind of magical serverless persistent Prolog interpreter in the cloud. That's where I hope to take this Wasm stuff at some point. Can you imagine how powerful it would be to use Prolog instead of GraphQL or whatever? Prolog is IMO the perfect language for querying things, with a 1:1 correspondence to how you write the data. It's like SQL without all the ugly bits (I like SQL too, of course). If this sounds cool to you, check out the paper/book on Web Prolog[4] which is a fascinating dive into what a Prolog-based networked query system could look like.
[1]: http://github.com/guregu/trealla-js
[2]: http://github.com/trealla-prolog/go
[3]: https://github.com/guregu/trealla#spin-components
[4]: https://github.com/Web-Prolog/swi-web-prolog/raw/master/book...
TypeDB[1] is also doing interesting things. Work on incremental view maintenance is also carrying the deductive database vision forward, but under another banner, such as Materialize[2] (based on Datalog, but speaks SQL) or pgsql-ivm[3].
[1]: vaticle.com/typedb [2]: materialize.com [3]: https://github.com/sraoss/pgsql-ivm/
[1] https://www.sciencedirect.com/science/article/pii/0743106694...
For me personally it was a great way to be introduced to different programming paradigms.
It's fine for a programming language to live in a niche.
I also did a Prolog course and I got to teach programming as a teaching assistant in Java to philosophy students that had Prolog as their only programming experience. So, they understood logic but not loops or assignments.
IMHO it's worth learning about Prolog as a way of looking at the world -- for instance Isabelle and Lambda Prolog are essentially logic programming engines, albeit with more sophisticated terms and unification algorithms.
[2] https://www.hpl.hp.com/techreports/Compaq-DEC/PRL-RR-36.pdf
As for modes, I'm not convinced they are really needed? I do feel they take away a lot of the beauty of Prolog, and a lot of the incentive to think in relations. (Or at least, I fear they do. I haven't actually programmed in Mercury. Would be happy to be proven wrong.)
As for modes, well! 1. they were needed for at least one Uni of Melbourne person to receive their PhD degree, and less facetiously 2. they are needed for efficient code generation. They can be inferred for this purpose. One use case you may consider is enforcing the correct dataflow in a DCG. Otherwise they are handy for preventing calls to predicates that would not terminate.
I've never programmed in Mercury but it really looks like an ML to me. It was beautifully engineered in the late 1990s and it's a shame it hasn't received more attention. Its FFI influenced the development of Haskell's.
a_list_processor([H|T], ..., ):-
process_list_head(H,Xs)
,process_list_tail(T,Ys)
, ...
Or at least you learn to do that quickly enough. And note that this implicit typing is used both to select clauses in a predicate, and also to index clauses in the Prolog program database by their first term (in which case the first term better be a constant though, not a list). So it's a bit of a bug-repellent, and a bit of an efficiency booster, both. Just like you get with static types.There is even a new language that allows to embed logic programming inside of "regular" (imperative/functional) programming code. Forgot the name though.
To be pedantic, almost nobody is using a pure functional language even modernly. Almost all languages that support functional programming are hybrid systems at this point in time, and still have anti-functional constructs such as classes and objects.
I dare say, it would be very difficult to maintain a large system that was purely functional. Some of the concepts revolving around OOP are indeed quite good and lead to better organized, more easily understood codebases.
The future is probably a hybrid approach, not a pure approach as some advocates would prefer.
Yeah every non academic language (that I know of) has escape hatches.
Still, you can (and many do) write your code in a 99,99% pfp style in e.g. Scala.
However, a Data Class without mutability and without functionality (besides accessors) is in-line with PFP.
Like I said, most modern systems are hybrids - taking the best of all paradigms instead of aligning with a singular paradigm as was done in the past.
And when exactly did that happen? And no, I am not about imperative languages incorporating some functional programming stuff. When did a "pure functional" PL become mainstream and widely used in professional software engineering?
Because as far as I can see, I see imperative languages dominating pretty much every field.
I don't think that contradicts my understanding of "take off".
The languages are not widely used. Rhey play a minor role at specialised applications in the industry. Almost everyone who learns programming uses imperative languages.
So what exactly is the definition of "take off" here? Because, other than Haskell having a bit of media-echo a couple years ago, and an army of fans promising things like "the future of programming", I don't see any takeoff.
Curry also deserves a mention, I think.
https://en.m.wikipedia.org/wiki/Curry_(programming_language)
Whether it is syntax convenience of C, Java, C#
Or batteries included convenience of Python.
It's a crying shame because we are stuck with the primitive expressiveness of 3rd generation, and are unlikely to break free any time soon if ever. We'd rather get some LLM to generate the reams of boiler plate required to do anything significant.
“The Japanese Did It” is not the correct answer to “Who Killed Prolog?”. Prolog was killed by the failure in the early 1980s of mainstream AI researchers to find out about Prolog, by their willingness to play along with the “appropriate responses” to FGCS, and by their use of FGCS’s failure as an excuse for continued neglect of a promising alternative to Lisp.
“
main :- write('This is a sample Prolog program'),
write('\nThis program is written into hello.pl file').
?- main.
?- halt.
Next up, there's the fact that math doesn't use the =, but rather uses is to do evaluations at runtime, which drove me nuts. You have to use foreach or forall to do loops, and there are subtle differences ?- forall(between(0,5,N), (A is 5-N,writeln(A))).
5
4
3
2
1
0
true.
It's just not programmer friendly. At least with spreadsheets, you can see what's going on, Prolog is just weirdIt's hard to pick up users, if they can't get enough of a grasp of it to make sense of it.
The free tooling around it is bad, making you spend too much times debugging simple query as a beginner.
Indeed. My Apologies. Take a look at The Art of Prolog.