Because I have been learning about Type Theory, I have become much more aware of and interested in Functional Programming.
If you are unfamiliar with functional programming, Real World Haskell describes functional programming like this:
In Haskell [and other functional languages], we de-emphasise code that modifies data. Instead, we focus on functions that take immutable values as input and produce new values as output. Given the same inputs, these functions always return the same results. This is a core idea behind functional programming.
Along with not modifying data, our Haskell functions usually don't talk to the external world; we call these functions pure. We make a strong distinction between pure code and the parts of our programs that read or write files, communicate over network connections, or make robot arms move. This makes it easier to organize, reason about, and test our programs.
Because of this functional languages have a number of interesting differences with traditional programming. In functional programming:
- Programming is lot more like math. Programs are often elegant and terse.
- It is much easier to reason about programs, including proving things about them (termination, lack of errors etc.). This means compilers have much more room to automatically optimize a program, automatically parallelizing code, merging repeated operations etc.
- Static typing helps (and requires) you find and correct a large fraction of trivial bugs without running the program.
- Pure code means doing things with side effects (like I/O) requires significantly more thought to start to understand, but also makes side effects more explicit.
- Program evaluation is defined much more directly on the syntax of the language.
I'm another functional programming (and type theory) afficionado, but I don't think they are the future for the whole of computer programming.
I need to disagree, though, with your inclusion of "Static typing helps (and requires) you find and correct a large fraction of trivial bugs without running the program" in your list of the advantages of functional programming. The issue of static vs dynamic typing is completely orthogonal to the question of functional vs procedural control flow. There are statically typed procedural languages (C++) as well as dynamically typed procedural languages (Smalltalk). Similarly on the functional side of the fence.
I also have to disagree that it is an advantage of functional programming that "Program evaluation is defined much more directly on the syntax of the language." I've always understood that it is the direct opposite - evaluation order in a procedural language is explicit in the program syntax, whereas functional languages (being side-effect free) leave much more scope for the compiler to shift evaluation steps around.
Couple of comments: