I’m putting together a quick introduction to Prolog (and declarative approaches in general), both as an online resource and as part of a class for Seniors I’m teaching.
In my gut, I feel that moving away from an imperative style is the way we will continue to grow programming as the domains and environments get more complex.
At the same time, the purely declarative solutions often seem to lack a grounding in reality, heading off into the weeds where a more imperative solution would follow the path.
For example, I searched for a while for a purely declarative Towers of Hanoi (I know, I know), and all the solutions that claimed to be so were really just rewrites of the standard, imperative algorithm.
I had an attempt at doing it by simply representing the terms of the problem. You can see it here: https://gist.github.com/pragdave/0207669683ab18b28caa8e5732ed1f67
Clearly it isn’t viable.
My question is: could it be? Or will be always need to inject imperative knowledge into our code.