[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]

Well?

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: 73
Thread images: 2

File: tabs-vs-spaces.jpg (126KB, 1440x679px) Image search: [Google]
tabs-vs-spaces.jpg
126KB, 1440x679px
Well?
>>
>>58238995
Nobody uses spaces. That's an old wives tale.
>>
>>58238995
Tabs to indent, spaces to align
>>
>>58238995

Tabs are a degenerate form of indentation.

I like lining stuff up precisely how I like it.
>>
>>58239008
/thread
>>
>>58238995
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.
>>
>>58238995
I use tabs and have the editor convert them to spaces.
>>
>>58239024
> 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
>>
>>58238995
Tabs converted to spaces for compatibility.
>>
>>58238995
>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.
>>
>>58239082
Had u ever learned in school like primary or elementary about speak English good?
>>
>>58239008
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.

>>58239041
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.
>>
>>58239024
I feel like many people who answer spaces in these threads are just too stupid to know how tabs work.

>>58239102
>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.

>>58239008 is the only correct answer.
>>
>>58239008
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.
>>
>>58239228
read
>>58239172
The reason to use tabs is that their length can be adjusted.
It never varies inside a document.
>>
File: 1447978192591.png (74KB, 717x325px) Image search: [Google]
1447978192591.png
74KB, 717x325px
>>
>>58239228
>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.
>>
>>58239008
This is the one true way.
>>
>>58239238
>>58239276
> 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.
>>
>>58239296
>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.
>>
>>58239296
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.
>>
>>58238995
it doesn't matter as long as you always use one or the other the same way every time

>>58239296
>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.
>>
>>58239045
what happens if you exceed your line width with spaces?
>>
>>58239325
>>58239343
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 https://google.github.io/styleguide/cppguide.html#Spaces_vs._Tabs , https://aturon.github.io/style/whitespace.html or https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces for example.
Moreover,
>Python 3 disallows mixing the use of tabs and spaces for indentation.
>>
>>58239523
Most projects just use spaces because people are too retarded to understand how to use tabs properly.
>>
>>58239168
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?
>>
>>58239528
>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.
>>
>>58239556
>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.
>>
>>58239551
>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
>>
>>58239044
>>58239172

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.
>>
>>58239575
>>58239551
>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
>>
>>58239610
>- people WILL fuck it up
That should have three minus signs.
>>
>>58239551
0009
00200020002000200020002000200020
Which is less?
>>
>>58239671
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.

>>58239082
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.

>>58239338
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];
/**/}
}
>>
>>58239168
>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 anon, 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"?
>>
>>58238995
just tabs

I will retab anything that I come across
idgaf
>>
>>58239367
That sounds like a problem with the person that doesn't know how to properly use their own vimrc over ssh
>>
>>58239980

/*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!!!!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.
>>
>>58239008
it's like one is a woman the other a man and this fucking faggot choose to become a tranny
>>
>>58238995
space is for faggots....
wtf this thread anyway
>>
hot dogs
>>
I used spaces before, but now I use mostly tabs
>>
https://www.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.
>>
>>58238995
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.
>>
>>58238995

>people would rather hit space 4 times than tab once

time to find a new career
>>
>>58242583
>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.
>>
>>58242276
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.

/g/ would shit themselves if someone wrote code in MS Word and formatted it with tables, but somehow tabs are still ok
>>
>>58242902
>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.
>>
>>58242769
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.
>>
>>58238995
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.
>>
>>58242600
is this b8? you cannot possibly be so ignorant
>>
>>58238995
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.
>>
>>58243283
>what is vim
>>
>>58243283
It should be based on the existing format of the file so that you never mix tabs and spaces
>>
>>58243565
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
>>
>>58239008
>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.
>>
>>58243606
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"
Thread posts: 73
Thread images: 2


[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.