Overcoming Functional Programming’s Cognitive Dissonance Issues (for sticklers like me)

Paul Galvin
HackerNoon.com
Published in
2 min readNov 12, 2016

--

I don’t know how much you’re like me, but if you are, you can get bogged down in the specific meaning of words, concepts, definitions and how these apply to the real world. I can personally have a difficult time bridging the gap between notional definitions and real world practice — for instance, the beautiful castle on the hill we love called Agile versus what actually happens in the normal run of things.

I have faced a similar issue with functional programming as I continue to integrate it into my practical day-to-day. I just recently realized how much more trust and confidence I have in my own code. Ironically, this is a direct consequence of immutability — the very thing that held me back from seriously investigating FP for so long. “Immutable” is one of the most common words in the functional world’s lexicon. That’s been a bit hard on me because it just doesn’t find a happy home in my conceptual framework for “programming” at all. Inputs go into a program, the program changes them and the program spits out an answer. In other words, it mutates the inputs :).

By now, of course, I know that immutability is actually a tactic. It just means that you aren’t changing the value of any of the things (at least as much as possible). From this simple (and usually simply followed) idea, flows much goodness.

I find myself grappling a lot of with these little cognitive dissonance issues. In JavaScript, you don’t necessarily have to reduce things at all using the reduce function. But its very name (and the many canonical examples you find on the intertubes) leads people like me to initially conclude that its main purpose is to sum up an array of integers :). Having overcome that hurdle, I use it for all kinds of things that are only loosely coupled with the normal English speaker’s understanding of “reduce.”

So if you’re like me — a bit of a stickler for literal definitions — and you’re interested in functional programming, try and let your guard down a bit. I have been chipping away at my preconceptions for a while now and I’ve been enjoying some success. You may too.

</end>

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMIfamily. We are now accepting submissions and happy to discuss advertising &sponsorship opportunities.

To learn more, read our about page, like/message us on Facebook, or simply, tweet/DM @HackerNoon.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!

--

--

Paul Galvin
HackerNoon.com

Author and Practice Director @ Neudesic/IBM. Father, Not-Great-But-Always-Trying Zen Buddhist. “Yet Another TypeScript Book” (https://amzn.to/2ABntAX).