Tabs make more sense because that’s exactly what they’re for, indents. Ignoring how it looks, which makes more semantic sense for an indent, <indent character> or <space character><space character>?
And by using tabs the IDE can customise whether it’s displayed as two character or four character deep indentation. It just makes so much more sense.
It’s insane that anyone considered spaces to be a sensible default. Yet I primarily develop in C# where four spaces are the standard so that’s what I use. However the reality is the IDE handles all the formatting automatically so I’m never actually typing four spaces
Well, the tab key was created to avoid repeatedly having to press space to create an indentation, but that was on typewritters, so either way, you can use spaces or tab key to indent text.
Now text editors can transform tab character (‘\t’) to desired amount of spaces, and I think the problem with using tab characters in code (‘\t’) is that system may have different configurations for the amount of space a tab char takes, making it look inconsistent on different systems, while space char is pretty much standard on every system.
I was pro tabs when I started out with software development. It just made sense, right? You press the key once, you get a single symbol, you have your indention, neat. And there is the argument that everyone can adjust their tab sizes, want it to be 2 spaces? 4? 6? Whatever? Awesome!
Then you write actual code and this perception changes. Tabs make a mess, developers often align both code and comments to make sense. That alignment only works at x-spaces and utterly breaks if you change tab width.
An example in C# with LINQ (just semi-random stuff):
var test = customers.Where(c => c.Deleted == false
&& c.Enabled
&& c.HasProducts()
&& blockedCustomers.Contains(c.Id) == false);
This kind of indention only works with spaces, not with tabs. And no, mixing tabs and spaces doesn’t work (like some users claim, that you can indent with tabs and then do alignment with spaces… nope, if you change tab with then your space alignment breaks).
Honestly, I don’t care either way, I just use what my company uses and adapt. But till now it has always been spaces (even though I was team tabs in university) and now I actually prefer spaces as it just makes sense. It’s consistent, it’s easy, it works everywhere.
Btw. the Lemmy code editor is shit, trying to align this was trial and error for a minute :-/
Ah, I see what you mean, out of instinct I’d have put one more tab on the “whatever” line, which would break the concept. But if you manually do both the indent + alignment in spaces then it works.
Besides your IDE of choice screaming at you that you are mixing tabs and spaces that is :)
It still feels like a hack though, simply going with spaces is more uniform and works everywhere. Especially as a lot of code is viewed in browsers nowadays (GitHub, GitLab, …) and tabs are often a mess in those environments.
Tabs make more sense because that’s exactly what they’re for, indents. Ignoring how it looks, which makes more semantic sense for an indent, <indent character> or <space character><space character>?
And by using tabs the IDE can customise whether it’s displayed as two character or four character deep indentation. It just makes so much more sense.
It’s insane that anyone considered spaces to be a sensible default. Yet I primarily develop in C# where four spaces are the standard so that’s what I use. However the reality is the IDE handles all the formatting automatically so I’m never actually typing four spaces
Just don’t use IDE
Well, the tab key was created to avoid repeatedly having to press space to create an indentation, but that was on typewritters, so either way, you can use spaces or tab key to indent text.
Now text editors can transform tab character (‘\t’) to desired amount of spaces, and I think the problem with using tab characters in code (‘\t’) is that system may have different configurations for the amount of space a tab char takes, making it look inconsistent on different systems, while space char is pretty much standard on every system.
I was pro tabs when I started out with software development. It just made sense, right? You press the key once, you get a single symbol, you have your indention, neat. And there is the argument that everyone can adjust their tab sizes, want it to be 2 spaces? 4? 6? Whatever? Awesome!
Then you write actual code and this perception changes. Tabs make a mess, developers often align both code and comments to make sense. That alignment only works at x-spaces and utterly breaks if you change tab width.
An example in C# with LINQ (just semi-random stuff):
var test = customers.Where(c => c.Deleted == false && c.Enabled && c.HasProducts() && blockedCustomers.Contains(c.Id) == false);
This kind of indention only works with spaces, not with tabs. And no, mixing tabs and spaces doesn’t work (like some users claim, that you can indent with tabs and then do alignment with spaces… nope, if you change tab with then your space alignment breaks).
Honestly, I don’t care either way, I just use what my company uses and adapt. But till now it has always been spaces (even though I was team tabs in university) and now I actually prefer spaces as it just makes sense. It’s consistent, it’s easy, it works everywhere.
Btw. the Lemmy code editor is shit, trying to align this was trial and error for a minute :-/
No, it doesn’t? Here’s the exact same text content with different tab widths:
The tabs are smaller but the spaces are the same, so the alignment remains.
Ah, I see what you mean, out of instinct I’d have put one more tab on the “whatever” line, which would break the concept. But if you manually do both the indent + alignment in spaces then it works.
Besides your IDE of choice screaming at you that you are mixing tabs and spaces that is :)
It still feels like a hack though, simply going with spaces is more uniform and works everywhere. Especially as a lot of code is viewed in browsers nowadays (GitHub, GitLab, …) and tabs are often a mess in those environments.