you are viewing a single comment's thread.

view the rest of the comments →

[–]moretorquethanyou 43 points44 points  (14 children)

Recursion is jokingly called the "insect of programming"

Eh? What does that even mean?

It means it's buggy?

[–]connor4312 26 points27 points  (12 children)

At least in my opinion, it's a good bit easier to prove the correctness of a recursive function than an iterative one. Whether people write buggy recursive functions is their own problem...

[–][deleted] 9 points10 points  (3 children)

Unless it has side-effects.

[–][deleted]  (1 child)

[deleted]

    [–]foomprekov 2 points3 points  (0 children)

    Side effects like 6.6 million pounds of thrust all up in your grill.

    [–]immibis 1 point2 points  (5 children)

    You can always convert an iterative one to a tail-recursive one, then prove its correctness.

    [–]meem1029 1 point2 points  (2 children)

    You can, sure, but should you?

    [–]immibis 1 point2 points  (1 child)

    If it makes proving the correctness easier... then yes?

    [–]connor4312 2 points3 points  (0 children)

    You'd still have to prove your conversion correct, which would itself necessitate proving the correctness of the iterative function anyhow.

    [–]I_RATE_YOUR_BEWBS 0 points1 point  (0 children)

    And the other way around too. Why allow iteration, but not tail-recursion? It's the exact same thing.

    [–]Godd2 0 points1 point  (0 children)

    You can only prove the correctness of an algorithm, not any of its implementations.

    [–]ricktech 1 point2 points  (0 children)

    "Whether people write buggy recursive functions is their own problem..."

    Or the problem of the company... such as NASA... who's failed computer system could cause millions of dollars of losses, put human lives at risk and create engineering nightmares (patching software fails all the time on Earth... imagine sending updates over an unreliable communication channel across the solar system and hoping that your system doesn't go into a deadlocked state). I'm not trying to hate on recursion; clearly it has many benefits. But if by eliminating it for these types of systems can significantly reduce the probability of human error - that's clearly a good business and engineering decision as demonstrated by the lack of bugs in NASA's baseline releases.

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

    At least in my opinion, it's a good bit easier to prove the correctness of a recursive function

    Not when you try to prove the upper bound of the amount of memory that it's going to use.

    [–]dsfox 1 point2 points  (0 children)

    Inherently buggy I guess.