18

God, Allman indentation style is such pain... God bless K&R...

For those who don't know, Allman is this:
void foo(void)
{
statement;
statement;
}

and K&R is this:
void bar(void) {
statement;
statement;
}

Comments
  • 2
    Thank you DevRant for removing whitespaces...
  • 9
    Well thats not entirely correct. K&R look like that for if, while, and for statements. For functions it look like Allman. Like this:

    int main()
    {
    if(something){
    statement;
    }
    return 0;
    }

    What you probably are referring to is the True Bracket Style. (1TBS)
  • 1
    So what does Compiler understands?🤣
  • 0
    @prvInSpace Good point and perfectly true. And although I am preferring 1TBS, original K&R is still makes more sense to me than Allman...
  • 1
    I think it has to do with the first code language that you are introduced to. I started with Delphi 7 and we were forced to follow Allman for those four years. So now anything else just feels wrong.
  • 1
    I can read either.
  • 2
    I use both K&R and 1TBS. It depends on which programming language I am using. For C I always use K&R and for Java I only use 1TBS.

    The one I can't stand is the GNU one. It's so horrible.
  • 1
    I'm in the "it's what you learned initially" boat. For me, it's TBS all the way (from early c, c++ days). IMO, it's so much easier to visually identify matching brackets.
  • 3
    As a Haskell dev:

    What are brackets? What are tabs? What are 4 spaces? What are semicolons? What is readability? What is existence? Why is my cognac glass empty?
  • 2
  • 1
    @austudo I'm neither poor nor innocent, but I am tormented.
  • 0
    Allman is clearly the best for readability.

    'Seeing' scope as you scroll down makes it so much clearer.

    Indenting isn't a problem with a half-decent IDE

    But 1TBS / K&R is just vile to look at. The scopes are lost.

    And I'm a C / C++ programmer. Never (would) touch Java, even with a shitty stick.

    I'm now in macOS / iOS land, and I still want to punch whoever it was at Apple that forced 1TBS. I can't even get the damn IDE to adopt Allman.

    But then my coding style is to have 3 blank lines between every method / function and have all grouped assignments vertically justified.
Add Comment