5 ms·
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 p
by rcfox 15y 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?
- gbog 15y agoRelativism 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.
- deleted 15y ago[deleted]
- roc 15y ago> "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.