Coding in functional manner

Functional programming languages, such as Lisp (a mathematical notation for computer programs), are very different from procedural languages such as Java and early versions of C#.

Functional programming is a style of programming that emphasizes the evaluation of expressions, rather than execution of commands. The expressions in these language are formed by using functions to combine basic values. A functional language is a language that supports and encourages programming in a functional style.

What is this "functional" style?

Consider the following quadratic equation:

x^2 + 5 = y

Given a specific value for x, we always expect the same value for y.

So, if x= 2, y= 9.

This is always true.

In many cases, particulary in a multi-threaded environment, it is helpful to develop functions that, for a given set of arguments, will always return the same result.

Why? It helps us develop stateless imutable functions that are thread safe.

NOTE: Something always has to be mutable otherwise our Lisp application couldnt do" anything!

Posted in Labels: , , |

0 comments: