Comments by "Anony Mousse" (@anon_y_mousse) on "why is recursion bad?" video.
-
I doubt anyone will see this, but recursion is always unnecessary and should never be used. People keep bringing up tail recursion but not every algorithm can be written that way and if it can, it's just as easy to write and understand as simple iteration. If the iterative and recursive solutions are written correctly and they indeed yield the same result, the iterative solution will never crash due to any internal influences while it's possible that the recursive solution will, regardless of embedded system or desktop computer. This is because the stack is still limited in size even on desktops. If a developer can't translate a recursive algorithm into an iterative implementation, then they likely aren't very good anyway. One of the examples I keep seeing is for Fibonacci numbers, but I think the better example would be Quick Sort. If you've ever implemented one the correct way, you'll understand what I'm talking about, and even if you haven't, you might understand it should you read any C standard library implementation of it. You can have a simple solution that generally works, or a correct one, and you can have a complicated iterative implementation or a complex one. In the end, it's down to the programmer's skill.
2