# Rationale for Functional Programming

**URL:** <https://discuss.coding.social/t/rationale-for-functional-programming/294>\
**Category:** SX solution development\
**Tags:** best-practice\
**Created:** [March 25, 2023, 5:37pm UTC](https://discuss.coding.social/t/rationale-for-functional-programming/294 "2023-03-25T17:37:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryuno-Ki](https://discuss.coding.social/user_avatar/discuss.coding.social/ryuno-ki/32/44_2.png) [@Ryuno-Ki](https://discuss.coding.social/u/Ryuno-Ki)\
**Post date:** [March 25, 2023, 5:37pm UTC](https://discuss.coding.social/t/rationale-for-functional-programming/294/1 "2023-03-25T17:37:31Z")

</div>

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:

> **[Functional programming](https://en.wikipedia.org/wiki/Functional_programming)**
>
> In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that map values to other values, rather than a sequence of imperative statements which update the running state of the program.
> In functional programming, functions are treated as first-class citizens, meaning that they can be bound to names (including local identif...

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

> **[README](https://mostly-adequate.gitbook.io/mostly-adequate-guide/)**

(Code on GitHub [GitHub - MostlyAdequate/mostly-adequate-guide: Mostly adequate guide to FP (in javascript)](https://github.com/MostlyAdequate/mostly-adequate-guide) ) 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](https://en.wikipedia.org/wiki/Monad_(functional_programming)) 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?

---

<div class="post-metadata">

**Author:** ![aschrijver](https://discuss.coding.social/user_avatar/discuss.coding.social/aschrijver/32/3_2.png) [@aschrijver](https://discuss.coding.social/u/aschrijver)\
**Post date:** [March 27, 2023, 5:45am UTC](https://discuss.coding.social/t/rationale-for-functional-programming/294/2 "2023-03-27T05:45:57Z")

</div>

> [@Ryuno-Ki](#):
>
> What are your thoughts on FP?

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](https://www.destroyallsoftware.com/talks/boundaries) (must-watch), and then in this [Functional core, imperative shell](https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell) article. Both have multiple good discussions on HN, e.g. recently [in this submissiong](https://news.ycombinator.com/item?id=34860164) and [here in an earlier one](https://news.ycombinator.com/item?id=18043058). 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](https://www.destroyallsoftware.com/talks/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.

---

<div class="post-metadata">

**Author:** ![Ryuno-Ki](https://discuss.coding.social/user_avatar/discuss.coding.social/ryuno-ki/32/44_2.png) [@Ryuno-Ki](https://discuss.coding.social/u/Ryuno-Ki)\
**Post date:** [March 27, 2023, 8:43am UTC](https://discuss.coding.social/t/rationale-for-functional-programming/294/3 "2023-03-27T08:43:57Z")

</div>

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