Hacker News new | ask | show | jobs
by tenebrisalietum 1092 days ago
But you are OK looking at this?:

        }
       }

      }
     }

    }
2 comments

Some times it's unavoidable but I'd try to avoid it if at all possible. There is no perfect syntax. It's common, especially with some newer constructs in TS/JS/C# that you end up with lines saying })), because of a closure passed. And I consider that kind of token salad to be quite a smell too.
"...if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program."
"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).