Constraint Programming with python-constraint
Introduction
The first thing we have to understand while dealing with constraint programming is that the way of thinking is very different from our usual way of thinking when we sit down to write code.
Constraint programming is an example of the declarative programming paradigm, as opposed to the usual imperative paradigm that we use most of the time.
What is a programming paradigm?
A paradigm means “an example” or “a pattern” of something. A programming paradigm is often described as a “way of thinking” or “way of programming”. The most common examples including Procedural programming (e.g. C), Object-Oriented programming (e.g. Java) and Functional Programming (e.g. Haskell).
Most programming paradigms can be classified as a member of either the imperative or declarative paradigm group.
What is the difference between imperative and declarative programming?
- Imperative programming, simply put, is based on the developer describing the solution/algorithm for achieving a goal (some kind of result). This happens by changing the program state through assignment statements, while executing instructions step-by-step. Therefore it makes a huge difference in what order the instructions are written.
- Declarative programming does