Tabs or spaces?

Tabs or spaces?
How many spaces?
How many spaces per tab?
Single or double quotes?

Attached: tabs-vs-spaces.jpg (1440x679, 132K)

Other urls found in this thread:

youtube.com/watch?v=PAAkCSZUG1c&t=8m43s
superuser.com/questions/355863/why-is-the-default-tab-size-8-spaces-where-does-this-come-from-and-why-is-it-th
twitter.com/NSFWRedditGif

no one cares except reddit and twitter thots who took a coding bootcamp

Tabs for indentation, spaces for alignment is the correct answer.
Set tabs it to whatever number of positions you like, because it won't matter apart from maybe issues of lines being too long.
For languages that allow single/double interchangeably, single is better. It's one less keystroke unless you know there's going to be lots of single quotes you need to escape.

>Tabs for indentation, spaces for alignment
lol what? alignment and indentation aren't two different things.

You indent, to align. The question is: do you use spaces or tabs to indent/align?

No, they aren't.
Indentation is how you indicate how many blocks you're in.
Alignment is where you have a statement that is too big for one line and you want to break it up. You ideally want the continuation to line up with the original.

myList = [item1,
item2,
item3]

>You ideally want the continuation to line up with the original.
Only retards do this

I bind tab to four spaces, I usually use single quotes unless I need to otherwise.
This, nobody really cares. Just pick a style and stick to it

Attached: 1554479568608.jpg (369x387, 35K)

There's no global standard for the length of a tab. It can vary wildly depending on what part of the world you're in. However a space is a universal width no matter where you are. This is why it's preferable to bind your tab key to insert spaces

Spaces

i also saw that episode of silicon valley fellow hackerman.

Attached: 234523415.jpg (251x201, 8K)

set tabstop=2 shiftwidth=2 expandtab smartindent

It was retarded how they portrayed it. They literally showed that dumb girl programming and pressing "space space space space" and that was his main argument for not liking spaces too.
I hope you all know that was utter bullshit right? If you have your editor configured properly then the behavior of spaces should be almost entirely identical to that of tabs. In fact someone could probably switch your setup and you wouldn't even notice the difference for quite a while.

No one uses just tabs unless they are comfortable with their code looking like trash due to bad alignment.

You must either use tabs+spaces or just spaces. So, you might as well just use spaces only.

>tabs or spaces
if working with an existing codebase, use whatever it already uses. If inconsistent, pick the most-often used style.
if it's a new project, follow common convention for the language.
>single or double quotes
those aren't interchangeable in any languages I use at work, but I'd say use single quotes unless using double quotes will help avoid escape characters.

nah, with tabs+space people can have different /tab space/ preference. space only is ironclad

found a python user

Attached: flat 800x800 070 f.u6.jpg (586x800, 37K)

3 spaces
q()
To use the same character to open and close a quote is barbaric.

>different /tab space/ preference
Like what? I can't think of anything you might have in mind which can't also be done with spaces.

you should never use more than 1 character to separate words or characters. It takes more time to delete.
If you are that guy who uses tab to write 4 or even 8 spaces kill yourself

1. Not giving a fuck

POWER GAP

2. X spaces bound to tab
3. Tabs

if you faggots have an opportunity, you would also bake color theme into your code because it looks nicer

mine is set to 8, others like it lower? the point is you're not forcing your preference on others with the tab+space combo

Oh nevermind, I'm an idiot. You were referring to the tab spacing preference. I thought you were saying tab and space keys could have different preferences, which is obvious.

Anyway, I've never really found different indentation sizes (with spaces) to be an annoyance. Everyone basically uses the exact same conventions for every language. I can't even remember the last time I saw some code using a non-standard spacing for a particular language.

Come to think of it I also can't remember the last time I ever opened up a file and saw a tab character in it. It really seems like spaces dominates the field.

>hurr it was in a tv show so I must be contrarian
retard, then when you delete it you also have to delete 4 times fucking stupid nigger

On old systems like DOS text editors spaces, because it's easier to align words. On modern systems, tabs, because it's easier to align words in that case.

>fstab formatted with tabs
>fucking unreadable
>fstab formatted with spaces
>have to reformat every line if one column goes over
>fstab with single spaces between each item
>perfection

Tabs. I also double space my code just to annoy the autist that have to read through it.

1) Your greentext is pure projection. It is a FACT that programming with spaces was misrepresented on the show. Nobody who programs with spaces hits space 4 times every time they need to indent.
2) Either you don't use the Backspace key or you were referring to all forms of deleting just now, and that means you do not know what you're talking about.

If my tabwidth is set to 4 spaces then backspace deletes 4 spaces. And no, it's doesn't do it stupidly either, it aligns it to an imaginary grid, so if I have 6 spaces on the line and my tabwidth is 4 and I press backspace it'll delete only 2 spaces.

The ability to move to the left and also fine-tune it by pressing Del in the rare cases where it's needed is a good thing, not a downside.

wow... imagine having to make such a clusterfuck of a scriptjust to input spaces instead of tabs because you saw something in a show

You'll then have off-centered alignment if the tab width is changed.

If a tab of 3 spaces + a regular space was used, it will be broken if it was change to a tab of 4 spaces. Think about it.

>If my tabwidth is set to 4 spaces then backspace deletes 4 spaces
No it doesn't. I've yet to see an IDE/editor that has this behavior without custom plugins or scripts
Even if all editors could do this, tabs+spaces is still superior for the simple fact that it allows people to set their own preferred tabstop without fucking up the formatting. as explained in Unfortunately space people can't comprehend this

no? everything will just be moved by one space?
your example makes no sense

Press for indentation and convert it to 4 spaces.

ty for not being brainlet

Why are you so upset about something you clearly haven't done any research on? It almost sounds like you're offended that I said the show contained an problem.

There is no scripting involved here. What I'm talking about are all standard settings readily available inside both vim and emacs.

So you've been shown to not understand how these settings function (you were unaware of the backspace behavior) and you've been shown to not even know these are standard settings.
Why do you continue to try and act like you're some authority on this topic, and why do you continue to assert that a show depicting someone pressing space 4 times when nobody does that is somehow just me being edgy or whatever the hell you're trying to imply? A misrepresentation is a misrepresentation.
Get over it.

DocumentCode in html4 like its a Run-On-SentenceI turned in a project like this in highschool and had to stay after class and be told by my teacher whom I had a crush on that this was unacceptable simply from a debugging standpoint and that I needed to redo the assignment.

I don't know what to tell you user. You're wrong. All my editors have behaved that way for as long as I can remember.
It's been so long I don't even remember exactly what the individual settings in my vimrc do, but I'd guess the setting is probably one of these:
set autoindent
set tabstop=4
set shiftwidth=4
set expandtab
set virtualedit=all
Enjoy.

Since I use Ansible on a daily basis I have to use spaces, tabs break YAML.

>convert tab in 2 spaces
>use tab

I thought 1 tab = 4 spaces (depending on the editor)

go fmt

This, but it gets goddamn tedious when your editor doesn't account for it.

youtube.com/watch?v=PAAkCSZUG1c&t=8m43s

Attached: rob.jpg (1254x644, 59K)

No, the standard is intervals of 8.
Also, tab characters don't have a fixed width, it depends on at what column the tab character appears in. If you set tab stops at every 4 characters, then a tab character can be between 1 to 4 spaces wide.

>mfw when most of the people who support tabs think spaces people press the space bar multiple times
>mfw most of the people who support tabs are retarded
>mfw I have no face

In python I was obligated to do tabs more or less, and now that I work with C# I'm used to tabs (4spaces for each tab)

Whatever works; nobody cares unless it legitimately fucks up efficiency or security of whatever you're making.

Tabs. Always.

The only thing about this that irks me is why is it IDEs and editors doesn't know about this?
I mean, they think you want one or the other and gives you settings for it, but all of them makes you change.
Why not just automatically detect what is used and apply those settings to the document you are editing?
I jump around in a lot of different projects and I want to respect the choices they have made individually.
Detecting this is the easiest thing to do, so why isn't it standard in every editor?
We already have automatic alignment tools, so it is not like it works poorly once configured, we just need to automatically configure it.

I'd notice the difference immediately because tabs are indicated in my editor, whereas spaces are literally spaces (unless they are at the end of a line, in which case they highlight red)

Also, people don't mix tabs and spaces because there is no standard way to tell the editor how large the tabs are supposed to be, so alignment breaks. I only use tabs if it's preferred for the project or language. (For example php people seem to like tabs so usually if I have to edit php I use tabs, also, I took a class where tas were used. All it takes is one autocommand line for the file type or path)

Attached: 1554750536815.jpg (418x464, 99K)

We should all just use the Japanese space character (full-width space) for indentation.
Can we all agree on this?

i use 4 japanese space characters

Single and double quotes have different meanings in almost every language, so that question is quite stupid. Generally quote type changes interpolation, special characters, or typing. For a quick example, go try and compile a C program that says something like 'char mychar="c";' you'll end up with a type error. Another example is in Ruby, single quote means you get exactly the string, no escape sequences or interpolation, double quotes give you stuff like \n and #{interpolation}

Attached: 1554652591030(2).png (392x278, 138K)

I'm not opposed but to get people to switch over and have compatible editors could easily take 10-20 years. It probably breaks languages like python too. You might as well just fight for a tab character to be exactly four spaces. Knowing retards, if we switched to the 4-space character it wouldn't be long before electron-tier editors let you customize the character width, defeating the whole purpose.

Python has 4 different quote delims that can be used interchangeably. So there are languages where it doesn't matter which you use. In addition, for something like bash, if there's nothing in the quote that would be evaluated or escaped, then it also doesn't matter there.

I have a macro that randomly inserts tabs, spaces of various widths and sometimes a random number of zero-width spaces.

There isn't really a standard... If there is any standard it depends on the language or project. For the Linux kernel, the standard is 8-character tab indentation, and part of the rationale for 8-characters is that it makes it obvious when you've nested too much code. I've seen plenty of space-indented c that is just fine though, with varying widths, usually 2,4,or 8.

In Ruby, I commonly see code indented with spaces, and two spaces are common. Considering that most Ruby ends up in at least two blocks deep, it makes sense to have smaller indents. I've also seen two-character indents in Java, I think because it's so verbose you run out of width pretty fast, but I think it makes Java more difficult to read overall. I believe that I've seen 4-character indents more commonly with web stuff like PHP, and of course because JavaScript is JavaScript you tend to see files that randomly have varying indent width and illogically placed tab characters.

Anyway, the point is that there's no global standard. I think the Linux guidelines are great for C but it'd be crazy to try and apply them to a lisp, for example.

Attached: 1554750930726.jpg (2074x1382, 212K)

>Tabs for indentation, spaces for alignment is the correct answer.
Right, and then when someone aligns for a different tab indentation, you're whole setup is misaligned.

I didn't know that of python, but it makes sense considering python is so widely used among non-developer types. Quotes definitely threw me off when I was beginning with coding. Bash is a great example actually because it is easy to miss the difference at first, it's a language where you could probably go years not knowing quotes are different until one day you pass some garbage to a program and get an error.

>I have never used an actual terminal
8 is the standard, deal with it. All terminals used it, vi(m) and emacs use it, the Linux console (not talking about the source code) uses it.

superuser.com/questions/355863/why-is-the-default-tab-size-8-spaces-where-does-this-come-from-and-why-is-it-th

No, you align in a way that is independent of tab size, and the whole thing can change tab sizes and still look the way it should. That's the whole point.

So you're a JavaScript programmer. See, all this time I thought that shit was from copy-pasting off stackoverflow, but now it's confirmed that you guys aren't as stupid as you seem, you're just huge assholes.

Attached: 1554674224952.gif (640x480, 1.26M)

Tabs
4 spaces per tab
Plus spaces for alignment sometimes

You do know that tabs are used for making tables, right? Like a table of dollar amounts for an accounting spreadsheet. 2 and 4 are way too small for that.

Well I learned something new. So 8 is standard tab width. That still doesn't mean there is a standard indentation for code though.

I'm talking about indentation for code, which is what this thread is mostly about. I did conflate the terms indentation and tab, so I'll give you that.
As far as tabular data, I've definitely displayed things with tabs as short as one character, two examples off the top of my head are status outputs from docker, and lsblk.

AHEM AHEM. PREPARE TO READ THE OBJECTIVELY CORRECT RESPONSE.

Tabs are better. Tabs of 4 character length. You may on occasion use 1/2 tabs to pretty up your code if you are feeling cute.

But really that should be avoided. No one will going to read this shit anyway(certainly not for the pretty formating) and when you look back at it in 6 months it will disgust you for lacking the new syntactic sugar you learned last week.

>cute
>reddit spacing
>syntactic sugar
off yourself already

>separating paragraphs
>reddit spacing
Stop trying to fit in too hard, crabbitor.

Tabs and spaces are bloat the compiler doesn't even read. Why should I add extra bits to my file size when all I need is one line? I can read my code just fine

This is an amazing level of faggotry

based

>Tabs or spaces?
Spaces, obviously. Alignment is good for readability and you can't guarantee alignment when there's no standard for how much space a tab will represent
>How many spaces per tab?
I like 4. 2 is also fine
>Single or double quotes?
Single for characters, constants, and flags; double for normal strings

obviously tabs, anyone can then set tabs to be whatever length they went then and theres no arguments/autism

Compilers are bloat. Just program in binary.

my vim does that out of the box, sorry about your autism

myList =
[ item1
, item2
, item3
]

tabs is this even a question?

There are only 2 types of people in this thread.
Those who use spaces, and those who don't use spaces yet.

>tabs or spaces?
Always spaces. Tabs aren't standard and don't always display as you expect them to outside of a text editor. Getting vim to generate tab-aligned spaces when tab is pressed is easy. Converting text is as easy as %retab. The only argument in favour of tabs is the bytes wasted in source files on spaces.
>how many spaces?
Up to you. 2 for filesize and keeping code small in width. 4 is a good tradeoff for readability. 8 for extreme readability, but mostly autism. It doesn't rly matter how many, but you should aim to keep your code inside of 80 columns to accommodate different screen sizes, editors, etc.
>how many spaces per tab?
Up to you. 4 or 8 is fine for tab-aligning text. You may also wish to use the same value as your indentation for quickly indenting code.
>single or double quotes?
This is very language specific. You should always strive to adhere to a language's own conventions. If I'm using a high-level language which doesn't have said conventions, I personally use single quotes because it's neater (in the context of high-level programming). I mostly write in C, so this isn't really a question for me.
this

/thread

dont do this ever, it's stupid, requires plugins, messes up with auto formatters (e.g. prettier) and it would be wrong in most contexts (e.g. python)

t. a lead dev with 11+ years of experience

indeed, /thread

Why yes, how did you know I use 2 spaces for indentation

Attached: 1551823571950.png (244x300, 49K)

>Tabs or spaces?
tabs for indentation, spaces for alignment
How many spaces?
0
How many spaces per tab?
irrelevant
Single or double quotes?
double

>dont do this ever, it's stupid
I know at least one language where that is the standard. If it's syntactically valid and a big help to readability, why is it stupid?
>requires plugins
No necessarily. But so what? Working efficiently in any language and environment often requires language specific configuration. You do this once
>messes up with auto formatters (e.g. prettier)
You mean the prettier PLUGIN lol?
>it would be wrong in most contexts (e.g. python)
In what way is python a "context" in which it would be wrong to write a list that way?

>how did you know
You look extremely stupid.

It's alright buddy, maybe someday you'll be cool enough to hang out with 2 space indent dudes

Attached: 1554768724375.jpg (1080x1246, 124K)

Reminder that space programmers are more skilled and better compensated

Attached: original_salary_plot-1.png (3200x1200, 162K)

Tabs
4
It depends on the language in some dont have that option in others im working with both depending on what im doing

i use the default settingns of my editor
fuck you autists

I do it with Python and it works fine. Post an example where it would work.

>Tabs or spaces?
Yes, sometimes. Logically I suggest pressing the tab key unless there's no tab key.
>How many spaces?
2^n spaces possibly
>How many spaces per tab?
n spaces.
>Single or double quotes?
This is language and context dependant, no valid answer can be given.

What is this, plebbit?

These stupid flame wars you algol users have are kind of adorable.