DEV Community

Discussion on: Let's chat about functional programming...

Collapse
 
totally_chase profile image
Phantz

Many, if not all, functional language tutorials/guides rely on map/filter/reduce to build the reader's foundation. Usually, a good place to start for learning new languages is to solve some project euler problems. Once that's done with, one can move on to more practical shenanigans.

So functional languages more or less force a new user to get started using those parts of the language. And it works, like....really damn well! Especially folds (i.e reduce), folds can do absolutely everything. After you have a neat understanding of higher order functions, you start to realize that map/reduce/filter can do practically everything. They're foundational parts of control flow as well as data manipulation.

Eventually one might find themselves getting all philosophical and wondering why does it work so well. They, then, might consider looking into the abstract idea behind these concepts, at which point they might stumble upon functors (mapping), monads/selective functors/profunctor choice/arrow choice (filtering), and foldables (reduce, formally known as "fold"). From there, they might start developing their intuition further between these abstract concepts and stumble upon monoids. And how almost every concept in programming somehow magically describes......a monoid. Odd, but cool! Then endomorphisms, and then.....satisfaction, for a while.

Yes, I've been through that journey, starting off functional programming with those basic tools, realizing how weirdly strong and universal they are, and eventually realizing why they are so universal. It's fun, would recommend.

Collapse
 
rrsai profile image
Roy Ronalds

Yeah, certain languages I think lend themselves better to getting more depth into the abstract concepts that assist with functional programming. I'm curious what language you're generally coming from? as I haven't had to deal with monoids or even come across the term before, had to look it up here:
betterprogramming.pub/functional-p...

Collapse
 
totally_chase profile image
Phantz

Haskell ;)