5.4 FUNCTIONAL PROGRAMMING
Functional programming is the programming methodology that puts great emphasis on statelessness and religiously avoids side effects of one function in the evaluation of any other function. This property, termed ‘purity’, is the basic design goal of most functional languages, although even their architects will concede that most of them are not strictly ‘pure’. Functions in this methodology are like mathematical functions. In the conventional programming style, on the other hand, statements are considered ‘imperative’ and represent instructions to the computer for accomplishing computing tasks.
Adapting this notion of functional programming may sound like regressing back to the pre-object-oriented age and sacrificing all the advantages thereof. However, there are practitioners, both in academia and in the industry, who strongly believe that functional languages are the only approach that ensures stability and robustness in financial and number crunching applications.
Functional languages, by definition, are stateless. They do everything through functions, which return results that are, well, functions of their arguments. This statelessness immediately makes the functions behave like their mathematical counterparts. Similarly, in a functional language, variables behave like mathematical variables rather than labels for memory locations. A statement like x = x + 1 would make no sense. After all, it makes no sense in algebra either.
This strong mathematical ...