Imperative programming: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created)
 
m (Fixed some English, I think I kept the originally intended ideas)
Line 1: Line 1:
[[Category:Encyclopedia]]'''Imperative programming''' is a programming model opposed to '''declarative programming'''. As the name suggests imperative programing instructs what to do in order to solve the problem. Declarative programming describes the problem leaving the solution to the inference system.
[[Category:Encyclopedia]]'''Imperative programming''' is a programming model opposed to '''[[declarative programming]]'''. As the name suggests, imperative programing give instructions for what to do in order to solve a problem. Declarative programming describes the problem, leaving the solution to the inference system.


More formally imperative programming requires identifiable computation states, transitions between which are imperatively instructed. Declarative programming requires a well defined class of problems for which a close to optimal solution is implementable with the existing software and hardware.
More formally, imperative programming requires identifiable computation states, and transitions between these states with imperative instructions. Declarative programming requires a well-defined class of problems for which a close to optimal solution is implementable with the existing software and hardware.


The low level computational models and hardware are traditionally imperative. One exception is represented by analogue computers, which were declarative in the way they were programmed. Therefore the first generations of programming languages were imperative, as well as the precursor concept of algorithm is.
The low level computational models and hardware are traditionally imperative. One exception is represented by analog computers, which were declarative in the way they were programmed. Therefore, the first generations of [[:Category:Programming Languages|programming languages]] were imperative, as well as the precursor concept of an algorithm.


During the evolution of programming languages the computational states became more abstracted and less directly mapped to the hardware states. In the end the fourth generation of programming languages used to replace imperative programming with declarative one. This led to domain specific programming languages, because declarative programming is necessarily limited to only the problems for which the solution is known. Then the process of drifting towards declarative programming reached the equilibrium, as the maintenance of declarative solutions written in multiple languages became a problem due to the ''language impedance''. Further, understanding of complex declarative solutions is in general more difficult, effects of errors are less predictable, performance optimization is hard etc.
During the evolution of programming languages the computational states became more abstracted and less directly mapped to the hardware states. Fourth generation of programming languages are used to replace imperative programs with declarative ones. This led to domain specific programming languages, because declarative programming is necessarily limited to only the problems for which the solution is known. Then the process of drifting towards declarative programming reached its equilibrium, as the maintenance of declarative solutions written in multiple languages became a problem due to ''language impedance''. Further, understanding of complex declarative solutions is in general more difficult, effects of errors are less predictable, performance optimization is hard, etc.


Presently in the higher level languages the margin between imperative and declarative is very blurred. General purpose languages contain both imperative and declarative constructs.
Presently in the higher level languages the margin between imperative and declarative is very blurred. General purpose languages contain both imperative and declarative constructs.

Revision as of 20:27, 17 July 2008

Imperative programming is a programming model opposed to declarative programming. As the name suggests, imperative programing give instructions for what to do in order to solve a problem. Declarative programming describes the problem, leaving the solution to the inference system.

More formally, imperative programming requires identifiable computation states, and transitions between these states with imperative instructions. Declarative programming requires a well-defined class of problems for which a close to optimal solution is implementable with the existing software and hardware.

The low level computational models and hardware are traditionally imperative. One exception is represented by analog computers, which were declarative in the way they were programmed. Therefore, the first generations of programming languages were imperative, as well as the precursor concept of an algorithm.

During the evolution of programming languages the computational states became more abstracted and less directly mapped to the hardware states. Fourth generation of programming languages are used to replace imperative programs with declarative ones. This led to domain specific programming languages, because declarative programming is necessarily limited to only the problems for which the solution is known. Then the process of drifting towards declarative programming reached its equilibrium, as the maintenance of declarative solutions written in multiple languages became a problem due to language impedance. Further, understanding of complex declarative solutions is in general more difficult, effects of errors are less predictable, performance optimization is hard, etc.

Presently in the higher level languages the margin between imperative and declarative is very blurred. General purpose languages contain both imperative and declarative constructs.