computer programs


SUBMITTED BY: tigermalik

DATE: June 28, 2016, 2:57 p.m.

FORMAT: Text only

SIZE: 1.5 kB

HITS: 761

  1. Imperative languages[edit]
  2. Imperative programming languages specify a sequential algorithm using declarations, expressions, and statements:[16]
  3. A declaration couples a variable name to a datatype – for example: var x: integer;
  4. An expression yields a value – for example: 2 + 2 yields 4
  5. 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();
  6. One criticism of imperative languages is the side effect of an assignment statement on a class of variables called non-local variables.[17]
  7. Declarative languages[edit]
  8. Declarative programming languages describe what computation should be performed and not how to compute it. Declarative programs omit the control flow and are considered sets of instructions. 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.[17] 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.[18] The goal is defined by providing a list of subgoals. Then each subgoal is defined by further providing a list of its subgoals, etc. If a path of subgoals fails to find a solution, then that subgoal is backtracked and another path is systematically attempted.

comments powered by Disqus