Hacker News new | ask | show | jobs
by rcfox 5227 days ago
The problem is that everyone has a different idea of what's nice to read. Some people are more comfortable with an algorithm in a for loop, while others would prefer to write it recursively. Who's to say which is objectively nicer to read?
2 comments

> "Who's to say which is objectively nicer to read?"

The one that's written clearly. An ugly, obfuscated loop is worse than clearly-written and commented recursion and vice-versa.

If the most pressing readability concern in your code is whether an existing loop would be more easily-read as recursion, you're already done. The code is clean enough. Move on.

Relativism has to be relativised. Some logic is better expressed in a loop, some other fits better in a recursion. A guideline is to use the simplest correct path, which means for example that if complexity of the result is similar, the loop is preferable.