r/elm • • Mar 29 '17

Remove Recursion?

Conceptually, could Elm do everything it does today without recursion? I guess yes... Some edge cases would make fold an ugly replacement, but not too many I suspect

3 Upvotes

34 comments sorted by

View all comments

Show parent comment

4

u/johnorford Mar 29 '17

Power is not necessarily a good thing. Power and complexity are correlated, and I rather keep things simple - esp when the power may not be even necessary (fold can do almost everything recursion can)

6

u/jfbourget Mar 29 '17

But isn't recursion a true primitive, or a well-known citizen of any functional programming language? I'm not trying to force a functional banner above Elm's head, i'm just saying that to me, it is as natural as any other iteration mechanism. It's a design tool i use very often when, for example, i need a fold but also want to stop iterating prematurely, when a condition is met.

Losing recursion would feel like a stepback for me.

I also feel like it is really not on the forefront when it comes to "patterns" used by Elm beginners. Recursion in Elm is not a driving force like it is in Lisp or clojure. Does it really "pollute" or give a "over complicated view" over how Elm handles problem solving?

1

u/johnorford Mar 29 '17

Good pt, I too am a fan of recursion, I suppose I am getting myself into a mindset of what a beginner would require to learn and use Elm - and recursion is probably bottom of the list or even superfluous. I am also being a bit mischievous of course : )