Declarative programming is when you write your code in such a way that it describeswhat you want to do, not how you want to do it. As such, it is left up to the compiler or interpreter to figure out the how. SQL and XSTL are both examples of declarative programming languages.
Imperative programming is telling the machine how to do something, with the end result being what you want to happen. As for examples, just about every programming language, including Visual Basic, Java, and C++, is imperative.
Typically, a language falls squarely into one of the two camps. JavaScript, the language of AngularJS, is a rare breed -- flexible enough to be used either way, so it's often used to present side-by-side comparisons. That being said, most of the examples that I've come across compare declarative programming to its functional equivalent. Functional programming is a form of declarative programming that implements a function-based approach to problem solving. Perhaps the most noteworthy ramification of the black-box approach of functional languages is that they are stateless; that is, the value returned by a function is wholly dependent on its input. Functions in imperative languages allow for the creation and transformation of data so that subsequent function calls may modify a variable.
Your new post is loading...