Functional Programming in Frontend Development?

Bernardus Billy Tjiptoning
3 min readMay 19, 2019

I had this topic in mind since about a year ago when my company decided to move forward with functional programming, more specifically using Redux-Observable, RxJs, and Ramda.

I had a hard time understanding how functional programming works since I was taught with the imperative programming since Junior High. I wasn’t trying to be against it, but my brain would not follow the thought process of functional programming as if it were imperative programming. And not just about the functional programming, but now I also have to understand how the Redux-Observable works. Understanding new concepts like this was not easy and it definitely stretches my brain into think beyond the comfort zone.

Long story short, we had it in our codebase for about a year before we decided not to move forward with that and used Redux-Saga instead. Looking back, there are several things why I personally think that the concept of functional programming and Redux-Observable don’t work for us.

1. Steep Learning Curve — Different Concept Than We Used To Know

Generally speaking, we were taught with the concept of imperative where it makes programming easier to grok. I can see that functional programming is trying to solve the same issue from another point of view, where it wasn’t possible with imperative design.

If you were used to imperative, most of the time we will be thinking of information as an object. But now, with functional programming, you need to believe that the information will be transformed correctly based on the functions you give.

Switching concept from imperative to functional programming might require more time you initially thought it would be. So be careful when you decided to do so.

And that leads us to the second point.

2. Fewer People In The Community

Correct me if I’m wrong, but with a lot of students being taught in imperative design than functional programming, that already indicated how many people would understand imperative than functional programming.

During my time at UC Berkeley, I can’t even recall a class that taught me functional programming. Yes, we are using functions but not functional programming concept.

With fewer people understand functional programming, it leads to the next problem which is fewer people to hire. It then becomes the problem of the company to expand its product if there are fewer people that are comfortable with functional programming. It’s harder to find people with that kind of skillset.

3. Less Data, More Functions

Frontend work is mostly about displaying information to the client based on the data coming from the backend — of course, it’s more than that, but the basic concept is that. With that in mind, it is easier to manage the data in the form of an object than seeing a bunch of functions lying around without seeing the object itself.

Imagine when you were used to placing a debugger on your app, then grabbing information from an object; well now you won’t be seeing that thing so often anymore since most of the data manipulation is already hidden by the functions that you used.

4. Harder To Refactor

I encountered this issue when I had to remove a feature flag from the app; maybe it’s only because I don’t yet understand functional programming by heart, but I found it very hard since it touches a lot of things where I’m not sure if things would break. Here’s an example of the things that I have to work on.

Instead of just removing the feature flag from the store, I need to remove 20 or more lines just to remove all the functions related with that feature flag. Removing 3 lines from the example above is just a simpler example with what I had to do.

Conclusion

I’m not against functional programming, but I personally found it difficult to follow and I found more reasons not to proceed with functional programming than to use it. Where it then justified by the company’s decision not to move forward with that.

These reasons are from my own perspective after trying out functional programming. And I hope to know the reasonings from the other side on why we should be using functional programming.

--

--

Bernardus Billy Tjiptoning

UC Berkeley Alumni. Worked in the Bay Area for a couple of years as a Software Engineer. Working at Kargo Technologies as an Engineering Manager.