Hacker News new | ask | show | jobs
by rhelz 1003 days ago
I forget who said it, but a good programming language should have two features:

1. Make simple problems easy.

2. Make difficult problems possible.

Python is an outstanding language on both scores.

Prolog, alas, is much better at #2 than it is at #1. For example, prolog is a great choice for writing domain-specific languages, and modern implementations (like scryer prolog, mentioned in a comment above), can generate very efficient code for them.

Prolog's "killer ap" is how well it does on a third feature:

3. It makes virtually impossible tasks "merely" very difficult ;-)

And it has a steep learning curve; it took me years to really "get" it, and I only persevered because I was facing one of those category #3 problems.

Its not a deprecated language, but alas, it is destined to be a niche language. But for those niches, it is still the best, hands-down.

2 comments

Can you tell us about the problem you've encountered in #3? I'm really interested
I guess this is rather category #2 than #3, but my favorite example is Advent of Code 2021, day 24: https://adventofcode.com/2021/day/24. I think many people consider this one of the hardest AOC problems ever and at the time many people didn't even code up a complete solution but solved in manually (me included). However, with Prolog it's almost trivial. So many of Prologs strengths come together here: writing parsers, writing interpreters, solving integer constraints, and in particular "reasoning backwards".
I was writing a theorem prover for higher-order modal logic. All the theorem provers written in C or C++ were tens of thousands of lines, and even at that they had only a fraction of what I needed. What's more, they were all like 100 times *slower* at proving theorems which prolog could prove out of the box.

So I decided to try to implement the features I needed on top of the theorem prover which prolog already is.

Took me forever, but eventually it all came together like a thunderclap, and I was able to implement a theorem prover for quantified, higher-order modal logic which was amazingly-blazingly fast--in 67 lines of prolog.

In terms of lines-of-code per day, its the least productive I've ever been :-)

While I wouldn’t want to do many tasks in prolog. I’ve always wished for a good interop with some other language, or a language with some kind of async prolog call. There are so many things that are a couple dozen of lines of prolog but would be hundreds of lines of other languages.