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

If all { and } are on their own lines, then it modestly simplifies the ability to visually scan from one to its match because they appear on the same column with nothing between them.


But if your code is properly indented then you can do the same thing with the first character in the line containing the open brace:

    if (foo) {
    |   blah;
    |   blah;
    |   blah;
    |   blah;
    |   blah;
    |   blah;
    |   blah;
    |   blah;
    |   blah;
    }


I honestly think it may just be something physical in the brain!

That style, especially in other languages with callback hell, feels tight. I can't breathe...

That feeling of can't breathe is far far more of a potent dagger in the heart, than simply scrolling one extra mouse wheel in a Class.

The open and airy, instantly identifiable shape of the code is just like the fresh sea air.

An old friend at work used to call that style "NotepadOpenBinaryFileStyle". The reason that stuck with me was due to its accuracy!


Heh, I have a similar visceral reaction to the "open" style: what a waste of precious screen real estate. Now my eyes have to scan a much bigger area in order to see all the relevant information, and I might even have to waste time scrolling around to find what I'm looking for that I would not have had to if only all that unnecessary white space were eliminated.

Putting the brace on the same line also makes it easier to grep for function definitions.

So why not:

    if (
        x>y
       )
    {
      code;
      ...
     }
    }
(I've actually seen that in real code.)




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

Search: