DEV Community

Discussion on: Who Killed The Tab?

Collapse
 
leob profile image
leob • Edited

Let's put an end to this never-ending debate and choose what 80 to 90% of devs nowadays choose: SPACES ! Let's stop this, it's a waste of time and it's not worth it.

(next debate: terminate your statements with a semicolon in Javascript, or not?)

P.S. if you still need an argument pro spaces (against tabs) - I feel that the right way is: source code should ONLY contain printable ASCII characters (with the sole exception of line feeds)

Collapse
 
joehonton profile image
Joe Honton

What if the 10 to 20% were right all along?

Collapse
 
leob profile image
leob

Yeah forget about the 80 or 90%, that was the weakest argument ;-)

Thread Thread
 
bytebodger profile image
Adam Nathaniel Davis

Democracy is two wolves and a sheep voting on tonight's menu...

Thread Thread
 
v6 profile image
🦄N B🛡 • Edited

Yeah. And because of that "Fork" button, or its equivalent, on most open source code bases, just like the Second Amendment, coders also have the equivalent to some correction mechanisms on Democracy's excesses, Federalism and the Bill of Rights.

Linux Second Amendment

If you go too far, the sheep juuuuuust might fork ya.

If I may extend the metaphor beyond the point of usefulness, there's a valid concern in the backs of the minds of the wolves about armed sheep.

Collapse
 
amplanetwork profile image
Ampla Network

hii

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

My source code contains emojis

Collapse
 
bytebodger profile image
Adam Nathaniel Davis
Collapse
 
leob profile image
leob • Edited

What, in your variables names? 😉 okay I give up, let anyone just use whatever they like, even if they want to use aliens out of space (but not out of tab)

Collapse
 
mudlabs profile image
Sam

Terminte, because then at the end of every statement you can say; “you’ve been terminated”.

I’ll see myself out.

Collapse
 
bytebodger profile image
Adam Nathaniel Davis

He's here all week, folks. Tip your waiters.

Collapse
 
codefinity profile image
Manav Misra

This is why things like prettier.io exist along with ESLint. As an instructor, many new programming students have some sloppy habits. I provide all of the settings/configurations and automate the process of linting/prettifying the code so they don't have to be involved with '🚵🏽‍♂️ shedding' situations like this. They just code things up pretty much, however, stylistically speaking, and it's 'auto-magically' cleaned. Eventually, they get '🧠washed' into following some best practices.

Here's one example for Node

Collapse
 
bytebodger profile image
Adam Nathaniel Davis

There's no brainwashing quite like subtle brainwashing. 😉

Thread Thread
 
v6 profile image
🦄N B🛡

CLEANSE!

Collapse
 
lionelrowe profile image
lionel-rowe

"source code should ONLY contain printable ASCII characters" — try telling that (in 2020, where every mainstream high-level language already supports Unicode) to any developer who works and comments in a non-Latin-alphabet language.

Collapse
 
leob profile image
leob • Edited

Lol well yeah okay then, with the exception then of literal strings (texts) ... but you could argue that those texts should be in a separate bundle, rather than in the source code itself ... and let's not start using non-ASCII characters in variable/function names please ... I say programmers know English and stick to it (within their source code, at least)

Thread Thread
 
lionelrowe profile image
lionel-rowe

Well I think we can all agree that you shouldn't use tabs (nor spaces) inside variable names! 😂

Thread Thread
 
leob profile image
leob • Edited

Exactly, and not anywhere else either ;-)

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

What if 80% of devs would jump from a bridge?

Also:

source code should ONLY contain printable ASCII characters

  1. There's no functional difference between tabs and spaces. They're both just some blank space.
  2. You've already allowed for one exception, so why newlines but not tabs?
  3. This doesn't make sense either way. People argue that "nobody presses space bar to indent" but insist on using only printable characters? What's the rationale for that inconsistency?
Collapse
 
leob profile image
leob • Edited

Doesn't make sense to me at all, except for the 80%, which I agree is not a strong argument.

I said there's ONE exception (newlines), so that's the one and only exception, simple.

The fundamental difference between a space and a tab is that with a space always occupies the width of one "space" - so I can right away see that they're spaces, and how many there are - assuming that we don't use tabs. But if you allows tabs then that breaks down, it violates the "WYSIWYG" principle.

Well I guess you can still argue about it, but if I'm leading the project then tabs won't enter my codebase :-)

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

I said there's ONE exception (newlines), so that's the one and only exception, simple.

Yes, that's my point: one is an arbitrary number.

But either way, what's the point of that rule in the first place? In what case will you run into problems because your source code contains "non printable" tab characters?

To me it seems like this is just a personal preference, which makes as much sense as writing code that rhymes. If you want to do it, sure, but why should the whole world adopt this minor aesthetic preference?

As for the WYSIWYG principle, that just doesn't make any sense. First of all, most modern editors can visualize tabs and spaces, so the practical difference is just not there. The only difference is that, if I decide to use an indentatino of 8, you will also be stuck with it when editing the same code (or, more realistically, I might be stuck with a tab width of 2 which I find uncomfortably small so I will be less likely to work in that codebase). Or should I be expected to re-indent every file before and after working on it?

Thread Thread
 
bytebodger profile image
Adam Nathaniel Davis

To me it seems like this is just a personal preference, which makes as much sense as writing code that rhymes. If you want to do it, sure, but why should the whole world adopt this minor aesthetic preference?

Bingo! I don't personally mind someone arguing for spaces (or vice versa). But I'll admit that I do get annoyed whenever someone tries to argue for their preference by trying to twist it into some kinda empirical argument. I mean, if you really really like cinnamon, then throw it into all your dishes. You can even try to convince me to use it in all my dishes as well. But don't try to disguise your preference under some kinda faux-logical argument.

The only difference is that, if I decide to use an indentatino of 8, you will also be stuck with it when editing the same code (or, more realistically, I might be stuck with a tab width of 2 which I find uncomfortably small so I will be less likely to work in that codebase). Or should I be expected to re-indent every file before and after working on it?

The key here is that those arguing for 2-space indentation don't really have empirical reasons for it. The simple fact is that they like 2-space indentation. Which is fine. I don't have any problem with that. Just acknowledge it for what it is.

Every argument that you can make in favor of 2-space indentation could also be made for 8-space indentation. But most "space fanboys" would think an 8-space standard is ridiculous. In fact, the more I think about it, the more I'm convinced that the only way to logically discuss space-based indentation is to say, "Cool. Let's set EIGHT spaces as the standard." And then observe the appalled and disgusted looks on the faces of those who were arguing for 2-space indentation.

Of course, if you were using tabs, there is no argument to be had. Because every individual dev can set their own default for tab width. So if I started arguing for 8-space tabs, the logical reply would be, "Sure, set them however you like in your IDE."

But when you use spaces instead of tabs, you're deciding, for everyone else, exactly how they need to view the code. And those who argue for 2-space indents don't care - because they like 2-space indents. But if you turned it around on them and said, "No. I think we should use EIGHT-space indents." They'd think that's patently absurd.

Thread Thread
 
leob profile image
leob • Edited

Well now you're talking, that's the only argument until now that makes sense - by choosing tabs for indentation you can choose how it looks visually i.e. how wide the indentation is, with spaces that's fixed and you don't have that flexibility. So yes, if you use tabs consistently and only for indentation then there's something to be said for it.

Thread Thread
 
bytebodger profile image
Adam Nathaniel Davis

I have signed you up for a confidential membership in Tab-Lovers Anonymous.

Don't worry. I won't tell your friends. 😁

Thread Thread
 
leob profile image
leob

Thanks, well I hope they don't read this then!