DEV Community

Cover image for Ending the war or continuing it? Let's bring functional programming to OOP codebases

Ending the war or continuing it? Let's bring functional programming to OOP codebases

Cherry Ramatis on March 06, 2024

The more time goes by, the more I become a functional programming enthusiast. Even when I'm working in an OOP codebase, I try to apply small concep...
Collapse
 
anthonyvii profile image
Anthony Vinicius

YESS!! Another amazing article @cherryramatis. Thanks for sharing your knowledge with us. Nicee!!

Collapse
 
cherryramatis profile image
Cherry Ramatis

Thanks a lot!! It's such a pleasure

Collapse
 
eduardojm profile image
Eduardo Oliveira

Your text is amazing!!!!

Collapse
 
cherryramatis profile image
Cherry Ramatis

thanks honey ❤️

Collapse
 
maxgoldst profile image
Max Goldstein

I think this is a great summary for someone new to the topic.

Here's another perspective. Functional programming is about programming with pure functions, like ones in math, it's right there in the name. So why is it also about immutability? Because if you could mutably rebind a name from one function to another, it would no longer look like a pure function. And mathematical functions don't mutate anything: running lcm(6, 10) doesn't change six or ten. Mutation is a side effect.

Collapse
 
trusktr profile image
Joe Pea • Edited

OOP cannot be eliminated. "OOP" is merely syntactical sugar for what would otherwise be handling "objects" in memory using pure functions. Using pure functions is more difficult and cumbersome the more complex the "object" requirements get. TLDR: OOP is a superset of functional programming, and functional programming has not gone anywhere, and most languages have syntactical sugar (f.e. classes) to take functional programming to the next level.

Collapse
 
cherryramatis profile image
Cherry Ramatis

Agreed

Collapse
 
camilacodes profile image
Camila Figueira

bom demais!

Collapse
 
cherryramatis profile image
Cherry Ramatis

brigada migaaa

Collapse
 
elixir_utfpr profile image
Elixir UTFPR (por Adolfo Neto)

Again you are at Awesome Elixir Newsletter
elixir.libhunt.com/newsletter/406

Congrats, Cherry!

Collapse
 
cherryramatis profile image
Cherry Ramatis

Let's gooooo thanks for the love of always <3

Collapse
 
nikolai1312 profile image
Nicolas Evangelista

Thanks for sharing! This is pure gold!

Collapse
 
cherryramatis profile image
Cherry Ramatis

it's an honor to share knowledge ❤️

Collapse
 
andreasjakof profile image
Andreas Jakof

Loved it.
I am coding OOP for quite some time now, and I am also introducing more and more functional concepts to my code.

Very nicely written!

Collapse
 
chefemaster profile image
Jeferson Martins Bruno

Very nice Cherry, I am getting a better understanding of OOP and functional programming with you, Thanks

Collapse
 
starswan profile image
Stephen Dicks

anyone interested in FP should check out elm-lang.org/ - great simple language for learning FP concepts, building front-ends without all the complexity of Haskell

Collapse
 
giullianosep profile image
Giulliano Ferreira • Edited

I took a quick look at Elm and, honestly... it looks a lot like Haskell. But that's not a bad thing at all. I don't think Haskell itself is complex, the way it's taught makes it seem like it's more complex than it really is.

Collapse
 
vinnicedraz profile image
vcedraz-

You mentioned composibility in the end without having explained first what it is, is this a teaser for the next article or were we expected already know what that is or google it?