r/functionalprogramming • • Feb 07 '23
FP On FP Being, Like Jazz, Too Broad A Term
I like jazz a lot, but not smooth jazz. I like the trios and the quartets, the mellow stuff. But saying I like jazz is misleading since there's a lot I don't care for. I know what I like but I don't have an easy way of communicating it so I just say "jazz."
Isn't FP like that?
Too big be taken as an indivisible whole. Maybe ascending half the ladder is more than sufficient for most. Or, putting it another way, can't FP taken only so far be good enough?
This fellow was wondering about FP's comparative deficiencies. I'm not saying FP is superior to OOP, but I feel I'm writing better code because of what it taught me. Instead of seeing its comparative deficiencies, I see an onboarding problem.
The trouble is FP is a loaded term and it means different things to different individuals. We're not sure what someone means when they say FP. Normally we have to read the post or listen to the talk a bit further to pick up clues.
My perspective of FP was informed by Clojure. So higher-order functions, dynamic types, immutable data, pure functions, composition, pipelines, reactive programming (e.g. atoms). Elm is at a similar level but uses static types. Haskell is a whole other ballgame. It gets into computational contexts of monads, functors, applicatives and category theory.
This complicates FP onboarding because people read on the Internet. The posts about the more advanced stuff can be off-putting. They may lead some to believe using FP involves all of the above, but, in actuality, it doesn't. I mostly keep to the less-intimidating stuff in my day-to-day use.
In the board game realm 24-page rulebooks are not abnormal. Such games intimidate casual gamers who have not yet discovered that some board games are worth the fat rulebooks. So we have gateway games like Ticket to Ride. They allow one to dip his toe into the pool of modern gaming without starting at the deep end. He can be gradually lead there.
In the FP world I'm not sure there are any articulate boundaries, nothing which is the equivalent of a gateway game. Wouldn't it be useful to slice the pie up somehow? To improve the terminology? Permit us to differentiate basic FP from computational context FP? I'm not suggesting I'm the most qualified person to wield that knife, but wouldn't there be some value to getting things down to a few broad areas so that FP, like jazz, could be better qualified and, thus, better understood?
The term is too broad to be useful. It's resulted in a communication issue, like continuing to use "snow" after taking up with an Eskimo community.
The trouble is whenever I tell someone about the merits of FP and they google it, there's no telling where they'll end up. When I say FP, I mean something specific which I can't easily communicate. Rather the only measure I have to clearly articulate specifically what I mean is dumping my toolbox and showcasing the tools. Awkward!
Since functional programmers probably congregate around a few key areas, clarifying what those areas are could improve the conversations, branding, and onboarding. Having a sliced pie which separates the gateway concepts from the rest would help devs get started. They'd be less likely to wander into the quagmire and muck and to mistake it as belonging to the same indivisible whole.
Today, there are practically no options for communicating precisely what is meant when you say FP. When I herald FP as "the greatest thing since sliced bread" and you nod and heartily clap me on the back, it's all a bit absurd because we're possibly thrilled about different aspects.
You like jazz? Me too!
Only you're thinking Kenny G. and I'm thinking Till Brönner.
9
u/josephjnk Feb 07 '23
I’m sympathetic to this position, but I think that all of the things you listed above still can reasonably claim to be “functional programming”. It’s an umbrella term. I think it’s more important to come up with accurate names for the subsections in order to guide people. I try to differentiate “lisp-family” and “ML-family” functional programming. I also like the term “algebraic functional programming” for the abstract algebra/category theory style.
I think part of the challenge is that there’s no single feature whose presence or absence determines whether a language is functional or not. There’s a set of FP-esque features, and the more of them a language supports the more functional it is.
4
u/Raziel_LOK Feb 08 '23
I think OOP do have the same problem, the term is more used but people certainly mean different things, probably there is more overlapping, but still the problem is the same.
OOP patterns is even more confusing, people have a different understanding and ways of using it.
OOP is not what most people think, the same way FP is not. OOP is messaging and FP is lamba calculus, but those do not do much alone so people will throw in a lot of language specific features and opinions to try to give it more meaning, that is how OOP = Java and FP = Category theory for many people.
I strongly believe this is more about the community. People right away think FP is some magic/wizardry, that you will need to know category theory, monads and every function needs to be a single useless expression.
Then community comes in, reinforce the same misconceptions, stereotypes and gatekeep knowledge, intentionally or not. This has been my experience in many situations.
Imo FP is way more homogenous even when applied to different languages. By that I mean the patterns are more recognizable by reading the code and it is ridiculously easy to compose into bigger things, that is where the selling point of FP should be.
There are many examples of that in the wild: react fibers, hooks and the JSX DSL itself. So composition is the key in my view, it does not need to be mathematically rigorous or monadic or point free, but don't tell then if they are, they will just use it.
5
u/roguas Feb 08 '23
Is haskell and clojure really all that different?
Weird as I happen to meet people having some experience/dabbing with haskell at much higher rate at clojure shops. Also heard of the reverse. Where it is quite rare in say ruby shop (idk any ruby shops, but just for good analogy).
There will be perhaps some difference and perhaps even a breaking point. It is not difficult to reach breaking point in haskell, there exist people who could but want not to haskell. For me monad transformers where, ok its too much bother, i dont want this for a simple case of combining reading a file and logging in "one pipe".
Fp is a fuzzy area and a funnel. You can get some "juice" in your current-enterprise-lang and start moving thru.
3
u/fl00pz Feb 08 '23
I tend to reference specific languages no matter what paradigm I'm discussing. Referencing a language and a feature of the language helps clear up communication. I do the same when I talk music. I don't tell someone I like jazz, I will tell someone "Lately I've been listening to [album] by [artist]". If the conversation goes deeper, then you're welcomed to discuss more artists and albums, and maybe even start to use more generalized terms.
So perhaps the problem is the question. "What music do you like?" is a bad question. I prefer to ask "What artists are you listening to lately?". Likewise, "What programming paradigm do you like?" is a bad question.
3
u/harrygz Feb 08 '23
Haven't read this post yet, but you had me at "I like jazz a lot, but not smooth jazz.".
1
u/[deleted] Feb 07 '23
I would add I don't think OOP suffers the same. When people say "OOP" there is a more harmonious meeting of the minds.
2
u/ZettelCasting Feb 08 '23
Ontology as tool?
Perhaps a fun partial mapping might be from the types in a stylistics of Jazz genres ontology to an FP ontology.
This made me think of the code ontology. OOP ontologyUnfortunately, it is limited to OOP, but nonetheless informative.
Of perhaps limited interest is the "Jazz Ontology" and the "music ontology", both of which focus on facilitating indexing of works rather than the styliistic and tonal abstractions.
Here is a diagram of the top level classes of the Music Ontology: top-level-music-ontology-diagram https://images.app.goo.gl/79QS93kaCMimC4MK6
I'm sure a similar decomposition of patterns and structures in FP has been done--which I'll try to find.
2
u/poimas Feb 07 '23 edited Feb 07 '23
FP to me is rooted in typed lambda calculus. Within any FP programming language you should be able to model your computation, define its caclulus and composition, etc.--e.g.: https://www.cambridge.org/core/journals/journal-of-functional-programming/article/modal-frp-for-all-functional-reactive-programming-without-space-leaks-in-haskell/9BE20E8D61E9B74811CF3CF97B5D10C7#
I think virtually all imperative programmers are cluess of the capabilities of type theory to model and reason about computation. They don't see the forest before the leaves--as you can see in many of the comments. They think FP is collection of features.
4
u/[deleted] Feb 08 '23
[removed] — view removed comment