3 ms·
Just because of performance issues. No other explanation needed really. same reason why it took some time for pure functional programming to take off too. The t
by valenterry 4y ago
Just because of performance issues. No other explanation needed really. same reason why it took some time for pure functional programming to take off too. The time for Prolog will come.
- discarded1023 4y agoProlog has many issues; for instance the lack of types and mode declarations, and backtracking almost never being what you want. This was addressed in Mercury [1] but much of the baby was thrown out with the bathwater. (IMHO Mercury ultimately landed closer to the MLs than to Prolog.) The academic literature suggests classic Prolog got fast enough in the late 1980s / early 1990s on stock hardware [2]; see also Peter Van Roy's intriguing book [3] for what happened next. 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. [1] https://mercurylang.org/ https://mercurylang.org/ [2] https://www.hpl.hp.com/techreports/Compaq-DEC/PRL-RR-36.pdf https://www.hpl.hp.com/techreports/Compaq-DEC/PRL-RR-36.pdf [3] https://www.info.ucl.ac.be/~pvr/book.html https://www.info.ucl.ac.be/~pvr/book.html
- valenterry 4y agoRight, I have generalized a bit. It doesn't necessarily have to be Prolog, but I'm referring to logic-programming in general. There is even a new language that allows to embed logic programming inside of "regular" (imperative/functional) programming code. Forgot the name though.
- discarded1023 4y agoThere appears to be a lot of activity around minikanren [1]. Personally I'm so used to having a powerful metalanguage around (lambda calculus plus or minus a bit) that I can't imagine programming in pure Prolog any more. Which is to say this is probably the way to go in practice, if a subproblem can be solved using logic programming. [1] http://minikanren.org/ http://minikanren.org/
- zelphirkalt 4y agoMinikanren allows you to program in relations. That is, not only unidirectional functions, X->Y, but you can leave out the X and give the Y, getting all X, which would result in that Y. I always found that talk at RacketCon impressive [1]. I mean, of course, minikanren is also implemented somehow, using lambda, but usually one would not want to rebuild the things minikanren offers. I have not yet tried to use minikanren inside an otherwise "normal" program, but I suspect it will just work. [1]: https://invidious.baczek.me/watch?v=5vtC7WEN76w https://invidious.baczek.me/watch?v=5vtC7WEN76w (video id 5vtC7WEN76w)
- felixyz 4y agoI agree that the lack of types is a serious deficiency, but surely that can't be the reason Prolog lost steam? I mean... Python? 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.)
- discarded1023 4y agoI learnt as an undergrad that every sufficiently large program contains a type system (in the loose PL sense of operations requiring arguments of certain sorts) ... now that can be provided by the language or in an ad hoc way by the program itself. (Yes, shades of the CLOS truism.) Python has learnt this lesson (at least I get this impression from reading hacker news) since I stopped using it circa 2015. 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.
- zelphirkalt 4y agoAh, but Python has always had types. Just not static types. It still does not really have static types. Static type validation is done by external tools like MyPy. Python itself ignores type declarations at runtime. Still objects of Python have types. You just cannot reason about them at compile time using only pure Python.
- YeGoblynQueenne 4y agoProlog doesn't have typed variables, but any Prolog term has a type, the set of Prolog terms that unify with itself. In practice, when you write Prolog, your arguments to predicates are always implicitly typed, for example if you write a program that takes as argument a list, you'll write something like this: 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.
- usrbinbash 4y ago> same reason why it took some time for pure functional programming to take off too. 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.
- valenterry 4y ago> 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".
- usrbinbash 4y agoWhat is that understanding then exactly? 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.
- valenterry 4y agoMy own feeling about the speed of adoption in languages and libraries, nothing more. Something can take off but still play a major role. Just like LLMs took off recently but still play a minor role in almost every area I know.
- usrbinbash 4y ago> Just like LLMs took off recently but still play a minor role in almost every area I know. Okay, let's do the comparison. LLMs became a big story less than a year ago. Since then, they are, among other things, powering the fastest growing app of all time. They are poised to take over pretty much every NLU functionality, products are being developed every day that wouldn't be able to otherwise, and major players in the industry throw billions at them. Their, and other ML achievements, impact on society are estimated to be so profound, that they have caused ripples in international politics, rekindled debates about UBI, made geopolitical positions about chip maufacturing and AI research even more relevant, and set lawmakers all around the globe scrambling to figure out how to deal with this new reality, regarding everything from copyright laws to regulations. So, what is going on in the purely-functional-PL space? Well, the flagship of these languages, Haskell, had it's stable release 12 years ago. Since then, the only software product that I can name without googling that's written in it, is pandoc. The language is currently Number 34 on the Tiobe index. In fact, I am not sure any of the current top20 could be called "purely functional", which would place these languages below Scratch, Fortran, and Classic Visual Basic in terms of that index. https://www.tiobe.com/tiobe-index/ https://www.tiobe.com/tiobe-index/ Regarding usefullness, what have purely functional PLs demonstrated? That they can be challenging to use coming from an imperative background, and that they can be a drag on performance. On the plus side they offer ... yeah, what exactly is it they offer, that imperative languages adopting some of their features, like functions as first class objects, cannot? So I have a hard time seeing any indicators of an impending take-off for purely functional PLs.
- Alupis 4y ago> same reason why it took some time for pure functional programming to take off too 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.
- valenterry 4y agoClasses and objects don't contract PFP. 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.
- Alupis 4y agoThe idea of a class encapsulating functionality and traits is definitely at odds with PFP. PFP would prefer free functions, after all. 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.
- valenterry 4y agoNot really, at least not in my terminology. Classes (in the pfp world) are pretty much just a bundle of free functions with some predefined bindings that are available to all those free functions, and putting those functions into their own namespace. Those are valid things to do even in pfp. data classes are technically similar or even identical but conceptually a different thing (though of course also useful and needed).