Agreed 100%! I haven't written in go yet but whenever there are brackets I like for them to be vertically aligned with each other like Allman (even in Python!).
Agreeing with sibling comment too that K&R can be ok.. seems like K&R function declarations have Allman-like vertically-aligned brackets, but why not make that consistent for blocks inside the function too? 1TBS goes in the opposite direction, so not heaps of a fan of that.
I am a big fan of whitespace in code though, running afoul of various style-guides at times (like PEP8) because of the desire to put space between things to make things clearer.
I reckon code is already a very-condensed form of information, so it can help to make it easier to distinguish the meaningfully-different pieces by having some space around them. I know this is not everyone's jam, but that's what I like when reading code.
I often put an extra line of space after blocks, and between lines that are less logically linked, just to separate them in my head better. Also I do wish you could use brackets in Python so I could have my beloved Allman there too :P
To me it's a bit like formatting any document nicely.. we wouldn't usually let paragraphs run into each other, and I think in general it can be helpful to split up long blocks of anything into concept-sized chunks whenever possible for easier reading! (I think of this as a type of weird antialiasing)
Makes sense to me. The annoying thing with Go is that every end of line that doesn't have a brace gets a sort of virtual semicolon added, to make it easier for the programmer, so Allman style is forbidden, since it would mean that the previous line gets a semicolon appended. I guess that also means you can't split statements across multiple lines like you can in other languages for readability :/
Except that your opening brace is now *just wherever*. The information is "Here is the opening brace. Right where it's supposed to be."
Any of these styles can obviously work, but that one little detail brings a consistency that I personally appreciate. Your mileage may obviously differ.
I mean people keep going nuts for K&R and it does that for function declarations. It just looks neater to me to have a little bit of space before and after the code inside the block
Amen on both. The rest is just noise. Brackets are still a disaster though... I do love the fact that you don't have to close HTML tags. Making out-dentation close all brackets in order would be great...
Same, but for GNU. I can't speak for Go, as I hate Google with a dying passion, but the Rust toolchain not supporting GNU style is a tiny part of why I don't like the language (well, I do like it conceptually, but I wouldn't want to use it for anything).
Whitesmiths, if I remember correctly was used in Symbian C++. I remember I found it quite odd (as most things in Symbian) when I started using it. But, it grew on me and I actually thought it improved the readability.
You'll have to pry Allman out of my cold, dead hands. My favourite bracketing style by far, and I'm very annoyed that its a syntax error in Go
Agreed 100%! I haven't written in go yet but whenever there are brackets I like for them to be vertically aligned with each other like Allman (even in Python!).
Agreeing with sibling comment too that K&R can be ok.. seems like K&R function declarations have Allman-like vertically-aligned brackets, but why not make that consistent for blocks inside the function too? 1TBS goes in the opposite direction, so not heaps of a fan of that.
I am a big fan of whitespace in code though, running afoul of various style-guides at times (like PEP8) because of the desire to put space between things to make things clearer.
I reckon code is already a very-condensed form of information, so it can help to make it easier to distinguish the meaningfully-different pieces by having some space around them. I know this is not everyone's jam, but that's what I like when reading code.
I often put an extra line of space after blocks, and between lines that are less logically linked, just to separate them in my head better. Also I do wish you could use brackets in Python so I could have my beloved Allman there too :P
Same!
To me it's a bit like formatting any document nicely.. we wouldn't usually let paragraphs run into each other, and I think in general it can be helpful to split up long blocks of anything into concept-sized chunks whenever possible for easier reading! (I think of this as a type of weird antialiasing)
Makes sense to me. The annoying thing with Go is that every end of line that doesn't have a brace gets a sort of virtual semicolon added, to make it easier for the programmer, so Allman style is forbidden, since it would mean that the previous line gets a semicolon appended. I guess that also means you can't split statements across multiple lines like you can in other languages for readability :/
Why? The keywords that indicate brace opening are right there, and adding a whole line with almost no information gain seems a bit unnecessary.
Except that your opening brace is now *just wherever*. The information is "Here is the opening brace. Right where it's supposed to be."
Any of these styles can obviously work, but that one little detail brings a consistency that I personally appreciate. Your mileage may obviously differ.
I mean people keep going nuts for K&R and it does that for function declarations. It just looks neater to me to have a little bit of space before and after the code inside the block
Second that. I can tolerate K&R, but the others are blasphemy.
Amen on both. The rest is just noise. Brackets are still a disaster though... I do love the fact that you don't have to close HTML tags. Making out-dentation close all brackets in order would be great...
i used to do Allman and worked at a place where K&R was the rule, switched and never looked back
Allman is almost perfect.
If only it had begin and end instead of the ugly braces we'd be in a wonderful world.
Might I recommend switching to Pascal then?
I have a better idea:
Same, but for GNU. I can't speak for Go, as I hate Google with a dying passion, but the Rust toolchain not supporting GNU style is a tiny part of why I don't like the language (well, I do like it conceptually, but I wouldn't want to use it for anything).
[flagged]
Interestingly enough, the K&R variant called "one true brace style" (https://en.wikipedia.org/wiki/Indentation_style#One_True_Bra...) is the "one true style" that is mandatory in Go (although Go is never mentioned in the article).
Well, years kater, K had some more ideas for programming languages... :)
Whitesmiths, if I remember correctly was used in Symbian C++. I remember I found it quite odd (as most things in Symbian) when I started using it. But, it grew on me and I actually thought it improved the readability.