Well?

Well?

Other urls found in this thread:

google.github.io/styleguide/cppguide.html#Spaces_vs._Tabs
aturon.github.io/style/whitespace.html
python.org/dev/peps/pep-0008/#tabs-or-spaces
youtube.com/watch?v=p-cLQFj4Jb8
twitter.com/NSFWRedditGif

Nobody uses spaces. That's an old wives tale.

Tabs to indent, spaces to align

Tabs are a degenerate form of indentation.

I like lining stuff up precisely how I like it.

/thread

Nobody uses spaces. Anyone who says they do are just trolling.

tabs make more more sense

also Vim > Emacs

Both, preferably in the same line.

I use tabs and have the editor convert them to spaces.

> I am an autism and will continue to live in my foolish fantasies of perfectly aligned objects everywhere.

> Even my nuts need to be perfect aligned when I am making sweet love to my summer lesson waifu.

if modifying an existing project, follow that projects standards

if starting a new project, spaces and 8 width indentation with enforced 80 line width max

there's a case to be made for tabs for indentation with spaces for alignment but that seems to work better in config files than in source code

Tabs converted to spaces for compatibility.

>not setting tabs = 4 spaces
What are you all doing with your lives

Had u guys ever learned in school like collage or university about should use TAB key in programing by teacher?

One tab character that's 4 spaces long.

I find that spaces get annoying quickly, because you have 4 characters instead of one.

I know some people say to use two spaces, but I find that it makes code hard to read for me.

Had u ever learned in school like primary or elementary about speak English good?

Tabs to indent and spaces to align is objectively the best choice, but if you are working on any sort of project then you should just use spaces because someone is going to inevitably fuck it up and you are going to have fucked up spacing throughout your entire file.

You realize that is what everyone who uses spaces does, right? No one is actually mashing the space bar 2 - 8 times for each line.

I feel like many people who answer spaces in these threads are just too stupid to know how tabs work.

>I know some people say to use two spaces, but I find that it makes code hard to read for me.
This is why you use tabs for indentation. Because you have the 2 spaces autists, the 4 spaces autists, even faggots who will only accept 8 spaces. And everyone can work on the same project without triggering anyone's autistic fits, because each individual can set the tab length in their editor just the way they like.

is the only correct answer.

This is the best option but it's too easy for other people to fuck it up

>Not having your editor to insert 4 spaces when you press TAB
>Not having your editor to delete 4 spaces when you press backspace on a whitespace
>Not having your editor to auto-indent your code on opening new line and clearing up trailing spaces on every save
There is literally no reason to use tabs, and there is a huge reason not to use it - its width varies, making consistent formatting impossible.

read
The reason to use tabs is that their length can be adjusted.
It never varies inside a document.

...

>and there is a huge reason not to use it - its width varies
That's the entire reason to use them. People can use whatever tab stop they prefer.

This is the one true way.

> The reason to use tabs is that their length can be adjusted.
Yeah, but how is that a good thing? When I edit code in some vanilla vim over ssh it default to insane 8-spaces tabs making code unreadable, same thing with 2-space tabs, the code becomes too dense. With spaces the code will look the same everywhere, and it will be the way I wrote it.

The problem becomes even worse when people use "Tabs to indent, spaces to align", since the alignment they insert works only with the tab width they use, making code extremely ugly with tab width adjusted. This is basically the reason why people use PDF and not HTML for documents where formatting matters.

I can't figure out how many indentation when using spaces.
So, tabs.

>The problem becomes even worse when people use "Tabs to indent, spaces to align", since the alignment they insert works only with the tab width they use, making code extremely ugly with tab width adjusted.
What the fuck are you talking about? "Tabs to indent, spaces to align" means you indent like this:
def function(param1,
.............param2,
.............param3)
--->statement1
--->statement2
--->statement3
--->statement4
so the alignment of the parameters looks identical regardless of your tabstops.

A smart programmer wouldnt use either.

You're completely wrong. Tabs to indent, spaces to align fixes the very problem you outlined.

consider the following:
tab width 4:
{
--->some code
--->.....some aligned code;
}

now the same with tab width 2:
{
->some code
->.....some aligned text;
}
still perfectly aligned.

it doesn't matter as long as you always use one or the other the same way every time

>When I edit code in some vanilla vim over ssh it default to insane 8-spaces tabs

That sounds like a problem with wim, not with tabs.

what happens if you exceed your line width with spaces?

Ok, you're right, it works fine if you're using spaces for the whole indent and not for just the last part, like in
def function(param1,
----------->.param2,
----------->.param3)

Still, this approach is burdensome and without any significant payoff, the whole need to adjust tab width is a meme one, it's much easier to have indent widths fixed by your coding style, see google.github.io/styleguide/cppguide.html#Spaces_vs._Tabs , aturon.github.io/style/whitespace.html or python.org/dev/peps/pep-0008/#tabs-or-spaces for example.
Moreover,
>Python 3 disallows mixing the use of tabs and spaces for indentation.

Most projects just use spaces because people are too retarded to understand how to use tabs properly.

Fuck I've been doing it wrong this whole time. Those really indented lines were always a bitch for me.

Tabs are for indentation; only mentally retarded "people" would use spaces.

Can someone explain to me the arguments for both sides? Isn't it something to do with compatability across OSs?

>I'm to smart too use spaces-only indent
Gee, m8.
>Most projects just use spaces because people are too retarded to understand how to use tabs properly.
And they don't lose anything by doing that while having their code to display properly regardless of the editor they're using.

>And they don't lose anything by doing that
They do. They lose the ability for every programmer working on the project to set the tab width to their liking.
If you use tabs and spaces properly the code will line up perfectly no matter the tab width.

>Tabs
+ Everyone can use their preferred indent size
- Using tabs for alignment only works using a specific tab size

>Spaces
+ Code will look the same everywhere
- Restricted to a single indent size

In some languages (e.g. Haskell or other functional programming languages) indentation is not regular like it is in Java or C. In such cases spaces are objectively better than tabs. In java or C it doesn't really matter.

If you mix tabs and spaces however, you are retarded.

>Tabs for indendation spaces for alignment
+ Everyone can use their preferred indent size
+ Code will look the same everywhere (- tab width)
- people WILL fuck it up

>- people WILL fuck it up
That should have three minus signs.

0009
00200020002000200020002000200020
Which is less?

what?

I prefer spaces because occasionally I will want to align something that won't line up with my tabs, and i don't want the readability to be affected if someone uses a different tabstop length.

I've had different professors have different opinions, along with different standards . We had a university-wide coding standards document which said it doesn't matter, but 4 spaces is required for indentation if you don't use tab.

True, everyone should use inline comments to align their code
if (!waifu.isClaimed()) {
/**/waifu.claim(me);
}
else {
/**/ //fucking waifu thieves
Husbando[] hsubandos = waifu.getHusbandos();
/**/for(int i = 0; i< husbandos.length(); i++) {
/******/ // nothing personell, kid
/******/kill husbandso[i];
/**/}
}

>Be me.
>Taking god awful, closed room, practical test for cs course.
>We have to boot into specially prepared ubuntu user environment with nothing but the java api(kill me) and a submission portal.
>Start vim.
>Ask tutor if I can import my vimrc from my home file on the system.
>No user, this is a closed practical.
>Blind panic.
>Can't remember how to vim.
>Start writing stupid assignment anyway(~less than 50 lines of bulshit)
>comment return return name return date return class assignment{
>Return
>tap tap tap tap on the spacebar.
>tutor behind me snickers.
>public static void main(String[] args){
>tap tap tap tap... tap tap tap tap
>Only cute girl in class is sitting next to me.
>I don't know how that happened.
>Can feel her gaze upon me as if I were an idiot.
>Private int someVariable;
>Return.
>tap tap tap tap.... tap tap tap tap.
>Professor comes to ask if I'm OK.
>Y-yes I-I'm alright, t-thank you.
>Lab is dead quiet now.
>~100 people listening to the sound of my spaghetti falling onto the keyboard.
>professor stands behind me.
>Fuck.
>private String bulshitString; return
>tap tap tap tap... tap tap tap tap.
>Everyone aware of my rapidly manifesting autism.
>I wish there was a dinosaur.

Does anyone have that ms source code where it says "the code will not compile if tabs are changed to spaces"?

just tabs

I will retab anything that I come across
idgaf

That sounds like a problem with the person that doesn't know how to properly use their own vimrc over ssh

/*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!!!!IF YOU CHANGE TABS TO SPACES, YOU WILL BE KILLED!!!!!!!
* !!!!!!!!!!!!!!DOING SO FUCKS THE BUILD PROCESS!!!!!!!!!!!!!!!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/

why would you not use tabs and just set your own tab width in your editor like a reasonable person

Tabs.
>but I like to have small indents
Then set your tab width to a single space.

it's like one is a woman the other a man and this fucking faggot choose to become a tranny

space is for faggots....
wtf this thread anyway

hot dogs

I used spaces before, but now I use mostly tabs

youtube.com/watch?v=p-cLQFj4Jb8

I've never understood this meme of tabs vs spaces. Tabs afaik are the standard, and I've never ever seen a valid reason to use spaces.
If anything, after reading the linux style guide, I am more inclined than ever for tabs, 8-char tabs at that.
I do understand that some people like 4-char tabs and even 2-char tabs, that's personal preference, but what good do spaces do against tabs?
Sure, most editors such as vim can be set to use spaces when one hits tabs, and unindent automatically some times, so... there's still no difference whatsoever, it's just the same as if you were using tabs.
In my case I use vi, which doesn't autounindent, and spaces makes me have to hit backspace too many times when unindenting.

It literally doesn't matter at all since every text editor and IDE worth it's salt is capable of completely reformatting to whichever you prefer. Everyone wins. Everyone gets to use whatever they want.

In all seriousness though, there is at least one advantage and disadvantagae to each method.

Tabs advantage: less characters saved in document (big fucking deal, you saved a few bytes)
Tabs disadvantage: Alligned end of line comments will become misalligned if your code is ever viewed in an editor with a different tab size configured than you. This can be an annoyance when checking out another person's code since it requires you to guess what tab size the developer was using in order to get their end of line comments to allign properly. However, many IDEs and text editors can fix this problem simply by reformatting the entire document.

Spaces advantage: Alligned end of line comments remain alligned regardless of editor settings.
Spaces disadvantage: More characters saved in document.

>people would rather hit space 4 times than tab once

time to find a new career

>Alligned end of line comments will become misalligned if your code is ever viewed in an editor with a different tab size configured than you.
Tabs are only for indentation. You still should use spaces for aligning.

If your coworker uses 4 char tab and you use 8, the code will frequently be over your line length limit but not theirs.

If you use 4, any tool that writes the file to the terminal will show it differently because the terminal shows it as 8.

If you use GCC, errors are shown with columns that assume a tab size of 1. With javac, 8. You and your tools and integrations have to know about this.

If you use a column sensitive language like Haskell, code will look wrong but work or look right but fail if you don't account for tab length.

All these issues go away if you use spaces.

Sup Forums would shit themselves if someone wrote code in MS Word and formatted it with tables, but somehow tabs are still ok

>If your coworker uses 4 char tab and you use 8, the code will frequently be over your line length limit but not theirs.
Maybe this can be a bit of an issue.
>If you use 4, any tool that writes the file to the terminal will show it differently because the terminal shows it as 8.
what does it matter?
>If you use GCC, errors are shown with columns that assume a tab size of 1. With javac, 8. You and your tools and integrations have to know about this.
what does it matter? if gcc shows errors with 1-char tab it doesn't suddenly make it unreadable. They just give you the line number and the detected error
>If you use a column sensitive language like Haskell, code will look wrong but work or look right but fail if you don't account for tab length.
Yeah, that's a bit annoying about Haskell, but then you use spaces for haskell, just like you'd never use tabs for lisp indenting lest you want your code look like a landslide.
>All these issues go away if you use spaces.
s/issues/non-issues/

still no argument.

There is a special ring in hell for people who mix tabs and spaces. If you used spaces then you wouldn't need to bother fixing the alignment issues caused by tabs.

Mixing tabs and spaces is evil and amateur.

It depends on your fucking language are you retarded?
I mean if I had to invent a new language I would choose tabs but you just have to follow the standard conventions.

is this b8? you cannot possibly be so ignorant

you've never had a job as a progammer i guess ?
you use whatever the fuck you like and reformat it to the project standard before you push it.

Different editors interpret the "tab" character (i.e the actual byte, not the button) differently, but they all interpret spaces the same. Some don't even use the character, opting to use spaces by default.

So while tabs might have been nice to allow different people to view the code according to their preferences, it's more important that the code be consistent. Spaces ensure consistency, tabs do not.

You know what I really want?
Being able to set up your editor to use different a different configuration of tabs and spaces depending on the file extension.

>what is vim

It should be based on the existing format of the file so that you never mix tabs and spaces

why ?
you tell your editor to reformat it to whatever the fuck you want to use, and before you push it you just let whatever tool + config your project uses for formating reformat it

>Tabs to indent, spaces to align

Obviously this is correct, but the problem is that if you have a large team of software engineers, about half of them are not really going to care about this issue.

If you tell them "I care about this issue, and you should care about it too", they will earnestly listen to you and nod their head in agreement, and then they will promptly forget about it. And there is nothing you can do about that fact, because there's too many of them to get management to crack down on so many developers about such a minor issue.

After enough years go by, you eventually realize that people are just gonna do what they're gonna do. You're always going to see differences in spacing style, and you just learn to live with it.

Those steps are completely unnecessary if you just use the existing convention. Why the fuck are people so autistic about this that they will literally waste time to make it "their way"