On 2020-08-06 at 16:08:29 -0700, Christian Seberino <cseber...@gmail.com> wrote:
> > Trying to maintain that recursive list of unclosed lists in your > > brain is fun. It stretches the brain in interesting ways. I was > > way into Lisp at one point, including writing several Lisp > > interpreters (that simple structure makes Lisp very easy to > > implement). But I never found Lisp code very maintainable, because > > any time you read a program, you have to build up that list in your > > head every time just to follow the logic structure and figure out > > what the return value will be. "[R]ecursive list of unclosed lists"? Can you (whoever you are) expand on that? Yes, if you eschew helper functions and local variables, then you can end up with depply nested code, but that's true in any language. Because of Lisp's simple syntax, text editors can nearly completely relieve the programmer from the tedium of indenting and formatting, and even closing parenthesis, which also highlights missing/extra/unbalanced parentheses pretty quickly. > So basically while recursion is easy to write it isn't so easy for other > people to understand compared to iterative code. So maybe that is a > big part of it....recursion is just harder on the brain than iteration. I don't know about that. Have you ever seen an iterative or imperative version of quicksort (or any divide-and-conquer algorithm, for that matter)? Yes, it's doable, but explicitly managing your own stack of unsorted data ranges can really obscure the idea(s) of quicksort. And it's hard to imagine any language being more straightforward than Haskell's recursive factorial function: factorial 0 = 1 factorial n = n * factorial (n - 1) (Yes, it fails for n < 0, but that's outside the scope of whether or not recursion is harder on the brain than iteration. Pattern matching is a beautiful thing, too.) -- https://mail.python.org/mailman/listinfo/python-list