r/functionalprogramming • u/freefallfreddy • Dec 24 '23
FP Tired of seeing FP discussed as a single topic
(it's a bit of rant, I'd love to hear thoughts)
The older I get (42 now) the more I see the value of nuance in talking about all kinds of stuff, including programming.
One of the things that irks me is developers talking about FP as a single topic or a single concept. I see this in people that like and use "FP", but also in people that don't.
My take is the following: functional programming is not a single concept. It's a collection of programming practices and perspectives. If you ask 10 people "what do functional programmers do and don't do"? you'll get 10 answers that will have overlap but will also differ.
One of the problems with treating FP as if it were a single concept is the miscommunication. If I think immutability is essential to "FP" and another person has another view then talking about FP as a whole gets messy. It's a lot clearer to be more specific and talk about immutability.
What I also see people doing is "strawmanning" FP and saying you have to do "it" completely for it to be valuable. I've seen this quite a bit in FP vs OOP discussions. In my opinion it's way more useful to compare and contrast both the different parts of these programming styles and to discuss the spectrum of applying those parts. For example: you can write Java code in a classical OOP way and then write part of the code in a more pure style where you don't create stateful objects or not let stateful objects interact with one another.
10
u/One_Curious_Cats Dec 24 '23
You should add FP-style programming into this mix as well. I've had many imperative programmers tell me we don't use that. So I ask them, "So you never write functions or methods?" :-)
3
u/TheCommieDuck Dec 24 '23
"I'm tired of seeing FP discussed as a single topic" and then you seem to talk about OOP as a single topic lol
3
u/[deleted] Dec 28 '23
I agree with your sentiment that FP is a collection of things. I also agree that you don't need all of them, that it's too broad a term.
I think everyone is well attune to understanding that when someone says "FP" you have to read the post to see what aspects they're referring to. Unfortunately, I don't think think there's any getting away from that. So far no programmers have taken to defining the flavors of FP, as was done with jazz (bebop, big band, acid, ska, etc.).
5
u/acute_elbows Dec 24 '23
Yes I agree, I think the FP features being added to Java are very exciting! Do Records and Pattern matching making Java purely functional? No, but the programming patterns that they promote can make for cleaner and less error prone code.
2
u/saintpetejackboy Dec 25 '23
There is a lot of deep reading you can do where studies may indicate that these different methods of programming may have underlying and complex relationships with how individuals think and process information.
Personally, I learned my native language before it supported OOP. I begrudgingly use OOP in some contexts (databases), because it is superior to the functional method - but mixing in these two different paradigms is pretty common... Most OOP or FOP are really some kind of hybrid without really realizing it.
You don't have to be mutually exclusive with one or the other, but there will still be crucial differences to how a more Procedural/FOP thinking person approaches the same problem that ab OOP would. One way isn't necessarily "wrong" or "right" - if the end result is virtually identical, it doesn't really matter.
-3
u/mesonofgib Dec 24 '23
Functional programming, in a literal sense, means "building a program out of functions". This is opposed to OOP, where the basic building blocks of a program are objects / classes.
Immutability, purity / referential transparency etc are all implied in the particular definition of "function" in FP, but not technically necessary to meet the definition of functional programming.