Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If your blocks are big enough that this isn’t obvious, that itself is a code smell.

(Brackets also have the same problem.)



If you have a loop inside another loop and say and if statement, it can be hard to tell where the end is:

              I'm in the IF
    What am I in?
vs:

             I'm in the if
         }
      }
   }
   What am I in?
I'm sure it's just personal preference and I don't like it. I don't think significant whitespace is sort of a universal good that maybe it seemed like when it was proposed. It now seems more problematic to me.


> If you have a loop inside another loop and say and if statement, it can be hard to tell where the end is:

In either case, the aligned visible lines above (presuming reasonable block size) will be what clarifies that, assuming correct indentation (which is necessarily the case with syntactic indentation) and the brackets just add (in the example) three additional lines of separation making that harder.


Turn on "indentation guides" in your editor. A dotted line will extend vertically across the block.


I think it can become non-obvious in 10-15 lines. It is a trade-off, not a universal advantage. I suppose an IDE could cleverly draw little lines exactly when needed. One of the nice things about Python however is no IDE is required. This is one misgiving I have about C#, it is great but an IDE is nearly required.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: