Evil Computer Science Concepts?

I typically think of “evil” as relegated to the realm of literature and film, or the pretend games we played in grammar school. But, months after writing this article spelling out the fundamentals of recursion and how to apply it in PHP, the debate has been raging recently as to whether or not recursion itself is “evil”. I guess I just have to remember this stuff really helps some people, and there will always be coders with strong opinions. Like the PHP manual itself, sometimes the reader comments on an article can be illuminating. In this case, they are at least highly entertaining.

Liked this? Receive new ones in your inbox.

(You can unsubscribe any time.)


  • http://www.jhwwebsmith.com/ John

    Having just written a recursive function less than an hour ago, I’m horrified to hear it might be evil. The last thing I need is demons infesting my intranet site or the inadvertant release of planet-destroying dragons.

    Do you have a link to a bit of this debate so I can see what the issue is?

  • Robert

    Hi John,

    The link is on the word “this article” in the post:

    http://www.zend.com/zend/art/recursion.php

    I think more likely than not some people had bad experiences in CS 101, which only lead them to *think* that recursion is directly linked to planet-destroying dragons. None the less — better to be safe than sorry.

    Cheers,
    Robert

  • Joshua E Cook

    While recursion has its place, a naif misusing the technique can cause serious problems. Take the factorial code in your article, for example. Both the iterative and recursive methods compute the result in linear O(n) time, yet the recursive method also consumes stack space in proportion to n. The iterative method does not grow the stack to hold space for so many function calls and return values.

    “Structure and Interpretation of Computer Programs”
    http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html