Dec 8, 2023
A task such as reversing a string is fundamentally recursive. There is nothing wrong with writing it as a loop, but if you are using a language that supports tail recursion, there is nothing wrong with writing it using recursion either. The compiled code will be pretty much identical in either case.
In that case, the only factor is which one is easier to understand. If you are used to recursion, I would say the recursive code would be shorter and simpler.