Hacker News new | past | comments | ask | show | jobs | submit login

I've always been ok with no braces for one line statements. But they have to actually fit on one line and not be another nested block. I recently found a style guide for javascript that recommended only leaving braces out for statements that could be fit on the same line eg:

    if (something) doSomething();
    for (...) repeatSomething();
What I will disagree with is that braces are completely free. I believe that code which is vertically succinct is a good thing. It allows you to see more context at once which is particularly useful with well designed, well structured short methods and classes. I've always been opposed to excess white space, like the random blank lines within methods that programmers seem to put arbitrarily with no rhyme or reason, other than their personal aesthetics of course. Also spaces around arguments, putting the opening brace on it's own line (which I find terribly redundant anyone can see when a block has started).

I've always liked the K&R style aesthetically, but again I'll agree that Zed has found a decent example of where not using braces just because you can is taken too far.




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

Search: