3 ms·
I haven't used Prolog for about 10 years (and then only used it at uni) - this is my memory of it too. You could specify the rules for your problem very succinc
by aidos 14y ago
I haven't used Prolog for about 10 years (and then only used it at uni) - this is my memory of it too. You could specify the rules for your problem very succinctly and naturally but the devil was in the detail. You'd spend all your time making sure the ordering and cuts were right - which at the time felt non-intuitive (though maybe now with more software experience it would be easier).
Isn't there some alternative varient where the ordering of the rules don't matter? (if that's even possible)
Edit: not to put people off - all alternative software paradigms are worth experimenting with
- AYBABTME 14y agoJust finished a 2 months module on Prolog in my 'Programming Paradigm' course. It's true that in the basics, it's very simple... but it quickly becomes very complex and twisted as soon as you try to do something non-trivial. Also, the 'cut' operator surely doesn't help in keeping things understandable! To 'learn' Prolog was a fun experience but honestly I'm glad we switched to something new (scheme), I was getting tired of it. My conclusion is that Prolog is quite good at building expert-systems (duh) but for anything more usual, it's too hard to comprehend.
- yaantc 14y agoI'm not sure you can avoid the dependency on the rules order, and having to understand how the Prolog engine works. But I found there is a rather intuitive way to deal with it: think of the Prolog engine as searching a space of possibilities for a goal (expressed by the rules). Then you must order the rules to narrow the search space as quickly as possible. In other words, try to make the first rules as selective as possible to quickly reduce the search space. That's how you can get fast Prolog programs. But you have to be careful. It's been a long time since I played with Prolog, but I remember a case where reordering two lines would make the solution reached below 1 second from over 15 minutes. That kind of thing is part of the charm and frustration of Prolog. It can be a nice brain teaser.
- fusiongyro 14y agoI like to think of Prolog as an "intellectual diversion."