Skip Navigation

Tabs are objectively better than spaces - gomakethings.com

gomakethings.com Tabs are objectively better than spaces

Yesterday, I shared some spicy takes. A few were particularly controversial—most notably, that I correct Gif the correct way (with a soft G)—but I also got a lot of emails asking me to elaborate on a few of them. Today, I wanted to talk about how tabs are objectively better than spaces. This won’t t...

Tabs are objectively better than spaces
155

You're viewing a single thread.

155 comments
  • I've always wondered why some people tout "forcing a consistent appearance across environments" as a pro for spaces. That's a bad thing.

    To be honest I'm surprised code format converters aren't ubiquitous. Let the repo have it's master format, enforced on commit. Then converters translate into each developer's preferred standard dialect on checkout and back again on commit.

    • The consistent appearance thing is probably more about how mixing tabs (for indentation) and spaces (for alignment, eg in multi-line function definitions of calls) looks like complete crap if you change the tab width.

      • I think you have it backwards. If you use tabs for indentation and spaces for alignment it works great for any tab size.

        It is when you use a tab just as a compressed representation of 8 spaces and use them for alignment as well that it goes to shit. (because you have made the sin of tab == 8 spaces instead of the correct tab = 1 indent level)

      • Using only tabs for indentation and only spaces for alignment will never result in crap alignment when adjusting tabstops because the alignment does not use tabs.

        This is using both tabs and spaces for alignment.

        --->func foo(int i,
        --->--->     int j);
        

        Observe what adjusting the tabs does,

        ->func foo(int i,
        ->->     int j);
        

        This uses only spaces for alignment,

        --->func foo(int i,
        --->         int j);
        

        When converted the alignment is maintained because the tabstops aren't used for alignment, only for indentation.

        ->func foo(int i,
        ->         int j);
        
155 comments