When to use a functional programming language?

Functional languages are, in my opinion, good for mainly two things: Game AIs and mathematical computations. It's good in game AIs because of its nice list manipulations (at least in Lisp and Scheme), and for mathematical computations because of its syntax. Scheme, Lisp, and Haskell have a syntax that makes mathematical computations easy to read. The last thing I have to add is that functional languages are really fun languages. My Scheme course was one of the courses I had the most fun with.


A friend of mine quoted one of his college professors as saying something like the following:

Draw a grid with data types across the top and operations on those data types down the left side. If you slice the grid vertically, you're doing OO; if you slice the grid horizontally, you're doing FP.

My answer is that FP is a completely viable approach to programming with as wide a range of application as OO. As with any programming-language-choice discussion, I think the more important questions are:

  1. Do you have the time to invest in learning a new notation and a new way of thinking?
  2. Which of the languages you're considering have sufficiently rich libraries that you won't get stuck reinventing some wheel?

As to the first question, if you are doing this primarily for the learning value, I'd suggest looking at Haskell, because of the wide range of support materials (books, articles, active community, etc.)

As to the second question, Haskell has a nice range of libraries (although some are more mature than others), but Scala (a hybrid OO-functional language running on the JVM) has the advantages that you can more gradually transition into the functional style, and you have the full range of Java-accessible libraries available to you.


I've done some research into this myself and thought I might add CONCURRENCY to the list of reasons to use a functional language. See at some point in the near future processor speed will not be able to increase using the same cpu technology. The physics of the architecture won't allow it.

So that is where concurrent processing comes in.

Unfortunately most OOP languages cannot take advantage of multiple processors at once because of the interdependencies between data.

In pure functional programming languages the computer can run two (or many more) functions at once because those functions are not altering outside state information.

Here is an excellent article on functional programming you may enjoy.