Hacker News new | ask | show | jobs
by sobellian 1092 days ago
"...if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program."
2 comments

"If somebody starts talking about stuff like lines count, function sizes, nested ifs depth and tries to define optimal values, then be very careful about their advices" - me, &currentYear
Regardless of what you think of this particular maxim, one could do worse than cargo-culting Linus.

Code org itself is IMO fairly trivial. I just do whatever I think happens to look good. But trends will emerge even when you're just coding to taste. Thumbing through my code I find very few instances of either `} } } } }` or `)))))` (disclaimer - I don't use lisp).

I think he's probably right for C. Unfortunately for TS/JS it's not just idiomatic it's downright unavoidable to have at least twice that number of { } levels.
Before async/await I would have agreed with you, but now I think 3 indents is a reasonable maximum (4 if you're writing classes).