What is a brace? Simple, they're these little 'curly-q' brackety characters
Braces are used to define code blocks
. Do not confuse them with brackets
The two most common brace/indenting styles are as follows:
C-style tends to be more common than K&R, and it's what the LSL editor
uses for its default script
The advantage of the K&R style is that it saves a lot of space.
How much space? A linefeed and a tab isn't a lot of space added up...
The advantage of C-style is that Catherine likes it.
TreadWhiplash likes C-style a lot; and notes that C-style is a hell of a lot more readable in complex code!
ChristopherOmega disagrees with Tread. A smaller number of lines your eye has to scan through makes K&R code easier to read. It's all a matter of taste though.
It ends up being many MORE lines your eye has to scan through trying to find where a codeblock begins.
StefanNilsson also likes C-style and happily throws in the question of whether or not to explicitly add braces even when the code block consists of only one statement. The Swede says: yes!
As answered in my comment below, that depends upon how much you know (or want to know) your language. Also, when you gauge the scope from the distance you are from the margin, it doesnt matter which style you use in terms of how much more your eyes need to run thru.
I don't do this because it's more efficient to have it all on a single line.
DolusNaumova wonders if not putting spaces between a closing parenthesis and a brace is still K&R-style?
NornAlbion likes a mix of both styles, using C-style for default and K&R-style for the rest.
IoneLameth likes Python indenting so calls this moot (and seems to mix them in practice).
SkyHoney always adds the braces even for a single statement since she learned Perl, which requires them. Even though it adds an extra line for the closing brace, it makes the code even more beautiful. :)
I tend towards indenting the line after the conditional statement, reguardless of whether it's enclosed in brackets. Saves a couple lines without sacrificing a significant amount of readability.