States and complexity in programming – why functional programming helps to improve your code

The human brain is very, very bad at keeping track of states. Especially for code maintenance states are hell, in particular if you are not the original author of the code, and even then. Even if there is ample and up to date documentation around, trying to understand states of a program is very difficult. States don’t match well to the way the human brain is thinking. Computers, however, excel at it. On the other hand, humans are quite good at abstracting functionality, finding commonalities and patterns as well as following an explicit program flow, in particular if the code uses telling function and variables names and generally a coherent coding convention. Abstraction and pattern recognition in code is something that computers don’t do really well at all.

A programming language should therefore reflect this observation and provide efficient tools to use this human ability. Functional programming is a thinking tool and programming philosophy that helps the natural tendencies of the brain to abstract. While functional programming can be applied in practically every language that supports functions (essentially every modern programming language), some languages try to provide suitable and expressive syntax that allow to move much further up on the abstraction scale whereas other languages, allow only elementary functional programming and make life for the programmer more difficult than necessary. Continue reading