site banner

Friday Fun Thread for November 22, 2024

Be advised: this thread is not for serious in-depth discussion of weighty topics (we have a link for that), this thread is not for anything Culture War related. This thread is for Fun. You got jokes? Share 'em. You got silly questions? Ask 'em.

Jump in the discussion.

No email address required.

Which indentation style do you prefer?

IMO, Ratliff makes the most sense, because it's the only style that reduces the number of tabs after typing the closing brace, rather than before.

if(this){
	that();
	if(nothing){
		something();
		}
	}else{
	other();
	}

Indentation style is a problem for the IDE. The user should never think about it.

I find it disconcerting and nonsensical for the IDE to automatically delete a tab before the cursor when the user types a closing brace in non-Ratliff styles. Also, I'm not much of a programmer, but I imagine that writing a program to pretty-print code in non-Ratliff styles must be a major hassle, because it would force you to move the cursor backward and then forward again after finding every closing brace.

I don’t understand why more people don’t recognize that Allman is clearly superior.

If you get paid by the line, then it certainly is.

K&R, accept no substitutes.

It's logically consistent, space-efficient, orderly and readable. The others don't even come close.

While Visual Studio and C# are my drugs of choice, the worst thing about them may be the default linter & style guide's insistence on Allman.

K&R has always been the best, and as you say, it's not close.

I prefer K&R with mandatory braces around single-statement blocks.

Whatever the linter thinks is ok

There's a saying "code should be written to be understood by humans first an only incidentally executed by a machine".

None of them are actually harder or easier to read, it's just a matter of familiarity. You need to train your brain to quickly parse code and tweak that for new indentation styles.

You're going to have a better time if you just learn to read the most common styles quickly. You're inevitably going to be reading a lot of other people's code.

I like otbs. It's K&R without skipping braces on one liners, which can lead to bugs on a messy merge.

This looks very wrong to me. Closing brace being at the same indentation as the start of the block is what makes sense to me.

if (condition) {
    do_it();
}

This is my preference, but I'll work in whatever the code base I'm playing in already has.

Agreed. I also prefer two spaces of indentation to four, four is just such a waste of space for (imo) no readability benefit.