What is Functional Programming?
What is Functional Programming?
If you have been writing code for a long time with an object-oriented language (such as Java or C#) it may be difficult to imagine a different way to approach programming. Functional programming does just that. At the heart of functional programming is a new way to address a software problem- by focusing on the function decomposition of the algorithm(s). With functional programming, functions are first class citizens. If you come from the Java world, you can already appreciate the difference. In Java, the only way to express a method is as a component of a class.
Although a recent uptick in special purpose languages has gotten all the attention, functional programming is a technique and not necessarily a language. It is possible to write in a functional way with a general purpose or object-oriented language (in a later section we examine a functional example written in C#). Although it is possible, for anything significant, the lack of expressiveness quickly becomes apparent and anti-patterns start to crop up. Imagine trying to write an object-oriented program of any significant size using Java without the keywords extend or implements. These difficulties naturally lead to the need for a new language; a functional language.