[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Let's settle this https://www.strawpoll.me/12588564

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 129
Thread images: 7

File: tabs-vs-spaces.jpg (126KB, 1440x679px) Image search: [Google]
tabs-vs-spaces.jpg
126KB, 1440x679px
Let's settle this
https://www.strawpoll.me/12588564
>>
File: proprietary.png (239KB, 480x451px) Image search: [Google]
proprietary.png
239KB, 480x451px
>2 space tabs
>>
>>59534116
THIS D E S U
>>
>>59534116
>2 space
I've always preferred 3space, but since they're tabs they are completely subjective to the individual developer's tastes and that is acceptable.
>>
>>59534082
>Using indentation at all
>>
>>59534082
Tabs, duh.
>>
spaces since unix displays tabs as eight spaces
>>
File: this-is-fine.jpg (67KB, 920x613px) Image search: [Google]
this-is-fine.jpg
67KB, 920x613px
Why not both?
>>
>>59534243
For you:
https://esolangs.org/wiki/Whitespace
>>
>>59534203
FORTRAN was right all along
>>
>>59534082
Considering every editor worth thinking about is easily capable of converting between the two and displaying tabs as as many spaces as you want, this discussion is literally irrelevant. Have your editor convert every file to your preferred style on open, and convert it to the project format on save.
>>
Tabs, because there's literally no reason to use spaces. And you can set the width of a tab.
>>
pros for tabs:
no reliance on editor for indenting/deindenting.
Some editors get confused as to what actually is an indent, when you use spaces for alignment
pros for spaces:
opens the same on every editor.

There is not benefit to using either; just pick one and consistently use it throughout the project.

I use tabs that are 8 spaces in width. They are very visually distinct, which I like.
>>
>>59534289
>>59534287
The only reason not to use tabs is on like ancient terminal modes which have special rules for either. There was a period where tabs were haram, that period is long over.
>>
>>59534270
That's going to fuck shit up if you use git. Having to swap between tabs and spaces every time you do a commit is annoying as hell, but it's easily possible that your editor will fuck shit up and pollute your commit with little whitespace changes.

Just use whatever the project uses. Neither have enough of a benefit to be worth the pain in the ass of constantly switching.
>>
>>59534302
I find that a lot of editors don't handle backspacing tabs very well. A lot of them require me to hit backspace 8 times to get rid of my space-tab. I don't see a reason to use spaces instead.
>>
>>59534314
There's always the possibility of a git-local .vimrc or whatever. I'm not sure what configs exist solely for writes and not for editing though.
>>
>>59534335
Sounds like you're editing wrong, that's the exact reason to use tabs so you don't insert spaces but rather columns of whitespace as a single character.
>>
>>59534336
I suppose that's always possible. It seems like it's violating the KISS principle though.
>>
>>59534344
>that's the exact reason to use tabs so you don't insert spaces but rather columns of whitespace as a single character.
That was a typo. I mean to say:
I find that a lot of editors don't handle backspacing tabs very well, when you use spaces as tabs.
>>
>>59534314
>assign project commit button
>auto changes whitespace before saving or committing
>wow_so_hard.jpg
>>
>>59534370
>violating the KISS principle
Something is probably going to fuck up and you're going to wind up cleaning up some unintentional white space changes every now and then. All because you're too autistic to just use the project standards.
>>
>>59534314
Git is often set up to automatically change line endings when using windows. No reason the same couldn't be done with spaces and tabs
>>
>>59534082
two spaces
>two spaces
>TWO SPACES
>TWO SPACES
>T
>W
>O
>S
>P
>A
>C
>E
>S


ree.
>>
>>59534409
I do not understand how you can use 8-space tabs. It makes code unreadable. 4-space is best desu, but I use 2 when writing in seeples for obvious reasons.
>>
File: scr.png (8KB, 463x67px) Image search: [Google]
scr.png
8KB, 463x67px
>>59534082
have fun aligning things with other things tabfags
>>
>>59534082
Only REAL developers use 4-space tabs for everything.
>>
>>59534434
So I can align useless variables and my knack for over-commenting my code to death?
>>
Why would you ever use spaces. If you're really worried about formatting literally every text editor is capable of converting tabs to spaces.
>>
related
https://www.youtube.com/watch?v=SsoOG6ZeyUI
>>
>>59534434
tabs for indentation
space for alignment

it is the only true way
>>
>>59534082
spaces, because I'm tired of tab = 8 space on anything that isn't under my control.

so fuck it. the only time i need hard tabs is for <<- heredocs
>>
>>59534457
>hitting spacebar 4 times

this is retarded.
>>
>>59534406
There's also no reason you couldn't just not be autistic and use the standards for whatever project you're working with.

There is nothing to gain here by not just following the project specifics.
>>
>>59534457
>>59534540
To be fair, they are using macs.

If they were using Lenovo X220s, they would both have configured their operating system of a text editor so that they never had to hit spaces at all.
>>
>>59534584
>so that they never had to hit spaces at all
jesus how the fuck did I type that
>>
>>59534406
\r is literally invisible in 99% of text editors

spaces and tabs have width, and git would have to make a decision that tabs or spaces are king. It's easy to make that decision (\n > \r\n in all cases) for carriage return vs. line feed.

That being said, tabs are better due to their ability to be customized. Tabs > spaces will almost always work fine. Spaces > tabs can get tricky as you are removing data.
>>
>>59534606
>\r is literally invisible in 99% of text editors
fun fact: if you don't use CRLF endlines, batch files can break in bizarre ways.

>That being said, tabs are better due to their ability to be customized
That can lead to alignment problems in the codebase. You really should just stick to one tab size.
>>
Tabs that convert to 4 space
>>
>>59534606
some form of s/^\s+/\t/, so hard.
>/^{4,}\s/\t/g
>>
>>59534642
If you do that, it can unintentionally cause whitespace changes and fuck up your commits.
>>
>>59534653
Could, or you could just write it in some git config and do it that way. Either way it's not anything close to catastrophic. It's incredibly simple.
>>
>>59534642
that fucks up my aligned multi-line array literals
>>
>>59534664
If you do it in the git config, can you make it automatically prevent unintended whitespace changes? I've never had a reason to use anything like that in git.
>>
>>59534696
I don't know if you can currently do that in git but adding it would be trivial.
>>
>>59534653
>>59534673
That was just some top of my head regex examples, you could very easily ignore newlines but keep ^ and negate it within matched braces and quotes or whatever.
>>
>>59534736
>matching braces with regex
wat
>>
>>59534431
Not sure either, but I have to use 8-space tabs for Linux kernel development.
>>
>>59534743
oh boy you're going to make me flex them regex muscles huh, I'm going to try to remember all this without a reference and no symbol-matching editor.
>/(("({4}\s)+.*")|(\(({4}\s)+.*\))/\t{icantfuckingrememberthis}/g

Okay so in a single raw regex that's going to be non-trivial, but there are other trivial options
>>
>>59534818
Oh those are supposed to be (?:)'s too
>>
lol we need this guy on our startup
>>
>>59534818
Since array literals can be nested it's literally impossible to correctly match them with plain regex.
>>
>>59534710
It seems like a waste of development time for the git people

>>59534736
tab + 4 spaces + text;
if you converted to 4 spaces in place of a tab would become
8 spaces + text;
then if you converted back to tabs, this would become
2 tabs + text;

If one dev uses 8 space tabs, mixes tabs with spaces for optimal alignment and the other uses this hack to do 4 spaces, this case will fuck up.

>>59534743
a lot of regex implementations have pushdown automata computational power.
>>
>>59534866
It would be something, alright.

>>59534889
Mixed tabs and spaces would be grounds for dismissal, of course. I thought that went without saying.
>>
>>59534889
sed's is pretty limited though
>>
>>59534925
Yeah, sed's trash all around. psed exists but is broken in half the packages anyway. I don't even remember what else has real PCRE but they exist.
>>
>>59534942
To be fair if you find yourself having to match nested structures you should stop using regex oneliners anyway.
>>
>>59534905
mixing tabs and spaces will give you optimal alignment. You can't edit code
with a different tab size because it'll fuck up alignment, but having multiple developers using different tab sizes is going to fuck other things up anyway. I set my max line length at 80 characters in my projects, so I can split screen easily; if someone's programming with 4 space tabs and I open with 8 space, they're going to go over the limit.

Just set one standard for the entire project and stick to it. don't be a snowflake.

If your feature requires you to strictly use only tabs or spaces, it's not very good.
>>
>>59534082
I don't code, so I don't know the ups and downs of this, but spaces looks better tbhfam
>>
>>59534958
Hah yes, loooong before that point.

>>59534960
>alignment
first, who gives a fuck about special snowflake alignments? second, if they are deemed NECESSARY they can be annotated and worked around easily.
>>
>>59534980
>special snowflake alignments
I align certain elements of my code because it makes it quicker to read. I use it for the same reason that I don't create thousand line procedures.

The more pressing concern is maximum line length. That's really fucking annoying to deal with; line wrapping is hard to read.
>>
>>59535010
Whitespace alignment is never correct.
>>
>>59535026
How do align things without any whitespace?
add shit like "/******/" between them?
>>
>>59535073
I guess you wouldn't, or you would just use tabs and newlines.
>>
>>59535110
Tabs and newlines are whitespace.
>>
>>59534465
Correct answer. Though Elastic Tabstops is also cool.
>>
>>59535136
Tabs are like schrodinger's whitespace, they aren't whitespace until they are interpreted. Newlines are most certainly not whitespace at all.
>>
>>59535171
You're wrong.
Please look up what whitespace is.
>>
This thread has made me see that nobody on /g/ works in the industry.
>>
>>59535185
set tabstop=0

newline is a non-character formatting notation which is none space.
>>
>>59535171
white space just means its a character that represents horizontal or vertical space. what consequences they may or may not have in say a programming language is a totally different issue.
>>
>>59534082 5-space tabs. It's how I indent my regular writing anyways and is just personally aesthetically pleasing.
>>
>>59535226
Right, but \n doesn't represent space. It represents position.
>>
>>59535215
It still creates space between characters, making it whitespace.
>>
>>59535246
So does' ', it shifts the position to the right instead of down.
>>
>>59535273
As interpreted, perhaps. The behavior is not dependant on the character but the interpreter.
>>
>>59535301
That's true for any character.
>>
>>59535308
Except that most characters have unambiguous interpretations. \n is not the same as CRLF. Space is always space, tab is god knows what. Control codes are not the same as characters.
>>
>>59534637
>You really should just stick to one tab size.
What he means is that it's easy to tell you editor how wide a tab should be, and instantly the code is indented at your preferred width.

It only breaks if some retard throws in spaces somewhere, which is retarded.
>>
>using spaces
>import someone else's code
>they were using tabs
>IDE automatically converted each tab to spaces such that they are aligned to 0 mod 4 on the char count of the line
>some alignment problems for custom-aligned things, but they are clearly and immediately visible

>using tabs
>import someone else's code
>they were using spaces
>IDE doesn't do anything, code looks fine
>continue coding using tabs
>open code in another context (such as in a browser)
>code alignment is a catastrophe
>google for option in IDE to automatically convert spaces to tabs
>no such option exists
>manually write regex script
>normal indent alignment is fine, but everything else is fucked

Yeah, I'm sticking to spaces.
>>
>>59535401
I don't understand, tabs are superior in both parts of that story, why wouldn't you accept them? In one they don't harm spaces-users, in the other spaces users harm tabs users? There's literally no harm in using tabs but great harm in using spaces. Are you intentionally writing malicious metacode?
>>
>>59535422
In reality, if you stand in front of a bulldozer and say "no, you move", you get run over. A flower that needs to be protected is not a superior organism, it's just an affectation.
>>
File: a.jpg (111KB, 533x519px) Image search: [Google]
a.jpg
111KB, 533x519px
>not using 1 space tabs (everywhere)
>>
>>59535442
That attitude really violates my code of conduct.
>>
>>59535442
Elequantly put anon. Are you a writer?
>>
File: negroni.jpg (112KB, 1500x1125px) Image search: [Google]
negroni.jpg
112KB, 1500x1125px
4 space tabs mah {{ pic }}
>>
For C-likes with no universal convention: smart tabbing (tabs indent, spaces align)
For everything else: go by convention

For HTML: No indentation for whatever gets sent to the client. Save bandwidth. Let the template code be readable.
>>
>>59535460
You gotta pick your battles, man. If I were saying "I refuse to optimize my algorithm growth because it interrupts my workflow" that'd be different, but choosing consistency over indentation-resizeability is a cost I'm willing to accept. We use monospaced fonts for a reason, after all.
>>
>>59535391
>It only breaks if some retard throws in spaces somewhere
It also breaks if I want a maximum line length. If two people are coding on different tab sizes, one is going to go over the line length limit.

A line limit of 80-100 is necessary if you
want to view your code in split screen on
a 1080p monitor. Otherwise you get line wrapping, which is really hard to read.
>>
>>59535568
That's not true at all though because a tab is a single character. What DOES break is your interpretation of line length.
>80 character tabs
>can't ever code anything
If your work is suffering from YOUR PERSONAL indentation setting then that is entirely your own damn fault.
>>
>>59535442

>In reality, if you stand in front of a bulldozer and say "no, you move", you get run over
And then the bulldozer driver is charged with second degree murder.
>>
>>59535595
>If your work is suffering from YOUR PERSONAL indentation setting then that is entirely your own damn fault.
You're making the exact same argument I was making for why you need to force the tab size for all developers. If the tab size is 4 and some idiot uses 2, that's going to make everyone else's code go over the line length.
>>
>>59535646
What? No, are you insane? If someone uses a 20 length tab his lines are going to be super short and it will affect no one but himself.
>>
>>59535613
>the bulldozer driver is charged with second degree murder
I think it would be considered first degree murder in that case. The driver would have to have made a concious unprovoked decision to kill the man.
>>
>>59535655
You still have to manually line wrap your code when you write a really long function call. It'll look weird if you start line wrapping way earlier than you should.

Standards exist for a reason.
>>
>>59535345
A character like \x81 is not unambiguous at all.
They are all codes, and every one of them is dependent on how it's interpreted.
>>
>>59535671
It'll look weird and break nothing but apparently your pride.

>>59535687
Q isn't ambiguous in any encoding.
>>
>>59535695
it's hexdecimal, genius
>>
>>59535704
It's hexadecimal and Q. Probably also some asian thing, but they're all the same as interpreted everywhere. You could create some context in which it would be ambiguous what it meant but in the context of any text encoding, it's completely unambiguous.
>>
>>59534082
Four-space tabs are superior in C-like languages

Two-space tabs are good in Ruby-like languages
>>
>>59535695
>It'll look weird and break nothing but apparently your pride.
edgy
>>
>>59535730
What?
In what fucking encoding is 0x81 Q?
Why would even have Q again since it's already 0x51?
And no, its meaning does differ in different common encodings
>>
I thought tabs were always 5space??????????
>>
>>59534082
I never understood people that use spaces. There's a character for indentation, any decent editor can adjust it to your favorite length, and everything is fine. Even better: you can use virtual space on tabs like many modern editors do, so it works like spaces, but it's actually tabs. You can even convert tabs to spaces and back again.

The issues really come from people indenting shit in retarded ways, whether with spaces or tabs, and then suddenly the space/tab conversion fucks up. But then as usual, it's a problem with people being retards, not either solution being bad.
>>
>>59534082
I will post this poll to reddit
>>
    Indent with tabs, align 
with spaces.
>>
>>59534082
>not mapping your tab key to produce 4 space, which is the industry standard

in all seriousness, you do what your company says. if you get uppity or whine saying "i don't like to do it that way" well you're probably gonna get fired.
>>
>>59538340
>tab key to produce 4 space,
>industry standard

No, no it isn't.
>>
4 space > the rest
>>
Whichever you prefer is okay as long as your programming language doesn't force you to use them.
>>
>>59540706
What programming language forces you to?
>>
This doesn't matter if you're a competent programmer.
>>
>>59540771
Python. Although most IDEs treat a tab button press as if you'd pressed space 4 times.

The syntax requires proper indentation with spaces. Because fuck curly brackets, right?
>>
>>59538372
Tabs to 3 spaces, excellent compromise.
>>
>>59540798
No it doesn't.
It only requires you to be consistent.

I use tabs in Python.
>>
>>59534082
Where's the option for "It Doesn't Matter"?

Any sane IDE can convert from tabs to spaces and vice-versa.
>>
>>59540847
Spaces to tabs won't work with mixed styles.
>>
>>59540860
Actually, yes it can.
>>
>>59534082
>Let's settle this
Do you really think we'll settle this?
>>
>>59540866
No it can't.
It would convert alignment spaces into tabs which is the last thing you'd want.
>>
>>59540830
If you're using an IDE it's turning it to spaces for you.
>>
>>59540893
Why turn something to tabs to turn it to spaces again?
>>
>>59534203
You would hate Python
>>
>>59540922
Because fuck you it's python that's why
>>
>77% tabs
Absolutely disgusting.
2 space indents for ruby, 4 space indents for everything else.
This has always been the standard and for good reason. Not all systems display tabs in the same lengths.
>>
>>59540990
Why would display length be a target issue? That's the developer's business and not some style guide's
>>
File: mussolini.gif (2MB, 297x229px) Image search: [Google]
mussolini.gif
2MB, 297x229px
One tab to rule them all, one tab to find them,
One tab to bring them all and in the darkness bind them.
>>
tab bound to 4 spaces
>>
tabs automatically converted to spaces
Thread posts: 129
Thread images: 7


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.