Re:Imperative vs. Declarative
by icebraining on Tuesday April 02, 2013 @01:12PM
(#5480662)
Map and other functional constructs may be declarative, but I only "feel" like I'm programming declaratively when I'm coding in a language like Prolog.
The fact that, with unification and backtracking, you can not only get a result for a query, but also "pass a variable" as an argument and get a possible value makes it seem much more like a mathematical expression and less like a computation.
The fact that, with unification and backtracking, you can not only get a result for a query, but also "pass a variable" as an argument and get a possible value makes it seem much more like a mathematical expression and less like a computation.
For example, I can define some relations:
And then I can simply run a query: But I can also make it fill in the value for me: 'grandparent_of' is not some piece of code, it's an actual declaration of a relation between the terms.Of course, you can do unification and backtracking in other languages, but Prolog is designed for it.