zlacker

[return to "Can logic programming be liberated from predicates and backtracking? [pdf]"]
1. woolio+du2[view] [source] 2024-10-13 08:10:44
>>matt_d+(OP)
This is a reference to the "Can programming be liberated from the von Neumann style?" from 1977. It argues for functional programming, making the point that the imperative style is more common for efficiency reasons, as the programming model is close to the computer architecture. It aims to be a general thought framework inviting to step a step back on some notions that have been (hastily?) accepted in the programming world.

It makes the same analogy that Prolog (or logic programming languages in general) have been strongly influenced by the resolution algorithm. In practice that means that if you write a non-trivial program, if performance is not right you'll need to understand the execution model and adapt to it, mainly with the pruning operator (!). So while the promise is to "declare" values and not think about the implementation details, you're railroaded to think in a very specific way.

I personally found that frustrating to find good solutions essentially unworkable because of this, in comparison with either imperative or functional paradigms that are significantly more flexible. As a result, Prolog-style programming feels limited to the small problems for which it is readily a good fit, to be integrated into a general program using a general-purpose language. I may be wrong on this, but of the 50 people that learned Prolog around the same time as me, none kept up with it. Meanwhile, other niche languages like Ocaml, Haskell and Scheme had good success.

Rethinking the language foundation could remove these barriers to give the language a broader user base.

◧◩
2. PaulHo+yX2[view] [source] 2024-10-13 13:38:24
>>woolio+du2
The way you write imperative programs in Prolog by exploiting the search order, using cuts, etc. seems clever when you see it in school and do a few assignments for a comparative programming languages class (the only 3 credit CS course I took) but it is painfully awkward if you have to do very much of it.
◧◩◪
3. YeGobl+E53[view] [source] 2024-10-13 14:41:16
>>PaulHo+yX2
It isn't. I do most of my programming in Prolog, I write oodles of it daily, and it's not a problem. You learn to think that way easily.

The argument is basically that Prolog is not 100% declarative and that if we jump through a few hoops, and translate it all to functional notation, we can make it "more declarative". But let's instead compare the incomplete declarativeness of Prolog to a fully-imperative, zero-declarative language like Python or C#. We'll find I believe that most programmers are perfectly fine programming completely non-declaratively and don't have any trouble writing very complex programs in it, and that "OMG my language is not purely declarative" is the least of their problems. I hear some old, wizened nerds even manage to program in C where you actually can drop to the hardware level and push bits around registers entirely by hand O.o

◧◩◪◨
4. dragon+kh4[view] [source] 2024-10-14 00:28:24
>>YeGobl+E53
> But let's instead compare the incomplete declarativeness of Prolog to a fully-imperative, zero-declarative language like Python or C#.

There's no such thing as "fully-imperative, zero-declarative language" -- at least not one as high level C# or Python -- because declarative/imperative are programming styles, which languages can make more natural but which are used with all (well, higher-level than assembly) languages.

◧◩◪◨⬒
5. YeGobl+7d5[view] [source] 2024-10-14 11:40:05
>>dragon+kh4
I think there are declarative elements in various high-level languages, e.g. Linq queries in C# so I guess it is an exageration to say "zero-declarative", but in general the level of declarative-ness is tiny compared to Prolog.

Did I misunderstand what you mean?

◧◩◪◨⬒⬓
6. thesz+uol[view] [source] 2024-10-20 21:52:55
>>YeGobl+7d5
Have you tried Haskell?

For example, it is possible to embed backtracking logic programming [1] into Haskell with not a big effort.

[1] https://hackage.haskell.org/package/logict

◧◩◪◨⬒⬓⬔
7. illogi+gbv[view] [source] 2024-10-24 15:21:33
>>thesz+uol
It sure is if you read enough "Functional Pearls" to think all you need for logic programming is some backtracking. Oh, and the cut. Because you can't control backtracking without the cut. Not if you don't understand what the backtracking is for in the first place! Mwahahaha.

Oh sorry. Did I let my schadenfreude out again?

[go to top]