Tabs vs Spaces

what do you use?

what SHOULD you use?

Other urls found in this thread:

suckless.org/coding_style
stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/
twitter.com/SFWRedditVideos

Tabs

Spaces is more aesthetic, particularly 2 or 4
Best way is to have your editor write tabs as literal spaces

I don't indent my code, I write everything on the same line.

There is no universal standard for tabs across the globe. Therefore spaces should be used.

What is even the argument for spaces? It's more keypresses,, therefore worse

autism

Tabs for indentation, spaces for alignment. That said, people who actually take time to align their code are faggots and therefore, tabs are the only good option.

fpbp

>2 spaces
t. JavaScript

just have your editor display tabs as 2 or 4 spaces long. get the aesthetic with only 1 key press.

Really? I thought they were entirely standardized as "move to the next multiple of N characters, where N is some configurable number based on personal preferences". Am I missing something here?

I use both

silicon valley memes aside, this is a thing where the general practice should be established a long time ago, whether it's tabs or spaces
personally, I'm for tabs

but with tabs you can set the tabs to be displayed as many spaces as you like, so you will have your preferred 2 spaces when your college would see his 4 while working on the same code

>There is no universal standard for tabs across the globe
which is a good thing, because of and

All of this.
>t. a faggot who aligns his code

General practices get established when people fairly universally agree that a particular approach is superior. This topic is clearly not one of those cases.

Tab characters are broken and misguided and should never have been part of ASCII. And "tab"ulation characters shouldn't be used for indentation in any case.

tabs automatically converted to 2 spaces

Your editor would automatically insert either, so that is not it.
The problem with tabs is some people don't understand how to use them.
There are faggots around who don't have visible whitespace in their editor and then the tabs becomes indistinguishable from spaces.
Say you have something like this:
void someFunc(int with,
int many,
int long,
int input,
int names)
{
if( with ) {
many = long + input;
}
return names;
}

The indentation of the input arguments must be spaces.
If you use tabs, you should have a tab (if the function is indented) then a lot of spaces to create the indention.

>Tab characters are broken and misguided and should never have been part of ASCII
elaborate

>not using addon that formats your fucking code in one click

Well they are broken in that you need a varying number of tab characters between columns depending on the number of characters in individual cells in a table, which makes tab characters unsuitable for tabulating data unless you assume a fixed tabstop width.
Typewriters had a tab key, but all that did is advanced the cursor to a certain point. There's no reason that shouldn't be implemented in text editors as multiple spaces instead of tab characters.
Tab characters are also not good for indentation in all cases, for example indentation relative to alignment before it, e.g.
foo_bar(asdf,
[](int x) {
return x + 1;
});

This is a very common style in LISP and Erlang.

are there really niggers out that press the spacebar multiple times when you can just press tab once?

I do. My tab key is for switching to Sup Forums when my boss is not looking at me.

Consider the following
if (very_long_expression &&
other_very_long_expression)
// code

If you used tabs, editors that don't have your tab to space ratio would have the second line not in line with the expression

>Well they are broken in that you need a varying number of tab characters between columns depending on the number of characters in individual cells in a table, which makes tab characters unsuitable for tabulating data unless you assume a fixed tabstop width.
That only happens if your table is tabulated in a wrong way.
If it was tabulated correctly (e.g. each column started at a tabstop) it would work as you described.

Tabs are way more comfy.

Tabs are the proper way, however spaces are more retard friendly.

That's why you use tabs for indentation and spaces for alignment. You use tab up to the start of the if, then spaces to align the next line of the if condition.

That way the alignment will persist regardless of the tab size, and users can still configure tab size however they want.

I feel there is some misconception about how tab works, so I'll clarify:
Tab doesn't move your cursor N characters. It's not the same as typing N spaces. It could be, but that's not really a tabulation.
Tabs work like this:
You define a tabstop value, eg. 4.
Then, every line gets divided into 4 characters long tabstops.
Then, by using a tab, you shift your cursor to the beginning of the next tab stop.
So the number of spaces you move is between 4 (if you're at the beginning of the previous tabstop) and 1 (if you're 1 character before the next tab stop), depending on how far is the next tab stop from the current cursor position.

eg.
1234123412341234 //previous line, just for demonstration purposes
sometext //current line

if your cursor is under "1", it will go to the position under the next "1" by pressing tab
if your cursor is under "2", it will go to the position under the next "1" by pressing tab
if your cursor is under "3", it will go to the position under the next "1" by pressing tab
if your cursor is under "4", it will go to the position under the next "1" by pressing tab

>being forced to use spaces in order to use tabs
This is why you get paid less

Vim and practically all editors have the ability for you to program what the tab key should do.

I only use tabs though, no need to use extra bytes for nothing.

The tab key inserting 4 spaces

>forced
Trying to do alignment with tabs is retarded. Trying to do indentation with spaces is retarded (though admittedly less retarded than doing everything with tabs, since it is at least consistent).

Tabs for indentation, spaces for alignment is perfect. The tab key produces a single tab character, always, regardless of what language I'm using. The space key produces a single space character, always, regardless of what language I'm using. In any platform I can easily view any of my files with whatever indentation size I want, while maintaining alignment (something you can't do with just spaces or just tabs). If the editor doesn't support configuring tab size, I can always find and replace each tab character with some number of spaces to get whatever indentation size I want.

It's the only correct approach.

What do you mean?
foo>----bar>----asdf
asdfg>--asdfg>--asdf
asdfghjkl>------asdfg>--asdf

Notice how the first cell of the last line, being too long, overflows into the next column and brings everything out of alignment. You would have to fix it like this
foo>---->-------bar>----asdf
asdfg>-->-------asdfg>--asdf
asdfghjkl>------asdfg>--asdf

But this is kind of messy since you have an arbitrary variable number of tab characters between each column. And on top of that, everything will look messed up if you use a different sized tabstop, such as 4 or 2 and the number of tab characters between each cell needs changing for that.

Tabs for indentation
Spaces for formatting and alignment

1) why would you switch ide’s
2) why wouldn’t the ide allow you to configure that

Tabs are the objectively superior choice.
However, 5 seconds in a programming job, reading legacy code, or 5 seconds spent talking to the average developer will make you just switch to spaces and forget about it.
These fucking chucklefucks can't even be trusted to use git properly or not fuck up files with mixed line endings and whitespace everywhere, how on earth could they be trusted to fully understand the concept behind tabbed editing and configuring their editor to render and insert tabs properly.
So I instantly switched to spaces and forget all about it

I find that the tabs-versus-spaces debate really tends to be a proxy for differences as to how people try to cope with morons. People who use tabs tend to be the sort of people who try to do things Right and the people who can't follow that can either git gud or get the fuck out. People who use spaces tend to be the people who try to accommodate their works to be idiot-proof, and will accept suboptimal solutions in order not to confuse the normies. It's no coincidence that tabs are popular in the C and C++ worlds, while spaces are generally mandated in the python and javascript lands.

I dont use either. I use the letter f

def fuck_you do
ffIO.puts "fuck you"
end

FPBP

you don't have to use neither in machine code
machine code ftw

Lisp as well (though you usually align related forms)

>not indenting your machine code using copious NOPs
Are you even trying

but that's like spaces
what would tabs be?

>I have literally never worked in a team before: the post

>not setting your .vimrc to change tab key to 4 spaces
spaces 4 lyfe! fuck tabs

>41234 //previous line, just for demonstration purposes
>sometext //current line

indeed. Tab code is optomized, space quote is bloat

>>not setting your .vimrc to change tab key to 4 spaces
>spaces 4 lyfe! fuck tabs

I did set vimrc up that way but still using spaces is about the gayest thing known to man in code.

Just use vim and set the tabstop to 2 spaces

>not setting tabstop to 1 space so it becomes effectively a space

what if you work with YAML or Python, then you're forced to use spaces

I use a beautifier extension or whatever they're called to make the indentations correct

>2018
>not using a filesystem with transparent file compression

8 width tabs

u can use tabs w python

my tab maps to 6 spaces

Vi pls go

Spaces are disgusting.

Disgusting.

spaces because if you press spacebar or tab, it'll be consistent regardless

It's a little staggering how only one other poster has said tabs as spaces. This isn't 1989, if your text editor and/or IDE doesn't have tabs as spaces well you should probably get a plug-in(TM) for that.

spaces (inserted by pressing the tab key obviously) because pressing tab will fuck you up when trying to write some code online or in an instant message or whatever whereas spaces just werk

Tabs

Tabs to insert spaces is fine, but I still prefer tabs for indentation, spaces for alignment because of the ease of conversion and the 1:1 mapping between keys pressed and characters inserted.

I press tab and it inserts 4 spaces. The reason being that GitHub absolutely fucks up every time I use tabs. Plus if you want to align things on multiple rows, you have to use spaces anyway, so you'd end up with tabs and spaces, which is ugly. So yeah, spaces all the way. Except for Python.

suckless.org/coding_style

>Leading Whitespace
>use tabs for indentation
>use spaces for alignment

>Tabs
>Press tab to indent once
>Press shift+tab to remove a indent, can remove indents from multiple lines at once this way, can still delete in traditional backspace / end + delete ways

>Spaces
>Multiple spaces to add spaces
>Multiple backspaces or end then delete to remove spaces

>while spaces are generally mandated in the python and javascript lands.
probably more like: people who use a text editor for writing code are fine with tabs, people that edit js in a within some cms admin page don't have an easy option to insert tabs and go REEE TABS ARE BAD

A mix of tabs and spaces within every file, sometimes even on a single line.

>not using a sensible editor that lets you insert/delete multiple spaces with one keypress

It's 2018 there's no excuse

Tabs for indenting and spaces for aligning.

tabs that print 4 spaces

Then why use space at all, just press tab

why do you even use tabs?
Shit is so confusing what happens if I dont use tabs.

fpbp

the office rebel

who else /inverseindenting/ here

that's fucking disgusting

int main()
{
return 0;
}

With tabs this is 26 bytes, with spaces it is 29 bytes. Now imagine this across the entire file and how many bytes you're wasting.

But does this change in the compiled program?

int main(){return 0;}
21 byte with neither. Imagine!

No. It will increase compilation time by a millisecond or two parsing x4 the number of spaces for each tab, however.

We should add the proviso that it has to be human readable in addition to using fewer bytes.

I'm sold.

shut
fuck

you're a fucking hero, but honestly I couldn't waste the time using an editor for a single line when you can just pipe your source straight into gcc and use bash_history for file management.

There was a study conducted on this and it turns out that programmers who use spaces typically earn more.
stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/
>t. tabfag

all the devs i know use tabs. seriously who uses spaces?

Just make your editor output a tab as 4 spaces...
There's no way I'm slamming on my spacebar 4 times. That takes way too much time.

I can't read that shit.

PEP8 specifies 4 spaces

Just set your tab to 4space

The only reasonable argument for spaces is that they make fancy aligning easier and less likely to get messed up if some retard who's unable to comprehend tabs touches the code.

But seriously though, you shouldn't even be aligning your code. What's the fucking point? It doesn't really increase readability much at all and makes maintenance hell. Lately I think I've been seeing a trend of code aligning getting less popular.

Please be patient: I use spaces.