When using braces, I mostly put the brace on their own line, and indent the lines between the braces.
if(cond)
{
statements;
}
else if(cond)
{
statements;
}
else
{
statements;
}
Also, I basically never put whitespace after keywords if there is a parenthesized expression required directly after the keyword.
Nowadays, I have come around to occasionally using brace-on-the-same-line. Particularly, I do this in JavaScript, because it becomes sort of nasty to write some of the annoying define-a-function-literal-and-call-it stuff to fudge around the terrible variable scope issues in the language.
var funk = (function(lib) {
lib.foo = function() {
if(thing) {
...
} else {
...
}
}
...
return lib;
})({});
If I were to prefer a language syntax, I would say that I want something that is easily machine readable, human readable, explicit, and parses the same regardless of whitespace formatting.
C-like languages have some annoying syntax problems particularly the "dangling else" problem. Here's some shoddy psuedo-BNF:
if_statement: 'if' '(' expression ')' statement ('else' statement)?
compound_statement: '{' statement* '}'
statement: if_statement | compound_statement | ...
Since the braces are optional, you get ambiguous cases in stuff like:
if(foo) if(bar) statement; else statement;
Does the 'else' bind to the inner if, or the outer if? It's not entirely clear to everyone. The resolution is to bind 'else' to the nearest if statement, but certainly it makes parsing more difficult, if you use a parser-generator.
This is why Lua gets my vote.
It has a very simplistic syntax, with a fairly low number of keywords and operators. Semi-colons are optional empty-statements to improve readability, but are not required. Newlines are also not required. There is no magical statement completion, like languages like JavaScript. Blocks have unambiguous 'end' delimiters, so this avoids the 'dangling else' problem that C languages have.
List and dictionary initializers use the same syntax -- because in Lua, there is one type, the table that mixes both types.
Unlike Python, you are free to use whitespace as you wish to make things more clear (although indentation is still generally recommended), without having to add syntactic noise to indicate "split this across multiple lines" or "put these related statements on the same line".
Unlike C, and like Python, you assignment is a statement, not an expression -- making a certain category of typos (accidentally using = instead of ==) impossible. They also don't clog up the language with unnecessary assignment syntax shorthands you see in most languages, like: for increments (++), decrements (--), and other in-place calculations (/=, *=, <<=, etc).
In Lua, unlike Python, local scoping is made explicit (undeclared variables are global lookups), and any block may shadow local declarations in an outer block, and can pass variables in outer scope as an upvalue to closures in a reliable way. Unlike JavaScript or Python, variable declarations are lexically scoped to blocks, instead of function-scoped. Unlike JavaScript's rules for global-fallback, you can actually change the lexical environment of a block to another table which is used instead of the globals table -- allowing you to reliably sandbox pieces of code from using insecure functions, or to prevent namespace pollution.
Python is also very nice, but I am often annoyed by the parsing complexities caused by using indentation as a block delimiter. Also, the fact that function syntax is sort of messed up -- there isn't really *good* syntax for anonymous functions aside from lambdas -- nested functions just feel really wonky, especially the variable scoping rules for them. I guess I just prefer explicit keywords.
Anyways.