3 ms·
Tail call optimization is a way for compiler to align functional recursive algorithm with stack-based procedural reality. Since Java is not a functional languag
by ivan_gammel 9y ago
Tail call optimization is a way for compiler to align functional recursive algorithm with stack-based procedural reality. Since Java is not a functional language and has sufficient expressive power to write iterations as... iterations, good programmer will just write a for loop and will not bother about a feature that is basically unnecessary in multi-paradigm language. Oh, by the way, recursion is a functional design pattern, isn't it?
- flavio81 9y ago> Since Java is not a functional language and has sufficient expressive power to write iterations as... iterations, good programmer will just write a for loop and will not bother about a feature that is basically unnecessary in multi-paradigm language. Ok, so you think recursion is unnecessary in a multi-paradigm language. Which implies also that multi-paradigm languages shouldn't be really multi-paradigm languages... Java, by the way, is hardly a multi-paradigm language. And you imply that the reason one uses recursion is because one can't "write iterations as ... iterations". You should realize that recursion is used whenever expressing the problem in a recursive way would make the problem easier to program and/or clearer to express, etc. Not because of recursion being fancy or fashionable. Recursion is a computer science technique, not a "Design Pattern".
- sorokod 9y agoKotlin is also a "non functional language" but does tail recursion optimization via tailrec keyword