I’m taking a break from coding for a bit and I felt like sharing some thoughts about Prolog programming in general. None of this is to be taken too seriously. It’s just for some lively discourse.
Prolog is my favorite language. SWI-Prolog is my favorite (by far) implementation of it.
But I must confess I have to concentrate a lot harder when writing Prolog code than in a procedural language (my primary job). But everything has its trade-offs and what I find as a reward for that more intense level of concentration and exactness, is that debugging the code I’ve written is a lot, lot easier than in a procedural language.
It’s as if Prolog forces you to get your thinking correct. Than after a short burst of cleaning up a few (truly) minor syntax errors, and a slew of
singleton variable errors, which are also very easy to correct, the code frequently runs fine the first time!
This is a true delight given the opposite experience I have when debugging a procedural program. That experience usually consists of wading through tons of nested function calls and trying to disentangle improperly coupled algorithms or data structures or flat out logic errors; each of which causes an unpleasant round of alterations in the code that frequently ripple upwards and downwards the code hierarchy, with the not so infrequent painful mass refactoring session.
What has the experience been for the rest of you, especially those whose primary coding job is in a procedural language? What is it about Prolog that you feel promotes this unique experience?