[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Is this accurate?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 90
Thread images: 9
File: tabs-vs-spaces.png (1 MB, 1266x875) Image search: [Google]
tabs-vs-spaces.png
1 MB, 1266x875
Is this accurate?
>>
Yes. Tabs are only acceptable if you're working alone, and bad practice then.
>>
Yes. Best solution is setting your editor to replace tabs with spaces.
>>
File: attachment.jpg (50 KB, 625x626) Image search: [Google]
attachment.jpg
50 KB, 625x626
>>55003877
>>55003900
>>55003951
>>
>>55003877
yes, space is always a space

the proper solution is that your language provides you a code formatting tool so this like this doesn't need to happen
>>
>>55003877
how do they "preclude using spaces at all for formatting"?

How is "how the developers intended it to look" relevant? It's code, not a fine art fuckin painting.

Tabs for block indentation, spaces for alignment. It's literally that simple.
>>
Just rig all keyboards to map the tab button to the spacebar. Problem solved.
>>
>>55004044

Consider the cases where you have a line that is indented using both tabs AND spaces. Tabs are designed to help text stay formatted, but your code editor has a hard time reading your intentions when you blend the two. It may display all whitespace characters normally, it may fail to display spaces that are in between two tabs, or it may do something totally different. The only thing you can really guarantee is that no two code editors will handle tabs the same way.

The best advice was already given: set your editor to replace tabs with spaces. That will guarantee your code looks the same on all machines.

>How is "how the developers intended it to look" relevant? It's code, not a fine art fuckin painting.

Yeah, try using that logic the next time you open a pull request. Nothing will make you look like a retarded child more than not knowing how to properly indent your code.
>>
>>55003877
Part of it is.
Spaces ensure the code looks identical on all computers. But most languages isn't repetitive enough to demand that you manually align something.
I like to have huge indentations (8 spaces). While I would like other people to agree with me, certain situations doesn't demand this huge a margin, one example would be if the code is imported into a report or into doxygen.
If you work with animals (people who doesn't follow the coding standard) then stop working with those people.
>>
>>55004226
For a good coder it is fuckign shit piss easy to make editor replace tabs with spaces.

But for actually writing code tabs are way more efficient, like richard said its like taking 6 steps at a time.
>>
>>55003877
immaturity as a programmer is getting this butthurt over what whitespace style a fictional character uses.
also
>tabs for indentation, spaces for alignment
>>
>>55004323
Why would you want 8 space indents?!
>>
>>55004226
> it may fail to display spaces that are in between two tabs

So... don't fuckin do that?

Under the "tabs for block indentation, spaces for alignment" rule I already mentioned, tabs only belong at the beginning of the line, before all spaces and all other characters.

You should not have tabs in the middle of a line. You should not have different numbers of tabs on two lines that have things that are supposed to be lined up (like, if you have "tab tab foobar(..." the next line needs to be "tab tab seven spaces" if you want the stuff on the line to line up with the parentheses from the first line, not "tab tab tab three spaces" like a retard).

None of that means you shouldn't use tabs for block indentation levels.
>>
>>55004359
For *block* indentation. Too many people think "indentation" includes hanging indents that are supposed to line up with shit on the previous line, but that should be spaces from the point that the previous line had printable text.
>>
>>55003877
>imdb
Since when are we taking programming advice from fucking imdb.com?
>>
>>55004226
>your code editor has a hard time reading your intentions when you blend the two.
No it doesn't.
>it may fail to display spaces that are in between two tabs
Nobody does that. And if it did, it would be extremely rare and fixed just like a spelling error.
You are aware that you can set almost any editor to show tab characters right?
This is not a problem.

If the rest of the project is using spaces, then you obviously shouldn't use tabs.
Follow the standard.
>>
>>55004420
It has nothing to do with programming. We are talking about what coding standards should contain regarding indentations.
>>
>>55003877
Isn't a tab just four spaces though?
>>
>>55004443
Which is still not something to take advice on from imdb.com, so the distinction while true is irrelevant.
>>
>>55004454
Not on every editor
>>
>>55004454
No, it's a user-configurable amount of spaces. Which is why it's used for indentation amounts that should scale with user preferences, i.e. block indents.
>>
>>55004443
yeah but you need to question the validity of the argument based on its source as well.
>>
>>55004466
nor on every installation of that editor, or for every language that editor is used on. Some people prefer 2-character indents, some 3, some 4, and some 8. Fortran is particularly odd and treats columns 1, 6, 7, .and 74 specially, so some people have their editors set up so that the first 3 tabs take you to columns 1, 6, and 7, and subsequent tabs take you in a further N columns (N=2,3,4,8 columns).

Use spaces. Always. Tabs are simply asking for aggravation.
>>
>>55003877
it shouldn't matter.

If you're working alone on a solo project, there is literally no difference.

If you are working in a group, your group should already be using editors that don't care. Just like variations in line breaks. Use whatever you want in editor, save to whatever is standard, never think about it, editor does all the work.

The fact that HBO and now /g/ are arguing about this highlights their immaturity as programmers
>>
>>55003877

Most large companies have a default xml formatter for their IDE's which would be available from their internal documentation system such as confluence.

This is to maintain code conventions and to prevent people using different formatters. When people use different formatters their IDE will update any pulled code so their commits would just be huge wads of reformatting going back and forth.
>>
>>55003877
No, it's absolutely a don't care, not even worth discussing. Your code is probably never going to be more than an include statement in someone else's code if you are working in a large company. So how it looks does not matter very much, no one's going to look at it as deep as you would and they're going to complain about how you write in any case. Just do whatever you like as long as it has some consistency.
>>
>>55004561
>If you are working in a group, your group should already be using editors that don't care.
It would be, were it not for the fact that there is no such thing. Nor will there ever be, because some indentation schemes contain strictly more information than others.
>>
I feel like people don't actually understand the tabs for indent, spaces for alignment principle.
>>
Unless a project has a preferred style of indentation that everyone already agrees on, I use smart tabbing. Tabs for indentation, spaces for alignment. Everything that is intended to be aligned will always be aligned regardless of the tab width. How deeply the code is indented is not something that needs to be agreed upon by anyone, because it is a matter of preference and does not affect alignment.
>>
>>55004561

Your solo project should still conform to the company code conventions which will include a default formatter.

You're right about groups though.
>>
File: serveimage.jpg (16 KB, 600x600) Image search: [Google]
serveimage.jpg
16 KB, 600x600
>>55004595
>there is no such thing. Nor will there ever be
>>
>>55004662
I am entirely serious. It is an impossibility, because the information simply isn't there.
>>
>>55004679
>I am entirely serious. It is an impossibility, because the information simply isn't there.

Then how does every modern editor, including the free ones, do it by default?

I can understand that *you're* retarded but lots of other people write software anon, they can accomplish all kinds of things with those brains!
>>
>>55004632
You don't understand their autism

If your code didn't wrap at 80 columns when you wrote it, but wraps at 80 columns for a nerdy UNIX historian using the original vi on a VT100 (as in, goes off the fucking screen), they sperg out hardcore and nearly kill themselves because they were just reminded that the world is better now that we have editors with adjustable tabstops and even, wait for it, smart line wrapping. BLOOOOOOOOOOOOAAAAAAAAAAAT!
>>
>>55004692
You're talking about two different things. You said "Editors that don't care [about tabs]" and he thought you meant "Editors that don't care [about literally anything in a coding style]"
>>
>>55004692
They don't.

There are indentation styles that make use of the distinction between tabs en spaces. Any editor that doesn't care about the difference will necessarily fuck up that indentation.
>>
>>55004699
If it were that then they wouldn't lie about shit like "no two code editors will handle tabs the same way."
>>
>>55004717
Who the fuck mixes tabs and spaces in a way that fucks up

>emacs autoindent users, that's who
>>
>>55004727
It's not a lie. The original vi had no tab handling. All terminals have 8 space tabs, so the original vi always had 8 space tabs.

Basically, the anti-tab council works in the interest of retarded autistic luddites.
>>
>>55004699

The company where I work has the 80 character limit to make the code readable on github.
>>
>>55004734
All sensible programmers do. It's the style described in >>55004632 >>55004642 >>55004400 >>55004381.

In this style, if you are using a tabsize of 4, there is a semantic difference between "two tabs followed by three spaces" and "one tab followed by seven spaces". Any editor that doesn't care about that difference can therefore not handle this indentation scheme correctly.
>>
>>55004766
But that doesn't fuck up? Indentation and alignment are preserved as long as you don't use tabs for alignment.

All that changes is how soon the line wraps.
>>
>>55004806
It certainly breaks if your editor flattens away the difference between spaces and tabs, as >>55004561 suggested. Which is why editors don't actually do that, which was my point.
>>
File: good day.jpg (70 KB, 768x600) Image search: [Google]
good day.jpg
70 KB, 768x600
>>55004746
https://docs.freebsd.org/44doc/usd/10.exref/paper.pdf

> tabstop, ts default: ts=8
> The editor expands tabs in the input file to be on tabstop boundaries for the purposes of display.
>>
>>55004853
>tfw you never knew it had this because man pages are a horrible format for documentation
>>
>>55004878
Well this wasn't actually a manpage, it was a full document (using MS rather than MAN macros), you were supposed to read it cover to cover on paper before starting using the program.
>>
>>55004894
You know, it was probably in the man page.
>>
>be veteran at company
>new dev gets hired
>he's a linuxfag
>goes on about how everyone should double space instead of tabbing
>start laughing
>he won't shut up
>keep laughing for six months
>laughed out of company
What a fucking faggot jesus fucking christ tens of thousands of lines need to be changed for our little snowflake.
>>
>>55004910
You know, if people would read the manpage cover to cover on paper before using a program (and all of section 2 and 3 before programming in C) they'd probably be alright.

It's really not the original UNIX developers' fault that modern people have such short fuckin attention spans.
>>
>>55003877
>using spaces for indentation
>ever

Fuck this shit
>Work on someone else's code
>4 spaces to indent
>want to refactor
>need to make a line less indented
>press backspace 4 times
>every time
>EVERY
>FUCKING
>TIME
nah fuck that shit. Life's too short to waste mashing buttons to do the job another key was designed to remove.

now it's
>get code that have to work on
>use sane code formatter to get a quality output
>no more space indentation
>no more '} else {' nonsense
Fuck everything else. I don't care if my commit says the entire file changed
>>
>>55003877
Why should I give a shit how the developer wanted it to look? If I can customize my syntax highlighting and other formatting I want to customize the size of indenting too. As mentioned above, using tabs for indenting and spaces for alignment is the superior way to keep things both customizable and in place.
>>
>>55005034
This. Immature programmers are the special snowflakes who feel that, if their code looks a certain way to them, everyone else must look at that code the same way, rather than the way they would prefer.
>>
>>55004031
because you think a tab suddenly stops being a tab?
Using tabs = using a dedicated character for indentation + allow the dev to setup his editor to display them as 8 spaces or 4 or 2 if he/she wants
>>
>>55005010
>press backspace 4 times
this. Its painful,
>>
I always do 1 tab followed by 2 spaces.
>>
> spaces for indentation
Oh boy I love pressing the arrow keys four timer per indentation.

If you're not using tabs you're fucking autistic
>>
>>55005273
>he indents manually
haha oh wow
>>
>>55005286
I meant as in moving through code. Like, starting at the beginning of a line and arrowing through it.
>>
>>55003877
what's with the finger on chin thing now?
>>
Literally every Professor I've met uses tabs.
>>
I agree that tabs are pointless and dumb, but then again it doesn't really matter.
>>
File: CMtl17nWIAA9h6z.jpg (51 KB, 600x450) Image search: [Google]
CMtl17nWIAA9h6z.jpg
51 KB, 600x450
>>55003877
Just code however you want and use your editor or IDE to transform it to spaces or tabs depending on what your employer wants.

/thread
>>
Tabs for indentation, spaces for formatting.

>>55005338
It's a joke playing on motive of the cover of the Jobs biography.
>>
>>55004331
so set your editor to replace tabs with 6 spaces you fucking retard

the point is, when someone will need to change your code in some way, tabs can make it look like shit on his editor and spaces won't

literate programming bitch
>>
>>55003877
What really triggered me with that episode is that the chick used space to indent... I mean, who in their right fucking mind doesn't
1) auto-indent
2) press tab ONCE to get to the right indentation level
>>
>>55005753
I do. I like the tactile feel of space space space space
>>
File: RF007.png (305 KB, 600x600) Image search: [Google]
RF007.png
305 KB, 600x600
It depends, are you working with a cancer language where white space matters?
>>
People keep talking about how spaces will look the same for everyone. But that's a bad thing. What if a developer set his tabs to size 8 spaces and you instead place 4 spaces in his code with your editor. If he sees his new code, it'll look messy, because now there's 8 space sized tabs AND 4 spaces. Now if you'd use tabs, then the size of the tabs would be 8 spaces on his computer and 4 spaces on yours.
>>
>>55003877
Yes, spaces only.
>>
Unless you're doing some ascii-art bullshit, there's literally no reason to use spaces

>just werks
>everyone can see it the way they want
>can't fuck it up too much
>smaller files
>meant for indenting
>>
>>55003951
This. The whole argument is pointless because literally all programmers do this.
>>
Wow, a tabs vs space shitposting thread. Haven't had one of these arguments since college.
>>
>>55006762
That's why I only use languages that are case-insensitive so that everyone can type identifiers the way they like it best.
>>
>>55005010
>>press backspace 4 times
>I'm too retarded to set up my text editor correctly
>>
>>55007957
What about partially case sensitive languages like PHP?
>>
>>55007996
I don't know. But I forgot to say that I only use languages that ignore _. This way people can write either

my_func, or
myfunc, or
myFunc, or
MyFunc

and it all means the same. It's great when you work in large groups.
>>
Can we all agree that people who indent like this are the worst, though?

> Four spaces
> Tab
> Tab and four spaces
> Two Tabs
>>
>>55008013
what languages?
>>
>>55008046
nim
>>
>not indenting with 2 U+2008
Plebs.
>>
>>55007898
>using literally for emphasis
neck yourself
>>
>>55008027
you mean like all of them at the same time or what? How else would u indent?
>>
If the language is block based and it is not idiomatic to align certain elements like the Python morons do with anything that involves parenthesis and a newline then I see no reason not to use tabs.

Go is a good example.

Otherwise simply use spaces.
>>
>ctrl k + d
only RealProgrammers™ will get this :^)
>>
ITT: autists sperg out over their code not having the same amount of whitespace when viewed on someone else's machine

Why should I have to be subjected to your mental disorder just because I opened your code? Does the reader not get a preference?
>>
>>55003877
>tabs have unpredictable output
What the fuck kind of retard wrote this shit? Unless you're using a fucking non-monospace font (go fucking kill yourself if you're programming without monospace) tabs always have a predictable behavior. If you start fucking with the tab spacing then you run into issues, but fuck you can dick around with spacing on space if you're that fucking retarded.
>>
>B-b-but it doesn't look the same on every machine!
If it were possible, these people would be hard coding the syntax highlighting into their application, because god forbid you get to choose it yourself.
>>
>>55006022
nice multiplies of eleven m8.

also to the thread, season 3 is trash, only the last esp. was ok, but so muxh filler wew.
>>
File: m2.jpg (133 KB, 610x665) Image search: [Google]
m2.jpg
133 KB, 610x665
>>55008118
Neck'bearded. *Tips fedora
>>
>>55003877
>>55003951

This. Like three lines in my .vimrc file change other peoples tabs to space and let me just hit tab to make 4 spaces.
Thread replies: 90
Thread images: 9

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.