> I spent five years in a codebase with tabs instead of spaces. In my editor, I had indents set to 2 spaces. GitHub annoyingly defaults to 8 and requires customization in order to fix that.
> I have no idea how spaces won, and I don’t really care (other than my slight annoyance that I will get over, eventually). Does anyone know?
I think, the reason is no one really care. But a common convention is better than everyone use their own style. It was one of pointless holy wars of code styling from a previous century. It is still not completely dead in a C world, but newer language just impose common conventions on everyone, so no more point of arguing should we use 8 spaces indentation, or 4 spaces, or tabs, or should we place a brace on a separate line, or whatever.
Those who deeply cares of these things can fine tune their editor to replace spaces with tabs or vice versa, so on-disk format would conform to conventions, while keeping a complete freedom for editing. But for the most of people it is not important enough to go for such lengths to preserve their preferred style of editing.
One of alternatives should have won and spaces have won. Probably due to a chance. Probably not. But why to bother? We ended with a better world were no one is arguing that their style is better then others'.
I use spaces because in my old age I find that I like to align things like end of line comments.
It didn’t really matter - if you used tabs or spaces - back in the day when you only looked at code in your own editor.
But, now with things like online git repositories, I find I will look at code in other places that may have a different concept of tab spacing to my editor.
For example, I was recently reviewing some code in github, and in various parts the indentation had gone nuts due to me using tabs.
Converting that to spaces fixes that problem.
IRT alignment, at the place that used tabs, everything was nicely aligned by having some pretty strict line-breaking rules. I never ran into those problems with those clever rules.
I enjoyed reading this and it made me think it would have been nicer if tabs had won in the end. My best guess for why is that 'replace all tabs with x spaces' is marginaly easier to automate than the (also pretty easy to automate) 'replace all groups of x spaces with tabs'. Ultimately, tabs may have been a better default, but having a default in the first place has way more benefits than spaces vs tabs offer in their own right.
I prefer tabs, but I've Lemming-ed out a couple of times and tried spaces, and had to switch back because it was weird the way the editor treated them as a tab sometimes and a space other times.
Tabs are great, and I can only echo the article that I'm baffled why we aren't all using them.
Well... here you are. First paragraph! ;)