I go for 3 spaces, no tabs for indentation (though tabs are quite good for their other role - lining up columns of data).
3 spaces because
- I find it the minimum whitespace to easily visually distinguish indentation;
- it's not even, so I'm not tempted to "half-indent" as I would with 4 = 2 + 2 spaces;
- even after 4 levels of indent (function + 3 nested loops) it's still only 12 spaces across the page.
I don't like tabs (for indentation) because
- default tab spacing is different for different editors;
- accidentally mixing tabs and spaces ends up looking ridiculous; and if, like me, you're also trying to learn Python you are in for a nasty shock;
- default tab settings (typically 8 or more) are ridiculous; if you switched from tabs to spaces would you really want to write eight in a row?
- default tab settings waste vast amounts of screen space with multiple levels of indentation;
- the editor that I use has << and >> prefix commands which allow me to shift whole sections of text left or right by any specified amount; this simply wouldn't work with tabs.
I do, however, often use tabs for aligning output. Then tab spacing of 8, 10 or 12 seems quite reasonable.
Braces:
- I just find them easier to identify and check if they are matched vertically; thus,
1 2 3 4
|
for ( ... )
{
// ...
}
|
std::
- Only when absolutely necessary; I'm a scientist/engineer/academic, not a professional programmer, and the maths I'm trying to code is quite complicated enough without adding a whole load of extra symbols. Besides, Fortran doesn't use it!
But if we all used the same it would be a boring world. (@Ganado's links were quite amusing!)