login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for FunctionalProgramming revision 1 of 2

1 2
Editor: test1
Time: 2016/07/29 18:23:18 GMT+0
Note:

changed:
-
In pure functional programing there are no variables, there are only values.  Values
are immutable and logically exist "forever" from creation.  Program creates
new values from old ones, typically using functions.  Traditional loops are of no
use in pure functional programming because repeating computation will produce
the same value.  Instead, recursion can produce effects equivalent to
traditional loops.  There are practical problems with pure functional programming.
First, since values exists forever eventually they will exhaust all available
memory.  This is resolved by noting that some values are unreachable: there is
no way to reference them in further computation.  Consequently memory used
by unreachable values can be freed and reused for new values.  This is
called garbage collection.  Without garbage collection functional programming
would be of limited use.  Second, interesting programs interact with environment,
for example draw graphs on the screen.  Such activities mean that program is
no longer pure functional, but can be included in way compatible with
functional style.  Third, some computations, like graph traversal became
complicated without ability to change values.  So pure functional programming
is frequently regarded as doing things with unnecessary restrictions.
However, to deal with restrictions functional programming developed new
style which in many cases leads to short and efficient programs. 

In pure functional programing there are no variables, there are only values. Values are immutable and logically exist "forever" from creation. Program creates new values from old ones, typically using functions. Traditional loops are of no use in pure functional programming because repeating computation will produce the same value. Instead, recursion can produce effects equivalent to traditional loops. There are practical problems with pure functional programming. First, since values exists forever eventually they will exhaust all available memory. This is resolved by noting that some values are unreachable: there is no way to reference them in further computation. Consequently memory used by unreachable values can be freed and reused for new values. This is called garbage collection. Without garbage collection functional programming would be of limited use. Second, interesting programs interact with environment, for example draw graphs on the screen. Such activities mean that program is no longer pure functional, but can be included in way compatible with functional style. Third, some computations, like graph traversal became complicated without ability to change values. So pure functional programming is frequently regarded as doing things with unnecessary restrictions. However, to deal with restrictions functional programming developed new style which in many cases leads to short and efficient programs.