At the end of the day you can do whatever you want with the code you're writing, and some pre-commit hook can run go fmt/prettier/whatever and then it'll all get standardized.
I've become a very heavy proponent of code formatters (I added prettier to the entire team) and I truly believe that talk about code formatting will never really die off, but at the end of the day you can do whatever you want on your side but still have a standardized looking codebase, and that feels extremely liberating to me.
As a PS: If you are a diehard tab proponent/different bracket placement/whatever but your team formatter configuration uses spaces instead then you can also use code formatters to do spaces -> tabs locally, say, on file open. Once you commit your file your precommit falls back to the team configuration, which removes your tabs. Everyone is happy.
I should see if he remembers where he got it.
So totally this. I despise indenting with tabs with a passion, but when I heard gofmt did that I was actually pleased. There's no arguing with the official formatting utility: https://golang.org/doc/effective_go.html#formatting
I just defer to the code formatter. That way everything is consistent looking internally, which is all I care about. I couldn't care less whether the braces are on the same or a different line or other things like that outside of the fact that I do like internal consistency within projects.
All that aside, as soon as I saw the OP title I knew (via years of exposure to bikeshedding programmers) that this thread would end up having a ton of comments on it and wasn't surprised to see it was up to 500-something and still rapidly climbing.
Same goes to spaces vs braces, editor wars, etc.
Downside: my projects are usually a bit of a mess with mixed indentation styles :D
How big once you remove all the extra newlines?
Thank god OC didn't mention "Just like you move from tabs to spaces."
To me, it looks weird when functions don't have that extra line of space to set off their definition, but if/while/whatever aren't special enough to need that call out.
That said, the most important factor is simple consistency. In my person projects, I have the hybrid style. At work, I use same-line-only. If I'm on a project that has next-line, we all use next-line.
int max(a, b)
double a, b;
{
return a > b ? a : b;
}The correct answer is whatever the project is already using, unless it is new and then you luckily get to choose.
Unsurprisingly, PEP 8 does have a rule for tabs vs. spaces: https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces (spaces, of course)
But tabs vs. spaces is indeed a bad analogy, because of course it's 4 spaces. ;-P
pycodestyle, the Python style checker, has a few checks disabled by default (because there's no consensus they're good ideas), and even some mutually exclusive ones:
https://pycodestyle.readthedocs.io/en/latest/intro.html#erro...
Tabs are semantic and only take one key press for movement back and forth and to delete.
If you see 1 tab you know it meant one indentation level. With spaces you have to think.
Plus with spaces you are stuck with 2/4/8 spacing(unless you reformat), with tabs you can configure your editor to your preferences.
Configure 1 tab to be 4 spaces.
Sometimes it's easier to go with the flow. I like tabs for the reasons you mentioned, but fixed-width spaces are a bit better for some reasons too. IDE's can do the heavy lifting of re-formatting indentation levels and converting tabs to spaces for me, and it means if I cat a file on a remote server regardless of the bash tab width settings or if I'm in your code or the stdlib it will all make sense.
Except that you can't because people using tabs will invariably start mixing tabs and spaces because they can't separate indentation from layout. So the code will be messed up unless you configure your editor to someone else's preferences. Also, I'm sure there is some obscure git setting to de-uglify tab users' diffs, but I'd rather not find out.
Before you say that I'm crazy... please, go and read pep8.
OK. What am I looking for?
Tabs vs. Spaces has a fairly good answer that flows out of this way of looking at things. There is a counter-argument to that answer, but it is invalidated if you move toward conventions for argument lists and chained method calls that are also designed to limit noise in the source control system.
IMO, the argument about bracing also has a practical, non-religious answer once you start looking at your coding conventions this way.
When I write Python I end every block with a "pass" statement so that emacs can auto-indent my code properly. The "pass" statement thus effectively becomes a close-brace. It drives Pythonistas into conniptions, but I never have to worry about reverse-engineering a block of code to figure out how to restore the proper block boundaries after a cut-and-paste has screwed up the indentation.
If boundaries exist they need to be clear. One shouldn't have to count the tabs that make up the level of indentation.
Its already a challenge reading code. Counting invisible tabs makes it even worse.
Similarly, copying code from StackOverflow, Github and random blogs have all worked without any issues.
So it can't be as easy as you imply.
The indentation strategy also looks to produce syntactically valid code, so long as what you are pasting lacked indentation errors.
Mixed spaces and tabs as a next go, and it worked too---converting the pasted tabs into spaces of my style.
Smart-tabbing is pretty smart.
Granted, I knew that so long as the indents were proper (i.e it compiles), that pasting at that point would give valid code but... I can't see how using braces would have been different. Just because it compiles, doesn't mean it works. I've pasted javascript incorrectly multiple time to produce valid, but incorrect for my needs code.
def foo(bar)\
:
if (bar > 5)\
:
return bar + 1;
#
else\
:
return bar - 1;
#
# >>> from __future__ import braces
SyntaxError: not a chancePS: he coded at Hercules the graphic cards back in the day before he got into teaching.
It's only people who cut their teeth on adjacent bracing that find it more readable.
I've seen both, and the reduction in vertical whitespace matters more to me than the readability to an untrained individual.
You seem to be erroneously equating a coincidence with a preference.
You should have a pretty cool family!