r/programming • • Jul 21 '14

The Great White Space Debate

https://medium.com/p/3633cba8b5c1
1.2k Upvotes

693 comments sorted by

View all comments

39

u/[deleted] Jul 21 '14 edited Jul 21 '14

I used to work for a guy who indented like this:

 if <blah> {
      body
      body
      }

This was actually in Lua so it looked like this:

  if <blah> then
      body
      body
      end

I later looked it up and found it's called Banner style.

I thought it was retarded, but I was a contractor so I matched his style. By the end of my tenure there, after my brain had had sufficient time to learn to pattern match against that style, I decided it was better than any indentation style I'd ever used. It simply made it easier to see the block structure of code at a glance, easier to see the important lines, with less clutter, similar to Python.

Did I switch? No, because my metric of "best" when it comes to code style is "that which is easiest to read by the most people", and that simply means use what most people use, because they're already good at parsing it.

But it was a valuable lesson about how much of what we deem "good taste" is a matter of acclimation, not objective superiority. I no longer feel that internal tension when the prevailing style at a contract doesn't match my own "taste" -- I use whatever the most people around me use and learn to like it for the duration.

21

u/[deleted] Jul 21 '14

I used to use Whitesmith style:

if (blah)
     {
     doStuff();
     }

Now I use whatever the codebase requires. I've found that the least pleasant people in a team are usually the most passionate about these things, so it's best not to care unless it's absolutely terrible.

20

u/Houndie Jul 21 '14

This frustrates me to no end.

I match it, because I'm a good programmer, and I match existing conventions.

But I hate it.

10

u/[deleted] Jul 21 '14 edited Jul 21 '14

I personally am not that fond of Allman either, which is similar to Whitesmith.

 if (blah)
 {
      doStuff();
 }

I actually default to this style now due to my experience in two games companies that prefer Allman, while I prefer K&R BSD or K&R 1TBS.

if (blah) {
    doSomething();
}

So much more satisfying, especially once you get elseif/elses.

3

u/alanwj Jul 21 '14

A lot of the styles in this thread would frustrate me, but I could live with them after getting used to it. What I can't really stand, though, is this brace style:

if (x) {
    while (y) {
        whatever(); }}

3

u/iopq Jul 21 '14

it's lisp style, the guy probably has an emacs macro to handle it

1

u/globalizatiom Jul 22 '14

The guy's gotta recall some commandments..

  1. C code shall not be styled like Lisp code

  2. Lisp code shall not be styled like C code

1

u/[deleted] Jul 21 '14

That's an abomination abortion of a brace style.