I just ran into an article on DZone that totally threw me off my chair in terms of content. It’s titled (ambitiously enough) “Functional Programming For the Rest of Us“. Basically the article attempts to explain many of the common FP techniques in terms that imperative programmers can understand. More importantly, it motivates these explanations with a long and rambling set of real-world reasons. It’s extremely long, extremely involved and well worth the read.
It’s worth noting that the author claims to be presenting his explanations in Java, but is in fact devising an extension of Java to represent FP constructs more concisely. He does say though that this is for clarity only and it is possible to write purely functional programs in Java (stateless) “…if you felt particularly masochistic.” Personally, I wish he had stuck with the masochistic route and avoided the invention of syntax extensions (or better yet, just used Scala); but regardless, his intent is clear. Anyway the explanations themselves are not where the real meat of the article is.
The really interesting bit is how the author motivates FP through a combination of real-world examples and lengthy reasoning. I’ve been sold on the benefits of functional programming for a long time now, but I’ve never seen so many supporting arguments thrown into a single batch. For those of you still skeptical about the benefits of writing side-effect-less code in Scala, this article is for you.
So grab yourself a cup of coffee and a box of donuts (it’ll take you about that long to finish the article), and slog your way through. Trust me, it’s worth the effort.