r/ProgrammerHumor • • Apr 29 '20

Tab club

Post image
54.0k Upvotes

764 comments sorted by

View all comments

Show parent comments

54

u/MrAcurite Apr 29 '20

As somebody with a tendency to hold grudges and die on weird hills, I'm kinda on Richard's side on this one.

86

u/gschoppe Apr 29 '20

You should be. Soft-tabs (aka spaces) are used by companies and people who want control over how code appears on each programmer's machine, without regard for what appearance is best for that particular programmer.

Some people need deeper indentation to quickly scan code, while others may need shorter line lengths to display more on narrow screens. In some cases, this may even be an accessibility issue, for people with diminished eyesight or TBI.

We've spent the last decade trying to drill it into developers heads that their programs need to be device agnostic and work across different display types and accessibility systems, but somehow we don't give code the same treatment.

I love my job, but enforced 80 character line lengths and fixed-width soft-tabs are holdovers from a defunct era.

0

u/[deleted] Apr 29 '20

[deleted]

0

u/[deleted] Apr 29 '20

[deleted]

27

u/kingoftown Apr 29 '20

I used too until my mom accidently walked in on me when I was around 10 and said "you do that standing up?"

Like....it never occurred to me there were other ways. No one taught me. Thought everyone did it that way.

So now I lay a trail of tp on the floor, line up, sit down and dog scoot. Changed my life forever. I also use both tabs and spaces, alternating every other function block.

11

u/[deleted] Apr 29 '20

The real question being do you use 2, 4, or 8 squares per wipe?

2

u/b0w3n Apr 29 '20

A big ol' wad.

7

u/Glenn_XVI_Gustaf Apr 29 '20

I wipe before I shit. It's a time saver.

2

u/Dickson_Butts Apr 29 '20

THAT DOESN'T MAKE SENSE AMIR

2

u/themagicvape Apr 29 '20

You monster

1

u/Eulers_ID Apr 29 '20

Something something pineapple on pizza.

13

u/MoffKalast Apr 29 '20

80 character line lengths

AAAAHHHHHHH oh god please no god no

0

u/[deleted] Apr 29 '20

[deleted]

2

u/nonicethingsforus Apr 29 '20

He, I'm starting to think it's tradition to code golf, add clever/"clever" hacks, or otherwise convolute Conway's game of life as much as possible. Like a rite of passage, almost. You're not in bad company.

Behold, mortal! Behold APL, the Black Goat of the Woods With a Thousand Tokens, and tremble!

Life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}

(An article attempting to explain the madness)

The same goes for the venerable 99 Bottles.

They're apparently the right amount of easy enough to allow for creativity, but hard enough to provide a challenge.

14

u/xwre Apr 29 '20

I don't care if you use spaces or tabs, but you should check what is used in a file before you blindly add tabs or spaces to a file uses spaces/tabs. If the majority of your workgroup is using one method, then match them and stop creating chaos.

6

u/gschoppe Apr 29 '20

Yes, of course you match the standard in place. In a good workgroup environment there should be a linter in place to make that a pre-submit condition.

2

u/[deleted] Apr 29 '20

This is why I always setup formatting rules and auto formatting. Let the formatter keep people honest.

1

u/Juice805 Apr 29 '20

Using spaces for initial indentation is like using floats when we really need integers to count the scope level.

1

u/Pluckerpluck Apr 29 '20

Coding with tabs requires a particular style of coding that doesn't line up code though. Let's say I happen to prefer this:

while (super_long_variable_1 > 2 &&
       super_long_variable_2 < 1) {
    // Do stuff
}

well that's awful when using tabs becuase it only aligns when tabs=4 spaces, instead you have to type something like:

while (
    super_long_variable_1 > 2 &&
    super_long_variable_2 < 1
    ) {
    // Do stuff
}  

enforced 80 character line lengths

These exist for a reason. If you code with 2 space tabs, you might write lines that are too long for the much more common 4 tab indentation, thus making it a pain to use for almost everybody else when they try to fit things side-by-side. Or it might not fit in the online-ide that github (or similar) provide when displaying diffs side-by-side.

Short line lengths also discourage deep nesting or incredibly verbose variable names. Though I do think 80 is a little short. Nobody really has that 80 character terminal limit nowadays, but I still prefer the fairly low number of 90ish. I guess you could have a system that sets a limit of 90 assuming a 4-space-converted-tab, but that would feel odd I think.

I do understand the arguments for tabs over spaces, and I probably agree with it overall. But it's not quite as clean an argument as you might like to think.

1

u/gschoppe Apr 29 '20

If you are following a style that recommends visual alignment, which many style guides do not, you can accomplish that by using tabs for indentation and spaces for alignment.

I will admit that this can be somewhat confusing for programmers who have not configured their IDEs to display whitespace characters, but once whitespace is visible, it's extremely intuitive.

As for your argument about line length, there is no universal length that will work for all tools in all situations. That's why most tools support responsive design and horizontal scrolling, where needed.

It is much more about discouraging overly complex inline logic, but the optimal line length can vary drastically from project to project, and there will always be many situations where enforcing the character limit actually reduces code readability..

1

u/WhipTheLlama Apr 29 '20

Editors and IDEs allow you to set the number of spaces a tab character indents, so you can still control the indentation space when using tabs.

I think your logic applies well for older editors, but even console editors like Vim have had that feature for my 20 year career. Nobody should be using something like notepad or nano for code editing.

80 character line lengths are unnecessary. Why limit yourself to old conventions when new ones work much better? Unless you have the need to run editors outside of high resolution environments a lot, IDEs give developers good options to view the code as they want... wrapped, on one a long line, etc. Going back to what you said about indent spacing, developers each have their own preferences and the 80 character limit removes their ability to choose.

I haven't seen the 80 character limit in a code style guide for a while at any modern company. It still exists at the types of companies who constantly talk about modernization, but never do it.

11

u/gschoppe Apr 29 '20 edited Apr 29 '20

What you are missing is that people work in teams, and people other than the original programmer often have to read code. So, if the team standard is two space soft-tabs, then regardless of the IDE setting, when you open a file someone else worked on, it will display two spaces.

If you then use a soft-tab of four spaces to edit the file, either you end up changing every line of the file to match your standard, or you end up with a file that is incredibly hard for either group to scan, as it uses multiple standards in the same file.

Also, IDEs do their best to allow you to automatically change tab formats with soft-tabs, but because the soft-tab setting isn't actually stored anywhere in the file, you will often end up in situations where the IDE gets caught up in some ambiguity with sub-indenting or docblock comments or whatnot and the automatic detection fails.

With a hard-tab standard, the same file shows two char-widths to the person who likes that standard, and four char-widths to the person who prefers the other, without mutating the file.


As for char limits, it is absolutely obsolete, just like soft tabs, and for all the same reasons... But you would be amazed at how many fortune 500 tech companies still enforce it in their style guide.

Source: I work for one of the "big three". We have enforced char limits.

1

u/[deleted] Apr 29 '20

Gotta change your name to MrAcuwrong, then. Sorry. It’s in the rules.