DEV Community

Discussion on: Who Killed The Tab?

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

I know (for sure) that the way I see my code is the same way you or anyone else will see it

Exactly: Now consider that, no matter how much you like yow you see your code, someone else might feel differently about it. Accessibility is one factor, screen space is another, and someone might just like an indentation of 7 because it's prime.

The thing is: you don't need to worry. One tab means one level of indentation. It doesn't have to look the same for everyone, and I can't think of a scenario where some code might look worse because of a different tab width.

Collapse
 
kallmanation profile image
Nathan Kallman

One tab means one level of indentation. It doesn't have to look the same for everyone, and I can't think of a scenario where some code might look worse because of a different tab width.

I agree; I'm very much focused on my "worst case" scenario of mixed tabs and spaces.

Semantically I'm on team tabs; but practically I see why spaces have been chosen.

Thread Thread
 
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.