Hacker News new | ask | show | jobs
by tom_mellior 2418 days ago
I love pure Prolog, and I welcome new developments like the pure if_/3 discussed below. But at the same time, your position is needlessly extremist. It's perfectly fine to write a program in 90% pure Prolog and 10% in its "quirky imperative" subset. Depending on what you're doing, turning that ratio around to 20-80 can still be useful: "quirky imperative" Prolog is still the best language for matching and transforming tree-shaped data that I know of.

The ability to mix in impure features where needed is what makes Prolog practical.

2 comments

The problem is, once you introduce a non-logical predicate, everything in the call stack "above" it is tainted and rendered non-logical. Since you frequently have to resort to using (\+)/1 almost as a necessity, the codebase ends up being 90% illogical and 10% logical. And at that point you step back and ask why you're even using prolog.

However: I do miss DCGs in every other language I've used. They're so useful that I've come to hate using regexes or even worse: manually parsing lists and strings.

> The problem is, once you introduce a non-logical predicate, everything in the call stack "above" it is tainted and rendered non-logical.

That's a very general statement. The non-logical behavior can be well-contained and unobservable from the outside. For example, the nice and pure if_/3 internally uses both of the non-logical predicates (->)/2 and (==)/2. Yet viewed from the outside it doesn't taint anything.

> And at that point you step back and ask why you're even using prolog.

As I wrote above, because I think even used imperatively it's a very convenient language for expressing matching and transformation of trees. And DCGs are great as well, I agree.

Very well said, exactly my opinion as well.