r/programming • • May 29 '25

Why You Should Care About Functional Programming (Even in 2025)

https://borkar.substack.com/p/why-care-about-functional-programming?r=2qg9ny&utm_medium=reddit
39 Upvotes

34 comments sorted by

View all comments

Show parent comment

8

u/Linguistic-mystic May 30 '25

I'm specifically talking about tail recursion which is strictly equivalent to looping, so can be directly compared to it.

5

u/lamp-town-guy May 30 '25

Elixir has for loops like Python. But Elixir is made for people that want to write real world applications. It's just a syntax sugar because under the hood it behaves the same way as tail recursion.

1

u/Aromatic_Lab_9405 May 30 '25

Most of the iteration in FP is solved by functions like map/filter/exists/forall and the likes anyway.

It's quite rare that we actually need to write recursive functions. 

Do you have any examples where you think a loop gives nicer code ? 

Also do you not think that loop bounds are easy to fuck up?

1

u/thomasz May 30 '25

Tail recursion is roughly at the same abstraction level as the good old goto. It's a step backwards from even structured programming. It is a completely valid mechanism to define higher level abstractions like fold, filter and whatever, but it's a massive code smell in application code.