DEV Community

Discussion on: Functional Basics #1: Map

byrro profile image
Renato Byrro

This is very informative. Having only a superficial understanding of functional, in recent weeks it started to grab more of my attention.

I bet you have a good experience with object-oriented. You mentioned that functional drives more "concise and rubust" code. Are you planning to get deeper into the benefits on a future article? Perhaps with some code examples, pointing out practically how these benefits apply?

kvsm profile image
Kevin Smith 🏴󠁧󠁢󠁳󠁣󠁴󠁿 Author

Yes, definitely! What I like about functional programming is that you can take a concept, like map in this article, and start using it today in your object-oriented language, and immediately you can reduce loops to a single map and never have off-by-one errors again. Much of my work is very object-oriented Ruby code, yet I use map constantly and could not tell you the last time I wrote a for loop or saw one in a code review.

The main thing I want to convey in this series is that it's not a choice of object-oriented programming or functional programming. You can mix parts of each to write code which is shorter, easier to read, and less likely to contain bugs, without having to dive right into a Haskell-like language.

byrro profile image
Renato Byrro • Edited on

Hum, interesting perspective. That indeed makes a lot of sense!

I see many developers adopting functional with a purist view of it. This word - pure - is even part of the paradigm vocabulary. 😄 So I'm interested in getting deeper into the benefits of an entirely functional system, understanding why folks like it so much. In a practical way. Comparing codes in both ways and having better grasp of why one is better than the other.

But I do like the idea of a mixed approach. We all apply it to some extent, actually, without thinking conceptually as functional.

Looking forward to your next articles! 👏

Thread Thread
kvsm profile image
Kevin Smith 🏴󠁧󠁢󠁳󠁣󠁴󠁿 Author • Edited on

It might be a while before I get round to writing about purely functional languages - in the meantime some good resources are:

Learn you a Haskell - nice intro to Haskell.

Programming Languages, Part A - free course from University of Washington, using Standard ML.