DEV Community

Discussion on: Who Killed The Tab?

 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️ • Edited

I hear that "worst case" example of mixed tabs and spaces a lot, but it doesn't really make sense to me:

If using tabs would cause trouble because people would push code with spaces, how come it's not a problem when using spaces that people would push code with tabs?

Also, this can easily be tested, so people would see that the tests fail and correct it.


I felt like trying it out and just added a test to one of my projects that checks whether all the code files are indented with spaces:

github.com/DarkWiiPlayer/restia/bl...

It was easier than expected :D

Thread Thread
 
bytebodger profile image
Adam Nathaniel Davis

With all due respect, I think that your "worst case" scenario is a bit of a contrived edge case. I'm not claiming that there aren't certain styles that use tabs and spaces. But I am claiming that, if you've purposely chosen a style that mixes both, you are pretty far out of the mainstream and probably implementing that "mixed" standard to make some kinda point.

@defman illustrated how that example could easily be handled by using only tabs. And of course, it could easily be handled by using only spaces. If you personally insist on using both, well, that's fine. But I can't really use that as an explanation of why tabs are bad and spaces are good.

But there's no need (other than personal preferences) to use both tabs and spaces. After writing Java code for years, there was never a single moment when I (or anyone around me) said, "Dang! This is just so difficult because I can only use tabs for my indentation, and not spaces." And of course, I've never heard anyone using spaces who complained that they couldn't achieve the proper formatting.

To be absolutely clear, I prefer tabs. But if the team insists on using spaces, then the clearly-superior approach is to... wait for it... use spaces. As a shared standard.