Computer programs can be categorized by the programming language paradigm used to produce them. Two of the main paradigms are imperative and declarative.
Programs written using an imperative language specify an algorithm using declarations, expressions, and statements.
A declaration couples a variable name to a data type. For example: var x: integer. An expression yields a value. For example: 2 + 2 yields 4. Finally, a statement might assign an expression to a variable or use the value of a variable to alter the program's control flow. For example: x: = 2 + 2; if x = 4 then do something (); One criticism of imperative languages is the side-effect of an assignment statement on a class of variables called non-local variables.
Programs written using a declarative language specify the properties that have to be met by the output and do not specify any implementation details. Two broad categories of declarative languages are functional languages and logical languages. The principle behind functional languages (like Haskell) is to not allow side-effects, which makes it easier to reason about programs like mathematical functions.[4] The principle behind logical languages (like Prolog) is to define the problem to be solved — the goal — and leave the detailed solution to the Prolog system itself.[5] The goal is defined by providing a list of sub goals.
Then each sub goal is defined by further providing a list of its subtotals, etc. If a path of subtotals fails to find a solution, then that sub goal is backtracked and another path is systematically attempted.The form in which a program is created may be textual or visual. In a visual language program, elements are graphically manipulated rather than textually specified
Sunday, June 7, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment