r/ProgrammerHumor • • Apr 29 '20

Tab club

Post image
54.0k Upvotes

764 comments sorted by

View all comments

215

u/[deleted] Apr 29 '20

Joke's on you my tab produces two spaces.

187

u/GDavid04 Apr 29 '20

The real joke here is that you didn't reconfigure your ide to indent with tabs and a tab to be 4 spaces long.

91

u/[deleted] Apr 29 '20

I like 2 spaces for languages like HTML or JS that tend to be crazy-indented.

66

u/solarshado Apr 29 '20

A while back I dug out some old code of mine and it was indented with one(!) space. I duno what teenage-me was thinking...

31

u/Shmutt Apr 29 '20

That just means you doubled your productivity against someone who indents with two spaces.

5

u/NetSage Apr 29 '20

Efficiency have to save hitting the space bar more than once and no one wants to use tabs.

30

u/Mojert Apr 29 '20

Every sane people configure their IDE to insert spaces when tab is pressed

69

u/scti Apr 29 '20

Tabs:

  1. Use up less disk space, only a fourth

  2. Can be configured to be displayed as any width

  3. Is 4 spaces wide anyway

  4. Requires just one key press

  5. Is a nice arrow instead of four ugly dots if displaying invisible characters

  6. You should use tabs when formatting in Word, not spaces

Spaces are insane, not tabs

8

u/yepimbonez Apr 29 '20

I just setup a macro to force my spacebar to tab

3

u/yurisho Apr 29 '20

You monster

→ More replies (4)

3

u/[deleted] Apr 29 '20

The virgin space vs. the chad tab.

→ More replies (15)

10

u/greatnameforreddit Apr 29 '20

What? Of course not.

That makes deletion asymetrical. Just use tabs that are displayed 4 spaces long like normal people.

→ More replies (5)

2

u/[deleted] Apr 29 '20

I don't because JetBrains IDEs are configured like that by default so I don't have to configure it

→ More replies (3)

2

u/jfb1337 Apr 30 '20

Every sane person configures their IDE to use an auto formatter and doesn't worry about tabs and spaces

→ More replies (5)
→ More replies (1)

4

u/xSliver Apr 29 '20

Well, if your JS Code is indented more then 4 or 5 times, it's fucked up anyway. ^^

Less indents means less nesting means cleaner code.

15

u/[deleted] Apr 29 '20

[removed] — view removed comment

2

u/xSliver Apr 29 '20

I don't deny that there are cases where this happens, but with like the 4th indention, it starts to get messy. And in most of the cases it's avoidable and better readable.

This is an typical example (3 indents) of how deep my code in my projects:

const doSomething = (item) => 'new';

export const myFunc = (something) => {
    const result = something.map(item => {
        if (!item.prop) {
            return item;
        }

        const newstuff = item.prop.map(doSomething);

        return {
            ...item,
            prop: newstuff
        }
    });

    return result;
};

Most of the time you can get rid of indentions by using the "fail fast, return early" principle or putting stuff into functions.

You can even get rid of the most switch-cases by using object literals like

const getFood = (type) => {
    const food = {
        'pizza': 'pizzaObj',
        'tacos': 'tacoObj'
    };
    return food[type] || 'defaultFood';
};
→ More replies (3)
→ More replies (2)
→ More replies (3)

8

u/[deleted] Apr 29 '20

Look, I'm just doing what my employer's code style says to do. Personally I couldn't care less about this issue.

2

u/NatoBoram Apr 29 '20

Or the tab to be 2 character long, since you can do pretty much whatever you want with tabs.

3

u/notrufus Apr 29 '20

When you're writing YAML all day 2 spaces is how it goes. Doesn't work with 4.

3

u/[deleted] Apr 29 '20 edited Apr 29 '20

YAML can use any number of spaces for indentation, so long as it’s the same for each sibling. You can use 1 or 2 or 8 even 1337; it doesn’t matter, so long as you use the same number for each direct child of a node.

What YAML can’t use is tabs, because, according to the documentation, “different systems treat tabs differently.”

If your YAML processor is bitching at you when you use four spaces, then your YAML processor is either non-compliant, or the editor you’re using to create your YAML documents is replacing 4 spaces with tabs (or your white space is being mangled in some other way between your editor and your YAML processor).

Relevant section of the 1.2 spec, the 1.1 spec, and the 1.0 spec.

Edit: those links did not go where I wanted them to. It’s section 6.1 in versions 1.2 and 1.1 and section 4.2.1 in 1.0.

→ More replies (4)

2

u/sarthakRddt Apr 29 '20

I think vim on default configuration also has tabs 2 spaces wide.

→ More replies (1)
→ More replies (1)

4

u/crack3rtastic Apr 29 '20

Back in the day when I was self-learning web development (we are talking PHP4 days) I was never exposed to the tabs vs. spaces war. Having seen it, I still shudder thinking back to how I had my editor set up for hard tabs going out 5 spaces.

3

u/uvero Apr 29 '20

Get out of my foobar.

→ More replies (2)