25
you are viewing a single comment's thread
view the rest of the comments
[-] Vlyn@lemmy.ml 0 points 1 year ago

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 :-/

[-] edward@lemmy.ml 1 points 1 year ago* (last edited 1 year ago)

if you change tab with then your space alignment breaks

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.

this post was submitted on 17 Jun 2023
25 points (100.0% liked)

Programmer Humor

32071 readers
394 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS