• edward@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    1 year ago

    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>? You wouldn’t use a bunch of spaces to indent a paragraph, so why would you use it to indent code?

    • StudioLE@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      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

    • Vlyn@lemmy.ml
      link
      fedilink
      arrow-up
      0
      ·
      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
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        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.