DEV Community

Discussion on: Challenge: Write the recursive Fibonacci algorithm in a different language.

 
avalander profile image
Avalander • Edited

Language limitations are the worst excuse for the developer, aren’t they?

It's also rather convenient to claim that other people's proposal is incorrect because they have to implement things that your language of choice gives you for free (or, in the case of Ruby, you need to enable a runtime option; still beats Javascript's strategy of not having it at all).

According to you I should not only hack tail-call optimisation into Javascript somehow (most current runtimes don't do any kind of tail-call optimisation, ever), but roll my own custom system to handle arbitrarily large numbers. I don't really think this was the point of the challenge.

Also, let's keep in mind that my solution blows when the stack isn't big enough to keep track of all the function calls, and yours blow when the number is too large to be kept in memory. So, while in practice my solution blows much, much earlier than yours, both are, technically, incorrect if the definition of correct is that it works for all natural numbers, and they are both incorrect for the same reason: computer limitations apply.

Thread Thread
 
stereobooster profile image
stereobooster • Edited

So, while in practice my solution blows much, much earlier than yours, both are, technically, incorrect if the definition of correct is that it works for all natural numbers, and they are both incorrect for the same reason: computer limitations apply.

The word you are looking for is "totality". Function is total if it returns a value for each input in the domain