What Epiphany?

In nearly every diatribe on a given functional programming language (but especially the LISPs and Haskell), the author will say something about how using the language will change how you view programming and forever change your style. Personally, I have always been skeptical of this. How can a functional programming language change how you view programming? Its still the same principles at work!
However, after learning Haskell, I think that I have found the cause.

The Epiphany

The "functional programming epiphany" isn't really an epiphany (or rather, not an epiphany about programming in general. It is simply reliving the experience of programming "clicking" with you. The cause of this is how functional (and/or declarative) programming differs from procedural (and/or imperative) programming.

Functional Versus Imperative

Quite a lot of ink has been spilled about the differences between functional and procedural programming, mostly in regard to global state and side effects. However, what quite a lot of them miss is the change in the "toolbox" that the programmer possesses when going from a procedural language to a functional language.
For a personal example, my programming didn't change much going from Java, Perl, and C to Haskell. Being self-taught and coming from the "new school" of scripting languages (i.e, Python and Perl), passing functions to other functions as parameters and working with values off of what a function or subroutine returned rather than maintaining a bunch of global variables was second nature (though for different reasons: passing functions to other functions shortened my code and not having global variables kept me from needing to scroll up to keep track of what I was doing).
Therefore, coming to Haskell was not super difficult (after wrangling the major syntax changes, I was able to run through CodeWars katas and do some toy projects in the language within a week). The main issue that I found was that the standard procedural tool (the while loop) had been replaced by map, filter, and reduce.
I posit, then, that the mastery of these tools to a programmer is the equivalent of the non-programmer mastering the basics of standard procedural programming (that is, learning to use the toolbox), and comes with a similar feeling when it all "clicks".

Home