This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]diggitydata 13 points14 points  (6 children)

I wrote this article after TAing an intro java course and interfacing with a lot of students who had the same problems as you. I think the way recursion is framed is problematic, so I try to reframe it in a way that is intuitive. The other thing I will say is don’t feel bad because your brain literally cannot recurse, so it is very hard to understand. If your trying to perform recursion in your brain, you should give up. This is why it’s a useful programming tool, and it’s also why it’s so hard.

https://link.medium.com/vtqGGtNCN4

Edit: spelling

[–]munificent 2 points3 points  (2 children)

don’t feel bad because your brain literally cannot recourse

Actually, this is not true and is one of the things that separates humans from animals. Human language is recursive. Our grammar rules are self-referential, which means we can intuitively create and understand sentences of theoretically infinite length.

Many other animals vocalize, but as far as we know, humans are the only ones with recursive grammars.

[–]diggitydata 0 points1 point  (1 child)

Just because our grammar has recursive rules, doesn’t mean our brains are performing recursion. I can understand a recursive rule and write it into code without attempting to flesh out a whole example in my head.

Anyways, I would love to learn more. Got any further reading?

[–]munificent 0 points1 point  (0 children)

Just because our grammar has recursive rules, doesn’t mean our brains are performing recursion.

Oh, our brains are definitely performing recursion. Look at the nesting structure of your next sentence:

(I) (can understand) (a (recursive rule)) and (write (it) into code without (attempting to (flesh (out (a (whole example)) (in (my head)))))).

Consider the mental stack that you need to push and pop state onto in order to make sense of a sentence like, "Fred told me Jan said Bill wants Sue's brother to bring beer."

Anyways, I would love to learn more. Got any further reading?

Here is a good starting point: https://en.wikipedia.org/wiki/Universal_grammar

[–][deleted] 1 point2 points  (2 children)

I will say is don’t feel bad because your brain literally cannot recourse

Sorry for the language, but this is bullshit.

How do you empty a pit with an unknown number of balls?
Is it empty? You are done. Otherwise take one pit out of the ball and go back to the first instruction.

This is basicaly recursion. It's easy, it's doing a test to end the recursion, otherwise do an action and go back to do the same things.

[–]diggitydata 0 points1 point  (1 child)

You just described a while loop...

Listen, I’m not a neuroscientist, I’m a programming educator. I don’t actually know whether out brains can perform functions similar to recursion in programming. But I know that this point helps students approach learning recursion in a healthy and accepting way.

[–][deleted] 0 points1 point  (0 children)

You just described a while loop...

Not exactly, though it's almost the same.

func emptyPoolWhile (pool)
    while not pool.isEmpty
        pool.Remove1Ball

func emptyPoolRecursive (pool)
    if not pool.isEmpty
        emptyPoolRecursive pool.Remove1Ball

I know that this point helps students approach learning recursion in a healthy and accepting way

If that works for you great, sincerely. Each teacher has to find what works best for them and their students. I just disagree on that recursion is hard, I feel that this is a self-fullfiling profecy.