Tabs vs Spaces

Did you read the actual post? They controlled for that and saw the same effect. (Or are you referring to how certain languages were excluded from the chart? Did anyone run the numbers themselves from the survey data without a filter?)

Where are you getting that? I don’t think the SO survey asks about typography. (I may be missing a joke. :slight_smile:)

1 Like

By people on both Reddit and HN.

I ran it without the filter. Here’s every language from the survey.

3 Likes

Elixir salaries are going pretty well by the way! :lol:

1 Like

But now we have half of a year later. I wrote and read code written by many people. waded through formatted source code of many kinds (manually vs. tool) and I came to a conclusion at about year change and I am in a transition phase since then.

I migrate slowly to use tabs for indentation and spaces for alignment. At least when I have the choice. For languages that have an official formatter or projects that use a style guide I adhere to those though (even when I am not always the same opinion as those guidelines or tools :wink: ).

@OvermindDL1 already did his point about this in Tabs vs Spaces - #27 by OvermindDL1 and I do understand it fully after using that style experimentally for about 3 months now in some C++ code I am hacking at for internal usage.

At least I will stick to this until elastic tabstops get proper support in the tools I use (emacs and VS code) and are not formatted away by the toolset I use (eg. mix format or go fmt).

3 Likes

Obviously haven’t worked with GNU source code. Tabs have to be fixed to render 8 spaces.

Why? Who forces me to do so? Who does even realize if I render it with a width of 2 locally or maybe 3?

2 Likes

Nobody is forcing you to. Problem with the GNU style is that your tabs have to be set to render 8 spaces so that alignment in the source code looks right. Reason is code is indented with 2 spaces but every 8 spaces are converted to tab characters. So if you don’t set you editor to convert every 8 spaces to tabs (not 4 or 3 or 2), then code just looks misaligned. I contributed a tiny change to gcc libstdc++ a long time ago but spent a disproportionate amount of time reading the code and I remember thinking how crazy the GNU style was. For example just

wget https://raw.githubusercontent.com/gcc-mirror/gcc/master/gcc/c-family/c-semantics.c

and open the file in your editor. If your tabs are set to render as 8 spaces then indentation will look right. If not then things will be misaligned.

Well, this falls under mixing tabs and spaces for indentation, and this is what I consider bad style. If there are consistently used only tabs for indentation and spaces for alignment, the actual tabwith will be irrelevant.

1 Like

To be honest, I see so benefits for educational reasons as well:
You can teach the difference between alignment and indentation.

As always, is it important to be explicit about everything, especially as newbie. To mix up alignment with indentation leads to a lack of understanding about both concepts, since it seduces you to assume that both is the same. :wink:

I will do this so now, thanks a lot ^-^

1 Like

Hmm, that is not really something I distinguish, but that is good to focus on… I’ll do that. ^.^

1 Like

So, is it unimportant to distinguish?
You might be probably already used to it, or?
Without teaching what is what, how to tell what is indentation?
Oh I see, you use languages which are not indentation significant :smiley:

This was shared with me today:

https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/

i get approached by not one, but TWO coworkers who unfortunately are highly visually impaired, and each has a different visual impairment

  • one of them uses tab-width 1 because he uses such a gigantic font-size

  • the other uses tab-width 8 and a really wide monitor

  • these guys have serious problems using codebases with spaces, they have to convert, do their work, and then unconvert before committing

  • these guys are not just being fussy — it’s almost surprising they can code at all, it’s kind of sad to watch but also inspiring

For as long as I can remember, I’ve preferred tabs for indentation (followed by spaces when alignment is desired), and I like being able to control the indentation width (if I remember correctly I’ve gone from four to three to two “spaces” in my tab width preference), but I hadn’t associated the ability to do this with accessibility before.

Also, from the comments, this may be useful:

Regarding Github, you can set a default rendering tabstop with an .editorconfig in a repository, and override with ?ts=<value> in URLs.

2 Likes

@BrightEyesDavid That hit pretty close to where I work. Reading things like that make me wonder why people use spaces for indentation, especially when by definition they aren’t for indentation…

1 Like