Hacker News new | ask | show | jobs
by cpdean 1888 days ago
Something that is still a difficult hurdle for me to overcome is how Prolog starts out feeling declarative but then very quickly you need to be aware of all the backtracking rules to correctly guide Prolog to the solution you want. I have tried to get through Clocksin's Programming in Prolog a couple times now and it still hits me how quickly you need to get into the invisible details nobody blogs about in order to be even base-level productive in it.
2 comments

You do need to keep both the procedural and declarative reading of Prolog programs in your head at the same time, yes. But there is such a thing as a "pure subset" of Prolog that doesn't use a) cuts, b) the dynamic database or c) destructive assignment (with arg/3 etc) and if you stay in that pure subset you can go a long way before you need to think procedurally.

But to be honest, myself I prefer to switch between the two paradigms at will when thinking about my programs. The trick is to do it in a way that leaves you with the best of both worlds, rather than the worst.

In terms of sources that go into more advanced material and avoid excessive procedural thinking, one is Markus Triska's website recommended in the sibling comment and I would also recommend Richard O' Keefe's "The Craft of Prolog" and Sterling and Shapiro's "The Art of Prolog".

To be fair, you won't find a lot of Prolog material in blogs so you can expect a lot to be left unsaid in the few that exist.

Have a look at the "power of prolog" YouTube channel (and website) by Markus Triska.