Coding Style: Braces

Pages: 123
@LB,
I thought my post was outrageous enough to not be taken seriously :( I prefer spaces. A space is a space is a space. Can't say the same about tabs. They each have pros and cons, as long as a project is consistent it doesn't matter though.
I cant stand this
1
2
3
 if( something ){
    thisIsStupid();
}


That was all over the java book I got.
Just go on github, go to any project that uses tabs, look through the source and you'll see the 1000s of formatting errors because github doesn't use tab = 4 spaces
1
2
3
4
5
6
7
8
9
if (something) {
	std::cout << something1 <<
	             some_thing_2;
} else {
	while (not !x) {
		doStuff(param1,
		        param2);
	}
}
This looks improperly formatted to you? Fing tab size when it is not properly formatted. If those morons cannot follow "ident with tabs, align with spaces", it is their problem.
Course that is just an example, the only way to follow that rule is to constantly check to make sure it is correct. I didn't say it wasn't possible to properly align with tabs, i was saying its a lot more work and even if you are careful you can still easily mess up the formatting using tabs. With spaces it's what you see is what you get. Though i guess with some editors now that show spaces as dots and tabs as lines it is becoming less of an issue.

It's not their problem, it's everyone that needs to use their code problem.
Tabs should never be used for alignment. I'm only saying that I prefer tabs for indentation. But, we've had this discussion before. I meant for my post to sound as ludicrous as ResidentBiscuit's but I again forgot this was the internet.
Last edited on
To be clear... the only reason Tabs/spaces were brought up at all was because of the issue with Python silently doing Very Bad ThingsTM if you mix them.


Of course... that said... tabs are ridiculous and should stick to word processors where they belong.
This is why I like Code::Blocks and its inherent "tab is 4 spaces, so when you press tab, instead produce 4 spaces" ability. Or however many spaces you want. Makes it that much easier to align (or anything other formatting, really).
Most (all?) editors worth using have that functionality.

I just wish it was on by default.
LB wrote:
I meant for my post to sound as ludicrous as ResidentBiscuit's but I again forgot this was the internet.
That's some pretty closed-minded thinking there. Instead of arguing just throw me a couple links pertaining to tabs vs spaces in C++ and I'll be out of your way.

That does not sound ludicrous at all. It's no the internet in this case, it's you and you obviously don't know how to exaggerate. or you were just trying to cover your ass, well played using "the internet" as fall back

I used to care about style. And then I worked with someone who writes in Allman style with two spaces indentation and uses Win32 conventions throughout, up to and including declaring typedef T *LPT for many classes and using the __in and __out macros. Now I only see tokens.
helios, lol.
I've read some odd code myself. Someone should read some of the DMD compiler's code. It's an entire C codebase turned to C++... so much so that it still has the .c extension... even though its C++. Some odd styles up in there. Walter Bright is an odd programmer despite how much I agree with a lot of D's concepts.
closed account (3hM2Nwbp)
Auto format in any half decent IDE allieviates this issue in under a tenth of a second. Are people still using caveman tools (or lack thereof)?
I actually generally use a basic text editor with nothing but syntax highlighting.
I tend to use Notepad++ because most C++ IDEs do really weird or annoying things with C++11.
I always thought IDE's were obfuscated with so many options and functionality in so many menus I found it tedious to work with.

Gedit with the in-built terminal has everything I could ask for. I'm rather proud of the file joiner I made so I could cat my files into a single one to make it easier to send over email rather than attaching multiple files, still working on the uncat to separate them out again at the other end, I'll get there.
I always thought IDE's were obfuscated with so many options and functionality in so many menus I found it tedious to work with.
Nobody forces you.

Most IDE can be used as plain editors with some tweaking, and needed functionality can be enabled gradually.
And there is many of it which helps with work on medium-large projects. Symbol browser, sanitised error mesasges and ability to jump to the source of them, some refactoring features, autocomplete, Abbreviations, autoformatter, DoxyGen integration, ability to jump to symbol declaration/definition/occurences... If I can make HeaderFixup to work, that too.

If it had git/Mercurial integration, it would be perfect.
Last edited on
Nobody forces you.


Never said I was, but I'm not going to debate.
I don't understand how anyone can tolerate coding without an interactive debugger. It really is the biggest selling point to using an IDE. Way bigger than the project management, build settings, autocomplete, and syntax highlighting combined.
I have wasted days and weeks of my time trying to configure my IDE and compiler for my system. I have learned to just give up when an error message I get only has one result duplicated hundreds of times in mailing list archives with no answer.
Sounds like you picked a bad IDE. Good ones work out of the box with very little (if any) configuration.
Pages: 123