5 ms·
What about Tabs vs. Spaces? :-)
by kwertyoowiyop 5y ago
What about Tabs vs. Spaces? :-)
- denismi 5y agoIt's so obviously tabs that it isn't even worth discussing.
- feupan 5y agoI obviously agree with you, but setting 3 spaces is so tempting.
- FredFS456 5y agoTabs are better for two reasons: - accessibility[0] - customization - not everyone wants the same tab-width [0] https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/ https://www.reddit.com/r/javascript/comments/c8drjo/nobody_t...
- greggman3 5y agomajor tech companies disagree with you tabs don't work for customization code // comment code code // comment If there are tabs between the code and the comments they won't align if you customize their length. If you use spaces there then you're just hypocritical. There are just as many arguments pro tabs as there are con tabs Many could be solved with smart tools. Have your editor reformat the text to your preference. Have it put it back to the project's preference when you check it in.
- Seb-C 5y agoBut nobody defends using tabs for aligning code. The debate is about indentation only. Tabs are not suited to aligning code, but ideal for indentation.
- greggman3 5y agoThey aren't really. You have to give up certain common styles. Example function(arg1, arg2, arg3, arg4, arg5, arg6) { code } The line with arg4 on it can't be indented by tabs alone but it's a common coding standard.
- markrages 5y agoThat's alignment, not indentation. Alignment should always be done by spaces.
- greggman3 5y agoThe people above claimed tabs let you customize. I'm only pointing out as soon as you add alignment that positive goes out the window.
- Dylan16807 5y agoIt doesn't go out the window if you can convince people to do it properly. I think you might be misunderstanding the alignment comment. The idea is that the lines starting with "function" and "arg4" have the same number of tabs, and then the "arg4" line has nine spaces after the tabs.
- Seb-C 5y agoExactly. The right way in this example would be like this (where '>' is a tab and '_' is a space). (For a better readability and ease of edition, I however prefer to actually indent arguments (each on it's line) rather than the suggested alignment, as I show in the second function) class Something { >const obj = { >>somePropName: 1, >>xyz_________: 2, >}; >function foo(arg1, arg2, arg3, >_____________arg4, arg5, arg6) { >>code >} > >function bar( >>arg1, >>arg2, >>arg3, >) { >>code >} }
- greggman3 5y ago
- markrages 5y agoA decent editor supports smart tabs
- floatingatoll 5y agoFolders have tabs, keyboards have spaces
- larschdk 5y agoTypewriters have tab stops that you can jump to by pressing the tab(ulator) key.
- jabbany 5y agoWhy not both ( ͡° ͜ʖ ͡°) Use tabs for logical indentation and spaces for line wrapping indentation! (/s)
- notapenny 5y agoI used to feel a way about this, but I honestly don't care anymore. Have your code-formatter deal with it and forget it exists. Even 2 vs 4 barely matters to me anymore as long as the code is formatted/structured in a consistent way.
- Dylan16807 5y ago> Even 2 vs 4 Sure, fine. I kind of like 3, to be honest. But have you had to deal with 8? My code's already inside a function inside a class. I don't want super wide columns, and I don't want >30 spaces of indentation when I go only two layers deep inside that function. Further back much of my code was inside a function inside a class inside a namespace... And code formatters are not usually very good at letting you edit in a different form from the canonical repo format.