r/functionalprogramming • • Nov 05 '23

Question Why is functional programming so hard

Throughout my entire degree till now, I’ve been taking OOP. Now I am in a FP course and I am struggling a lot. I understand it’s almost a total different thing. But I just failed a midterm in FP in Ocaml. I swear I could’ve solved the questions with my eyes closed in OOP. What am I doing wrong, why can’t I get a grasp of it. Any tips on how I should approach studying this.

78 Upvotes

87 comments sorted by

View all comments

Show parent comment

1

u/alexelcu Nov 06 '23

There's no such thing as “non-pure FP”.

FP is programming with mathematical functions, i.e., functions with referentially-transparent call sites. For this reason, FP is also based on lambda calculus as its foundation.

Working with “impure” functions, AKA procedures/subroutines, is just procedural programming. Although, something can be said about having “first-class functions” in the language, but these days a vast majority of programming languages do, and such a feature is only a prerequisite for FP.