I would say a bigger problem with not knowing the foundations of any field well, is you can fall victim to the errors of the people who do understand it and interpret it for you.
In the case of recursion, I think the author does not go far enough. The problem with recursion is that the fact that a given recursion is O(n) is usually quite opaque, while for a loop it is obvious. This is a much more significant concern than the fact that the change of state from one iteration to the next is implicit, rather than explicit. However, you can avoid both recursion and mutable state by using map and reduce, e.g.
The problem arises because even though recursion is relied on heavily in the foundations of mathematics, mathematicians also like to use the weakest axiom system they can in a given situation. Therefore they use set theory when they really have to, and first order arithmetic (which includes recursion) most of the time. But computer programming does not usually even need recursion, and so we shouldn't use it except when we have to.
EDIT: seeing the O(log(n)) solutions, I started to wonder if there is a way to see this without knowing about numbers of the form a + b * sqrt(5). There is, and you can also see it clearly from my solution.
By observing that the way I use reduce is just applying a function n times, you only need to see that the function is a linear transformation on R^2, to see that the problem is just calculating a matrix power. It is trivial to construct the matrix power in log(n) using the usual tricks.
In the case of recursion, I think the author does not go far enough. The problem with recursion is that the fact that a given recursion is O(n) is usually quite opaque, while for a loop it is obvious. This is a much more significant concern than the fact that the change of state from one iteration to the next is implicit, rather than explicit. However, you can avoid both recursion and mutable state by using map and reduce, e.g.
The problem arises because even though recursion is relied on heavily in the foundations of mathematics, mathematicians also like to use the weakest axiom system they can in a given situation. Therefore they use set theory when they really have to, and first order arithmetic (which includes recursion) most of the time. But computer programming does not usually even need recursion, and so we shouldn't use it except when we have to.EDIT: seeing the O(log(n)) solutions, I started to wonder if there is a way to see this without knowing about numbers of the form a + b * sqrt(5). There is, and you can also see it clearly from my solution.
By observing that the way I use reduce is just applying a function n times, you only need to see that the function is a linear transformation on R^2, to see that the problem is just calculating a matrix power. It is trivial to construct the matrix power in log(n) using the usual tricks.