When I first started programming I used a lot of Integrated Development Environments (IDE) that made the choice of formatting for me. Back then I didn’t worry about things as trivial as indentation methods. As I grew in my knowledge I was confident enough to program outside of the help of an IDE and moved to raw text editors that were more minimal (Sublime Text 2). This was the first time I encountered the issue of tabs vs spaces for indentation.
For those who are unaware, the tabs vs spaces war is the use of the tab character versus a set number of space characters to represent indented lines of code.
I kept with tabs for a long time, only because they were familiar. I was more concerned with what the code did than its style.
So What Changed?
I became a lead developer and suddenly needed to define an internal standard/style guide. I went down the path of researching what people think about particular styles like brace positioning and various naming conventions. We adopted what large companies (Google, Facebook, Mozilla, etc.) had defined. But then I decided to look at what’s been said about indentation and go from there.
I really didn’t expect to find such a fierce “war of words” battle. Opinions on the subject are high to say the least. But, as i read through forum after forum, I found a few comments that stuck out to me and made sense. Most of them would be as simple as: “It doesn’t matter, just stick to one.” Although it wasn’t a detailed opinion, I had to admit that, overall, it really is the best advice.
As it turns out the most important thing about a standard is having one, and that’s all there is to it.
When Should I Care?
In my experience, if it is a personal project that isn’t likely to be read by another developer, then use what you want. The problems all come from collaboration, so it is best to decide with your collaborators what style to use as early on in the project as possible.
You may find yourself using the same standards in your own projects anyway.
What Do We Use?
So, should source-code lines be indented using tab characters or space characters?
Some say that tabs are evil and spaces are antiquated.
I say the evil of tabs vs spaces is to not choose.
What are your thoughts on this age-old battle? Let us know in the comments below!