Rationale for Functional Programming

This topic will likely be turned into a blog on my own domain at some point. I want to share my thoughts with you here first, though.

Functional programming (FP for short) is a paradigm, alternatives are Object Oriented Programming or Procedural programming. See Wikipedia for a more in-depth introduction:

I have a background in maths. So learning about Professor Frisby’s book at

(Code on GitHub GitHub - MostlyAdequate/mostly-adequate-guide: Mostly adequate guide to FP (in javascript) ) changed my perspective on how I want to write code.

Now, there are use cases for each paradigm. In my experience with building web frontends I often have to turn state into UI. Something I feel Functional Programming is good at.

Breaking logic up into small functions makes it easy to test them (gaining confidence that they work as expected) while also allow for composition. Now I want to avoid the dreaded M-word at which point many will turn off.

But I feel like taking some concepts of FP can help improve the code. For example, I really enjoy Pure Functions (output only depends on input. No side effects such as logging, HTTP requests or database queries).
There is the option to take it to the extreme, but I am fine with multi-paradigm languages (such as JavaScript and Python) that allow me to take what I need.

What are your thoughts on FP?

1 Like

Fully agree on what you write, and there’s increasing appreciation in the IT world on how, when and where FP-related concepts can be best applied. Coming from an OOP background I intend to delve deeper myself. I’d like to add a related resource that has shown to be very valuable…

Functional core, imperative shell

This concept was introduced by Gary Gebhardt in 2012, first in the presentation about Boundaries (must-watch), and then in this Functional core, imperative shell article. Both have multiple good discussions on HN, e.g. recently in this submissiong and here in an earlier one. Quoting the latter’s top comment:

This basic idea has deeply infected how I approach software architecture and design. When someone asks me why I wrote something a particular way, it’s usually because I’m trying to keep the imperative/environmental concerns separate from the functional/algorithmic concerns.

I end up recommending this video at least once every year.

(EDIT: Another one from Gary that pairs well is “Boundaries”: Boundaries . The core idea is that values – data, not code – should form the boundaries between distinct systems.)

I was about to post these somewhere for Solidground project (cc: @realaravinth) as this fits very well on Clean/Hexagonal Architecture of Groundwork communication platform.

1 Like

For the record: This topic was moved to another category.

1 Like