Hacker News new | ask | show | jobs
by camus 4819 days ago
so what would be declarative programming ? does it even exist? i mean, at some point you need to write some logic , and logic is imperative. Let's take a html file. It is declarative. but the underlying logic is written somewhere else. so you cant really have pure declarative programming? if it is possible how ?
4 comments

I think the important distinction is what level of detail is the logic being passed off to the environment for translation into machine instructions. If the environment has freedom to decide exactly how to fulfill your request, then its declarative. Imperative is when your logic is specified such that there is little room for the environment to make implementation decisions.

In the case of map/reduce, if these functions are implemented in your language (say in jquery) then its not declarative as your implementation is still being specified. If you are actually talking to your environment in terms of map/reduce, then those methods are declarative. On the other hand, if we consider jquery as a part of our environment, perhaps it does make sense to consider it declarataive?

I think you're mistaking the program for the implementation. A program can be purely declarative; the fact that we need to create an imperative representation of it to run it on a computer doesn't change that.
An evaluation strategy is imperative but the logic that the strategy operates on doesn't have to be.
great point !
Yes. Read up on Prolog.