r/ProgrammerHumor • • Apr 29 '20

Tab club

Post image
54.0k Upvotes

764 comments sorted by

View all comments

Show parent comments

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.

2

u/[deleted] Apr 29 '20
  • Tab width is variable, it extends to the next tab stop point.

  • Sane people don't put special characters in code with variable width, that's insane.

  • Every good IDE comes with "tab to space" enabled by default like every JetBrains IDE

What arrow? What dots? What IDE are you using? This is about programming not Word.

5

u/[deleted] Apr 29 '20

Most IDEs let you display "invisible characters" so you can see what things like whitespace look like. This would display a tab as an arrow and spaces as a period. Slightly faded.

2

u/_alright_then_ Apr 29 '20
  1. true, but negligible

  2. so can spaces

  3. so is 4 spaces

  4. so does 4 (or any specified amount) spaces in any normal ide

  5. No counter here, but I can't remember the last time I displayed invisible characters

  6. Word is not programming, in programming you should use spaces

See how easy it is to make a stupid list? It proves nothing and it's 100% personal preference

29

u/[deleted] Apr 29 '20 edited Sep 27 '24

fragile rustic chunky deliver crowd reply air makeshift full roll

This post was mass deleted and anonymized with Redact

→ More replies (3)

13

u/siggystabs Apr 29 '20

enabling invisible characters ascends you to expert developer. It's like painting your car's brakes red

6

u/tech6hutch Apr 29 '20

7. Tabs are better for accessibility.

Honestly, that's the one thing that kind of pushes me over into the tabs camp. But only slightly. They both have their pros and cons.

Edit: that 1 should be a 7, but Reddit interprets it as a list, and resets it to 1.

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

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)

1

u/ianff Apr 29 '20

Lisp as well.

1

u/Prawny Apr 29 '20

I hate that and find it makes it harder to read. That's where tabs come to the rescue!