214 points
*

I know it’s a joke but I prefer the tab option. It’s easy to convert tabs to any particular spacing or code point width. It can also vary, if wanted, based on terminal or editor type.

People with worse eyesight can have a wider indentation while those who choose can opt for something more compact

permalink
report
reply
55 points
*

Honestly I always preferred tabs for indentation and spaces for aligning. It doesn’t break anyone’s experience. And if somebody wants two spaces for a two-space-tab-width for indentation and other people prefer four. That will work just fine.

I hate seeing 2 space indents. Unreadable AF ( to me ). At least this way I can easily work in the same codebase without somebody being annoyed ( except for the crying about the tabs )

permalink
report
parent
reply
10 points

Why not tabs for both indentation and alignment? (Actually, I see indentation as just a specific use of alignment.) Word processors have been doing it for decades (and typewriters for over a century!). Surely we can convince our code processors to use user-definable, fixed position tabs instead of relative position “tab = x spaces”.

Keeping the [TAB] character in the file then allows everyone the layout they like.

Or has working solo for 40 years fried my brain?

permalink
report
parent
reply
7 points

What I mean with tab = x spaces is only visually and not actually ( there will ( obviously) still be a tab character in my preference. Not sure if that was clear.

Because alignment are fixed characters compared to indentation. For indentation the only question is how many characters the next indentation needs to be.

For alignment it is not fixed. As an example of PHP code:

function test(&obj) {
$obj->doSomething()
....->doSomethingElse()
}

The dots would be spaces because in IDEs people generally use a font where every character is equally wide.

If I would tab again instead of spaces it could work out if my tab length display is ( for one or more ) adds up to the width of the variable $obj. If somebody else has a tab width of 2 rather than somebody who has 3. It would only align for one of the two people.

Does make sense? I typed it out after a gym session on my phone.

Additionally. The whole problem is resolved by using spaces for both alignment and indentation. But in the cursor would still jump one space at a time rather than the whole tab ( although there are keyboard shortcuts for jumping words which would jump all of em.

I don’t know. Call me old fashioned. I like what I like :/

permalink
report
parent
reply
2 points

Yeah, I understood the arguments against using tabs for alignment, but never really got the argument against using them for indentation.

permalink
report
parent
reply
39 points

I can’t imagine it would be difficult for an IDE to scale the width of spaces found at the start of a line, to emulate this same customization while still preserving my sanity as a fervent space-indenter. I’ve never seen an IDE that does this, but it’d be an interesting compromise.

permalink
report
parent
reply
27 points

It’s not difficult at all, and many editors and IDEs already support this, making the entire point moot. Just do whatever the style guide says. I’m into PHP and Python so for me it’s spaces all the way.

permalink
report
parent
reply
8 points

How can it tell the difference between spaces used for indentation and spaces used for alignment, if you use the same character for both?

permalink
report
parent
reply
2 points

What if instead of having the IDE special case space characters at the start of a line, we had a special character that could represent a variable width space?

permalink
report
parent
reply
1 point

What if we did that, and then wanted to align something?

permalink
report
parent
reply
11 points

I agree, tabs are better but I have been using spaces for so long I can’t even imagine switching to tabs. also I’d have to reformat all my abandoned projects.

permalink
report
parent
reply
92 points

Tabs are objectively the better choice as it allows each dev individually to decide tab width in their editors. Spaces in contrast don’t allow this same flexibility as they are used for much more than simply indentation, for example you likely put a space after each argument or operator IE func(arg1, arg2) or 1 + 2.

permalink
report
reply
17 points

Also, a lot of editors won’t unindent on backspace of spaces indentation, so I end up messing up the indentation with a 3/4 indent

permalink
report
parent
reply
3 points

That just sounds like a shitty editor, tbh. Pretty basic functionality.

permalink
report
parent
reply
-3 points

Autoformatter should fix that, unless you use python. (but even then they might fix it to the closest proper indentation level)

permalink
report
parent
reply
9 points

Sometimes. I love auto formatting, I spam the shit out of it more than I spam save but it’s definitely not perfect. It gets real confused with inconsistent indention like that. Especially with Python it’ll fuckup

permalink
report
parent
reply
6 points

Yeah you need an auto formatter, which is worse than not needing it. Also yes its terrible in python like languages

permalink
report
parent
reply
-1 points

Code can be viewed in more than just an editor. It might be in a terminal, rendered in a browser, etc. Sometimes you might even have to view it in an environment you don’t control. I am very disinterested in configuring each and every tool to have sensible tabstops, if such a tool can even be configured.

permalink
report
parent
reply
4 points

Then don’t? The whole reason nearly all the spaces guys do 4 spaces is cause that’s the nearly universal tab width. You won’t like this but the same exact argument can be made for spaces yet I’d bet you haven’t even once configured the width of those.

I don’t actually change tab width, it’s the default 4 spaces equivalent for me but just because I don’t take advantage of the ability doesn’t mean I should prevent others from doing so.

permalink
report
parent
reply
2 points

The whole reason nearly all the spaces guys do 4 spaces is cause that’s the nearly universal tab width.

That is provably wrong. The default tab width in vim is 8 spaces, and the default indentation in yaml is two spaces.

permalink
report
parent
reply
2 points

This is simply false, many systems have them configured by default to 8, particularly most CLI tools. Git, for example, is 8, and btw, changing it is not readily done and requires you to hack around it by using a custom pager command. In fact, all core gnu utils (and even bash itself) default to 8, as well vim, emacs, nano, gedit, etc.

I use 2 spaces since I work in Haskell, which is a significant whitespace language where you want certain syntactic constructs to exist at a different level of indentation from your main code block. So yes, I have configured it. 2 spaces is also exceedingly common for HTML (browser Dev tools renders HTML with 2 spaces, even).

There is not a universal indentation width, though it is almost always universal within a particular language or perhaps project, in which case it’s much better to have everything standardized. Code formatters enforced on a project are the norm, and those are way more impactful on how the code is read. But they are valuable because consistency is valuable. And yet, somehow you don’t have huge scores of developers complaining about being forced to format their code in a way they don’t like.

As I said, you don’t necessarily control the environment in which you are viewing code. A common example is reading code over a shared screen. So you can easily end up reading code in a way you don’t like anyway, so it may as well be some reasonable (if not preferable) standard that everyone is using.

permalink
report
parent
reply
-11 points

Too much waste of space imo, func(arg1,arg2) or 1+2 is faster to write and to read.

permalink
report
parent
reply
11 points

Stilltoomuchwasteofspace

permalink
report
parent
reply
2 points

Whyusemanywordwhenfewworddotrick?

permalink
report
parent
reply
74 points

The sole purpose of the tab key is for instructing the editor to insert four spaces.

permalink
report
reply
43 points

To insert a… TAB. Not four or any n number of space but TAB

permalink
report
parent
reply
12 points

After years of ass-whopping by python interpreter for stray tab characters, I’m now mentally rejecting the existence of tab character in my computing devices.

permalink
report
parent
reply
9 points

Isnt that only because you “mixed” spaces with tabs? I have had no issues with python and tabs with no spaces for intendation

permalink
report
parent
reply
3 points

Yep the ASCII table just goes 1, 2, 3, 4, 5, 6, 7, 9, 10, …

permalink
report
parent
reply
18 points

*three spaces.

Actually, let’s make that two.

permalink
report
parent
reply
6 points

2 space gang represent.

permalink
report
parent
reply
2 points

They fear us. We have to hide in the shadows.

But this is just one more example of our superiority - a perfect compromise between the file size and the nightmare that is two different invisible characters

permalink
report
parent
reply
11 points

Cycling through buttons, atl+tab, Ctrl+tab, some other fourth thing.

permalink
report
parent
reply
2 points

something something real linux users don’t use gui and tab completion

permalink
report
parent
reply
1 point

You can take my Cinnamon GUI from my cold dead hands.

permalink
report
parent
reply
1 point
*

And indent according to my major mode.

permalink
report
parent
reply
44 points

Team Tab Supremacy Unite!

permalink
report
reply
43 points

Hell yeah tabs

permalink
report
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 7.2K

    Monthly active users

  • 955

    Posts

  • 37K

    Comments