What Problem Spaces are Naturally Addressed by Functional Programming?
Growing up, I'd occasionally help my dad fix things around the house, paint, etc., and from the many things he taught me, "the right tool for the job" stands out clearly. When faced with a problem, you need to consider what you have in your "toolbox" and decide the best way to solve it. Certain problems can be solved easily with a hammer, whereas with others you need a saw. You need to apply the same thought process to choosing programming paradigms and the languages that support them.
Functional programming is appropriate for applications that exhibit one or more of the following characteristics: require significant computation (compute-bound) as they can be parallelized easily, are themselves parallel in nature, can benefit from asynchronous calls, need to be provable, or require sophisticated pattern matching. This means that functional programs are not generally applicable to typical line-of-business applications that deal with objects and their state over time; however, there may be portions of those programs, e.g., portfolio basket optimization for fixed-income securities, that would benefit greatly from using functionally-based libraries. We typically see functional programming applied to image processing, machine algebra, lexing and parsing, artificial intelligence, and data mining.
Why Should I Care About Functional Programming?
While you can develop concurrent, scalable and asynchronous software without embracing functional programming, it's simpler, safer, and easier to use the right tool for the job. Functional programming enables you to take advantage of multi-core systems, develop robust concurrent algorithms, parallelize compute-intensive algorithms, and to readily leverage the growing number of cloud computing platforms.
In addition, if you've not already explored non-imperative programming, it's a great way to expand your problem solving skills and your horizons. The new concepts that you'll learn will help you to look at many problems from a different perspective and will help you to become a better and more insightful OO programmer.
A note of caution: I am not here to convince you how wonderful functional programming is, or how it will change your life. It is a tool -- nothing more, nothing less -- that helps to solve a certain class of problems. In F# Survivial Guide, we explore and explain these types of problems, and point out why functional programming applies. We go on to explore functional concepts in depth in Chapter 8, Functions and Functional Concepts. To build up to that, we first examine F#'s syntax, primitive data types, control flow structures, loops, and basic collections.