Is really functional programming better?

Since the beginning of software development, we have used the same programing techniques, the author mentions that this is because it “closely resembles how a computer works at the hardware level: the processor fetches data from memory, performs elementary opera- tions on it, and writes the result back to a memory cell” (Hinsen, 2009). The only different technique that has been developed is functional programming, which was developed as a mathematical theory first and then into a programming language called LISP. So, we have two different approaches: functional programming and imperative programming. 
Functional programming consists on composing functions for computations, just as previously mentioned, this paradigm was first a mathematical theory and thus a function is “a mapping from input values to output values” (Hinsen, 2009) not to be confused with subroutines. A big difference between functions from functional programming and from imperative programming is that functional functions return always the same value given the same input.
The main advantage of functional programming is that the mathematical abstractions used to express an algorithm can be easily transformed into a function, due to its mathematical nature. In functional programming it is common to write functions that take other functions as parameters and returning functions, this is called a higher-order function The second advantage is the easiness of parallelism and concurrency that this programming approach gives because in its pure way there are no variables and thus no need to coordinate value changes but this is only in theory because the functional compilers are not yet ready to make this task possible in an efficient way.
The first problem with functional programming arises with its difference with the traditional method, the author mentions that because it is very different it requires a complete change of paradigm (learning and unlearning). Then, functional programming is more difficult to compile into machine code than imperative, this is due to the hardware implementation, as it was mentioned above. On the other hand, functional programs are easier to test and more robust than the imperative ones.
I think that functional programming is a really interesting paradigm, but it is not ready to take on the programming world. It is still better to program with the imperative approach, although one must know functional programming and must try to develop the necessary techniques for functional programming to fulfill its promises as a better approach to programming.
Hinsen, K. (2009) The Promises of Functional Programming.

Comentarios

Entradas más populares de este blog

Two is more than double of one

What makes Lisp Lisp?