Functional programming: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Eric Evers
imported>Eric Evers
mNo edit summary
Line 26: Line 26:
Some examples of functional programming languages are:
Some examples of functional programming languages are:
  [[scheme_programming_language|scheme]],  
  [[scheme_programming_language|scheme]],  
  [[erlang_programming_language|erlang]],
  [[erlang_programming_language|erlang]], (excluding all parallel functions)
  [[haskel_programming_language|haskel]].
  [[haskel_programming_language|haskel]].
   
   
If a functional language is eager then all values are fully computed in the order that they are encountered. In a lazy language like [[haskel]]
If a functional language is eager then all values are fully computed in the order that they are encountered. In a lazy language like [[haskel]]
some arguments are allowed to have delayed evaluation.
some arguments are allowed to have delayed evaluation.

Revision as of 11:24, 21 November 2008

Functional programming, time and state

A functional programming language is a language modeled after mathematical functions. Non-functional computer programs allow state changes. State changes are represented by changes in the values of variables over time. In strict functional programming languages variables are not allowed to change during a single invocation of a function.

In strict functional programming state is not saved outside of function calls. By removing state outside of functions, side effects are controled.

State may not change during a function call. Fixed state allows for the control of side effects(bad distant changes caused by local changes). When state is fixed, functions can be treated similar to mathematical functions and facts can be proved about such functions. Some functional programs can be proved to equal to each other or proved to be stable under certain conditions. Such proofs can aid the efforts of software engineers and computer scientists. See (Hutton, 1999) for an example.

Ref 1: Graham Hutton, 1999, [1]

      A tutorial on the universality and expressiveness of fold
      J. Functional Programming 9 (4): 355–372, July 1999,     
      Cambridge University Press.

Some examples of functional programming languages are:

scheme, 
erlang, (excluding all parallel functions)
haskel.

If a functional language is eager then all values are fully computed in the order that they are encountered. In a lazy language like haskel some arguments are allowed to have delayed evaluation.