News for hackers. Stuff that matters.
Re:Mindset Shifts for Functional Programming by nerdponx on Wednesday April 05, 2023 @07:32AM (#35452360)
I think the difference between recursion and looping is that the former requires you to be very explicit about the state you intend to modify and persist between iterations, while it's generally somewhat of a free-for-all in imperative loops.
Re:Mindset Shifts for Functional Programming by slifin on Wednesday April 05, 2023 @08:30AM (#35452985)
The most common looping construct I see in clojure is the for statement

Which isn't quite the free for all it is in traditional languages

You have to be very conscious and coding against the grain to use it to bang on values in place

Re:Mindset Shifts for Functional Programming by nerdponx on Wednesday April 05, 2023 @10:51AM (#35455229)
This is a general design principle that I appreciate about the Lisp family of languages in general. You can write highly imperative code that mutates things in-place, but it's a little harder to do and it's something you do only when you really need to do it. Whereas the default idioms are functional, and functional design is the path of least resistance. Perl is morally the opposite of functional programming in many ways, but I actually think this design is a great embodiment of the "make easy things easy, make hard things possible" ethos of Larry Wall.