Jason Warner
1 min readJan 24, 2020

--

Thanks for the article! It explains the hows and whys of functional programming using great examples.

One thing I think you could do better is to explain the downside to this approach. For example, in your do one thing example, you will create 3 new arrays and iterate through the array 3 times. I don’t think this is necessarily a bad thing. In most cases, this small overhead is minimal compared to the readability trade-off. However, for big arrays, your performance can definitely suffer (down from O(n) in the declarative to O(n²) and potentially triple the memory consumption if every case passes your filters in the do one thing example.).

One potential solution to stay functional and keep performance is to investigate transducers (or use a library that already has them like ramda).

I love functional programming and love articles like these. It is a crazy rabbit hole you are introducing people to. :)

--

--

Jason Warner
Jason Warner

Written by Jason Warner

I enjoy everything related to code and being a dev. However, my only skills are showing up and being lucky and I'm not sure if luck is a talent.

Responses (1)