3

As I have recently started using ES6 in production, I was going through an ES6 style guide (having more than 350 stars on GitHub). This guide mentions at least three times that "Tabs are evil. Don't use them!"

Also, another very popular JavaScript style guide by AirBnB also recommends using 2 spaces for indentation instead of using hard tabs.

Although I have been using tabs for all my frontend development (ES5 of course), and have no problems till now. I just want to know why tabs are considered evil in ES6? I thought it is completely personal stuff and it shouldn't matter. But are there any special scenarios in which the tabs can really become evil for ES6 development?

mg007
  • 155
  • 1
  • 4
  • 1
    Possible duplicate of [Why do some languages recommend using spaces rather than tabs?](https://softwareengineering.stackexchange.com/questions/121167/why-do-some-languages-recommend-using-spaces-rather-than-tabs) – gnat May 09 '17 at 06:02
  • Oh, gosh... telling people that spaces are better because you're making yourself to do so much more totally unneeded work, but hey, "we saved ourselves 2 minutes configuring the editor and then for 3 years we'll be hitting space key 4 times instead of typing a tab". Progress ;) The topic you linked should be used as a definition of laziness on the wikipedia. And let's not use IDEs, they're much harder to install than Vi. Usually it's smart... to work smart... – Slawek May 09 '17 at 07:45
  • 7
    @Slawek Most IDEs and more advanced text editors allow configurable soft tabs, so using spaces over tabs is no more effort than using hard tabs. – phuzi May 09 '17 at 08:12
  • 1
    Beside it combats most of the advantages of using tabs, like you cannot format code easily anymore, cannot use different tab size for each team member, you need to be counting space characters and people still are making mistakes so code gets formatted incorrectly... – Slawek May 09 '17 at 09:09
  • 2
    This question is off-topic here: we cannot read minds, if you want to know why some random guy on the internet says something, you need to ask that random guy. See also [Discuss this ${blog}](https://softwareengineering.meta.stackexchange.com/a/6418/1352). – Jörg W Mittag May 09 '17 at 09:20
  • @JörgWMittag Please note that this question is not regarding any flamed discussion about what should be used for indentation. As a software engineer, I'm just curious about the reason behind the strong opinion of that random guy and the recommendation of the airbnb style guide. And I think this is completely on-topic here [as per SO](http://stackoverflow.com/tags/coding-style/info). – mg007 May 09 '17 at 16:11
  • Please reopen this questions since I have asked this question [as recommended on SO](http://stackoverflow.com/tags/coding-style/info). – mg007 May 09 '17 at 16:26
  • [so] doesn't decide what's on-topic on [softwareengineering.se]. [so] decides what's on-topic on [so], [softwareengineering.se] decides what's on-topic on [softwareengineering.se]. "I'm just curious about the reason behind the strong opinion of that random guy" – Then you need to ask that random guy, because we cannot read minds. The only person who knows the reason behind the strong opinion of that random guy is that random guy. Nobody else can answer that question. Maybe he had a bad childhood. Maybe he lost a bet with his co-worker and had to write an unsubstantiated rant as a result. – Jörg W Mittag May 10 '17 at 00:47
  • 1
    Configurable tabs are great and all, but only if every developer is careful to never use a space character to indent. Having a no tabs rule avoids the need to monitor all your white-space changes during code review. – Eamonn McEvoy Apr 16 '18 at 09:06

1 Answers1

9

Because some people are unfortunately - stupid, and they still didn't notice it's 2017 not 1987... and they'll make everything to add themselves some work because their IDE/Text Editor is so old or so lame, it cannot properly support stupid, configurable tab char.

And the second part of the issue is that node.js architecture is a DISASTER. All the way. Almost nothing is working like it should. Starting from lack of working scheduler, and writing scheduling code "by hand", to improperly working foreach loops and no usable error support, ending with nested callback code which is WORSE and harder to maintain than goto-spaghetti written in the early days of '90 Microsoft Basic.

I'm not surprised that group of devs comming from an enviroment of people who cannot get a design of stupid "for" loop well - is having issue with a concept so "complicated" as tab character... and to add to the stupididy, all they can say is "tabs are evil". Well that's a great argument ;)

  • Tabs make code easier to read for different people on different devices (especially different screen aspect ratios)
  • Require less typing
  • You don't need to count characters so it's much easier to not make formatting mistakes
  • You don't need to argue like an idiot, about using 2, 4 or 5 spaces... you set it in editor
  • Are designed to indent not to separate words, like space

"Tabs are evil" is like arguing that page breaks shouldn't be used in DTP... let's align using newline.

No, the proper sentence is not "tabs are evil", but "we're too stupid to make our work easier, so we'll be working like in the '90s". It's not some C Kernel code where using spaces is justified at least historically, node is supposed to be "modern" way of programming modern interfaces.

JS is great for UI's developement, and totally SUCKS for the server side. It's interesting how even the "style guide" tells how badly it's designed for serverside code, and how bad this "coding guide" is, because AGAIN... some genius thought that "one size fits all", to propagate this moronic myth of "code which could be used both on client and on the server"... So do yourself a favour, if you're writing serverside - stay away from node. Use golang, scala, c#, php, c++, D... anything!

And don't allow anything related to JS to pollute your coding enviroment too much. These coding "requirements"... that happens when you want to create something that "fits all".... as, eg. using setTimeout it perfectly fine on clientside UI developement, but usually not a very good idea on the server-side.

Although I have been using tabs for all my frontend development

As any sane human being would do nowdays, if he can...

Slawek
  • 2,884
  • 16
  • 16
  • 2
    This answer seems overly combative. There's a valid point in there about IDE support, so perhaps an edit is in order? – Andy Hunt May 09 '17 at 08:19
  • 2
    @Slawek omg +999999 for having the guts to say what everyone is thinking!! – Ewan May 09 '17 at 08:31
  • 6
    This answer doesn't answer the question at all. What does the architecture of Node.js have to do with tabs? Why do you recommend using Go (whose official styleguide advocates using spaces over tabs), Scala (whose community styleguides advocate using spaces over tabs) or C♯ (whose community styleguides advocate using spaces over tabs) over ECMAScript (whose community styleguides advocate using spaces over tabs)? – Jörg W Mittag May 09 '17 at 09:17
  • @Jörg W Mittag If you'd saw github spaces vs tabs statistics, you'd realize that golang formatting is "use go fmt which will do it automatically"... and "use spaces only if MUST"... so it's the only language which has i think 99.9% tab usage. I mentioned archietcture, because if something is totally broken from the start... you may use some caution when reading "good programming practices", for a broken architecture. For the other languages, these were designed long time ago, when there were problems with tabs, which we don't face today. https://goo.gl/MS67ZY – Slawek May 09 '17 at 09:25
  • @AndyBursh Not sure what's overly combative. But I'm sure promoting bad practices from '80s and 90's nowdays - is just crazy. Same stands for most of node promises which were never true and will never be. Spaces were used to maximize compatibility... and that's it. Like tables on 95's web. Today we don't need to write everything using spaces because IDEs are no longer bad, same for writing everything in single language because "there's no alternative". So we should tell people to avoid things which are no longer needed and will only make their life harder, such as things similar to linked doc. – Slawek May 09 '17 at 09:35
  • 2
    "if you're writing serverside - stay away from node. Use golang, scala, c#, **php**, c++, D..." *php*? :) –  May 09 '17 at 10:08
  • @Orangesandlemons PHP has it's merits, as does Node.js. I'm not aware of any of the issues Slawek mentions here. What's the problem with for loops in Node? I can't find anything on that topic. – neilsimp1 May 09 '17 at 12:18
  • @neilsimp1 php indeed has merits. Just none that warrant it to be preferred due to nodes faults. In my opinion of course. –  May 09 '17 at 12:21
  • @Orangesandlemons if you're using eg. for (i=0; i – Slawek May 09 '17 at 15:07
  • @Slawek yes, but that sort of incomprehensive behaviour is a hallmark of php as well. –  May 09 '17 at 16:03
  • @Slawek Thanks for answering. Before shooting for production websites, I just wanted to know if there's anything which makes the tabs evil for *ES6*. But that does not mean I would entirely change my server side language just because I am unaware of some edge-case drawbacks (if any) of using a particular coding style. I appreciate your arguments about using tabs over spaces. But this question is only concerned about a very focused topic, let's also keep the answers focused. – mg007 May 09 '17 at 16:47
  • PS: I am currently using Node.js with [Koa](http://koajs.com/) on server side and will be sticking to it. – mg007 May 09 '17 at 16:48
  • @Orangesandlemons well in PHP you have for example "something" == 0, but in node, whole data model is just a pile of mess. – Slawek May 09 '17 at 16:51
  • @mg007 of course, would be strange to change tech for something finished, just wanted to let you know that this document you linked is generally bad advice, and you can consider something that is designed much better, like golang, for the next project... it's generally designed around the same principe as node, but it works ;) Well ... that's material for longer talk, but if you like node you should check it out ;) – Slawek May 09 '17 at 17:14
  • @Slawek: "if you're using eg. for (i=0; i – Jörg W Mittag May 10 '17 at 00:44
  • Actually it has everything "to do"... it shows that language which totally sucks for serverside was ported 1:1 to serverside, without any thought. On client you'll be, most of the time using DOM, which works perfectly fine... you can loop and easily identify element types using class or node name. While on serverside, when implementing any business logic - you'll end up with Objects (as hashmaps), and crap leaking to your foreach loops. It's unsuitable for convinient data processing. But that's actually small thing compared to other, serious issues, like lack of ANY(!) SCHEDULER. – Slawek May 10 '17 at 07:25
  • @Slawek: Node.js is a framework. `for` loops are part of the language. In ECMAScript, frameworks cannot change language semantics (this is different from e.g. Smalltalk or Lisp). Ergo, Node.js has nothing to do with how `for` loops behave. And even if it were true that the behavior of `for` loops were defined in the Node.js framework as opposed to being defined in the ECMAScript Language Specification, then you still haven't explained how `for` loops relate to the question at hand, which is "why did person X write this particular sentence in this particular document". – Jörg W Mittag May 10 '17 at 10:24
  • 1
    Downvoting because a) doesn't answer the question b) my mommy told me it's bad manners to call people stupid :) – Reversed Engineer Nov 19 '20 at 10:48
  • "it's 2017 not 1987" - Do you think tabs didn't exist in 1987? They actually originate with the mechanical typewriter, and were added [in the late nineteenth century](https://en.wikipedia.org/wiki/Typewriter#Tab_key) (Wikipedia) so I think spaces are the more modern option for coders, especially since then your code format looks the same on any editor, and doesn't depend on some special setting (tab size). That's probably the main argument against using tabs (IMHO). Come on! it's not 1878 anymore. – Reversed Engineer Nov 19 '20 at 11:22