Tabs vs Spaces

Not counting house/project requirements.

Other urls found in this thread:

kotlinlang.org/docs/reference/control-flow.html
twitter.com/AnonBabble

Tabs

checking those dubs

I always use 3 spaces instead of tabs. looks more compact and doesn't cause a fuckton of wrapping

Spaces via tab expansion.

That is, when I press tab, my editor translates that into the appropriate amount of spaces (almost always 2, but sometimes 4, depending on the project).

I have only ever met one person who used spaces that preferred to mash their spacebar N times by hand. And that was only because he didn't know that tab expansion existed. Once I told him, he switch to it.

Spaces because consistency

4 spaces

Spaces.

Make your editor change tab input to spaces.

You fucking idiot - how is this a question?

This is the best method. The only time that I don't is when I'm working with a piece of software that REQUIRES things to be written with tabs (I'm looking at you portage).

tabs and spaces

i like to live dangerously, tab usually whatever the ide indents with, and then occasionally you have to use a space to line things up

There was a guy here a long time ago that wanted the Tab key to die. Good times.

this is such a stupid fucking argument

pick one and stay consistent

I do whatever the surrounding code base does.
For new projects, I follow what the standard library does.
You know, when in Rome do as the Romans do.

Anything else is retarded..

Wow.

Tab, no question.

Everyone clearly has there own idea how many spaces to indent. If you indent with tab, you don't force your indentation size on anyone.

Smart tabs is obviously the best method.
It might be too hard for people with less than 80 iq though.

tabs, width=2

tabs expanded to 4 space for python

Why the fuck would anyone use spaces?

I copy paste so much shit that it's faster to backspace them to their places if they are done with tabs.

Other than that I don't care as long as I don't need to mash spacebar

Tabs, always. I get booty-bothered by the use of spaces in the year 20XX when every editor has adjustable tab widths. There's no excuse for spaces.

whatever the standard for the language or project is

i don't careeeeeeeeeee people who get bent out of shape about it are dumb

Spaces via tab expansion because muh haskell and f#.

A tab or 4 spaces.
Both are equal width.

Fuck all the special snowflakes making up their own standards.

Tabs to indent, spaces to align

There's very few good reasons to use spaces. The main argument spacefags can come up with is "b-but it looks the same everywhere" - but how's that a good thing? With tabs people who prefer different indentation widths can apply their own, with spaces everybody is forced to look at what one egoist liked.

Until you need to align multi-line statements with spaces beyond a tab, and all shit breaks loose. In all but the strictest environments, using tabs leads to mixing of tabs and spaces, which means you don't get to "apply your own" anyway, and might as well be using spaces in the first place!

Last time I checked, tab by default, is 8 spaces. So no, they are not of equal width.
True, plus different editors treat tabs differently. So why not just spaces instead and save yourself the trouble.

>need to align multi-line statements
>need
Why though? The answer to the question "should I spend my time lining these things up for diminishing readability improvements and increased maintenance costs" is almost always a negative.

That said, if you still insist on lining shit up, tabs can still work. You don't really need the "strictest" environment honestly, just everybody respecting the formatting. Though I admit there's often those turbo normies who just don't give a shit and soil it for everybody else.

>plus different editors treat tabs differently
Again, how's that a negative? Instead of telling the team to use spaces, you can tell them to use 4-width tabs, which is just as easy but gives you a lot more leeway later on.

>he uses text wrapping

i use my IDEs default settings

Tabs for indentation, spaces for alignment. Before committing I usually always use clang-format or yapf to format according to guidelines.

2 spaces for all indent intent. Spent some time doing Clojure and after I resumed 4 space Java I just couldn't figure out why the extra 2 spaces.

this guy's what I was talking about

>i use my IDEs default settings
>IDE
So do you work in Java or C#?

Smart tabs dammit!

Indent with tabs
Align with spaces

don't spaces consume more memory than tabs do?

>tabs
force you to mix in spaces when you intend

>spaces
clear winner if your editor supports basic stuff, like translate tab to spaces
no one actually presses 4 spaces to make tab, editor just writes spaces

Storage space, not memory

>intend
indent

No argument apart from the erroneous assumption that having both spaces and tabs appear in a file is inherently bad.

java

4 spaces, almost guaranteed to look the same in any IDE/text editor.

I dunno why anyone would want to use a control character in their code, are they masochists that enjoy people seeing their code in ways they didn't intend, just by using a different text editor?

Most IDEs already default to 4 spaces, makes it faster to get started seeing as using tabs just gives you another few minutes of setting shit up (some people enjoy that though I guess)

If you want people to contribute to your code you're going to run into issues by using tabs too, because of the aforementioned default to spaces.

Only real reason I can think of for using tabs is if you're living in 1985 and storage space is a premium, otherwise just make it easier on yourself.

Tabs for indentation, spaces for alignment

what do you put in storage space if not memory

>storage space
>Storage space

What is scaling?

Tab characters are for tabulation, not indentation.

Relative indentation is impossible with tab characters.

Alright then, you do you, Javabro.

However, just a passing note, some of us work in teams (or on projects), where we don't need an IDE to make our language tolerable, and where we are given the freedom to use whatever tools we desire. In that world, spaces lead to more consistent code.

But I don't fault you for working in Java! Seriously! Nor do I fault you for using an IDE, or for conforming to what works best in that environment. I had a BigCo McEnterprise Java EE job for several years. I just want to make you aware that not every project environment has the same parameters.

Huh? What's your point?

You certainly don't put memory in storage space. Memory implies volatile memory, storage implies persistent data storage. Tabs vs spaces don't matter considering memory for compiled languages or minified code.

Spaces but my editor is set up to treat them as if they were tabs.

Space indentation doesn't respect the user's freedom.

>you don't force your indentation size on anyone

There's one case where this isn't true: when you try to line anything up.

var hello = "hello";
var goodbye = "goodbye";


The above will look fucked up unless your tabs are 4 spaces, in which case spaces are the only way to ensure it looks right.

So it's worth using spaces over tabs if you do that kind of thing. I prefer it myself since it can make certain sections of code much easier to glance through.

this is autism

Tabs for indentation, spaces for align. Ever heard? It's been mentioned several times ITT already, and solves practically all common aligning problems.

>2

FUCK OFF

lol y u mad tho?

Tabs
Double quotes
if(condition){
}

Anything else is just disgusting

What's wrong with working in IDEs, even outside java or C#? Are you some sort of masochist who enjoys finding out that at line 1097 you missed a semicolon when your compilation failed after an hour?

>opening bracket on same line with other statements
>closing bracket on same line with other statements

I'm gonna puke.

Spaces

Just what?

What I'm saying is, fuck your spaces. If you put opening/closing brackets on the same line with other statements, you are a fucking degenerate.

I get that tabs vs spaces holy way is a bit of a meme.

But does anyone else wish they cared about it less than they do?

Like I would straight up get in a knife fight if one of my coworkers started using spaces because he insists it is better and this is the only way I will learn.

But like I should care less, no one should die over whitespace.

Nobody ever puts statements on the same line with opening braces if that's what you're talking about. Sensible people do, however, put function declarations and loop headers on the same line since that way they line up to the closing brace.

Still retarded. kys

Top argumentation there bud

What.
How does this line up?
if(statement){
//stuff
}

THANK YOU.
You are now my brother from another mother.

>moved to kotlin for android development
>android studio does not support opening colons on new lines
Why even live.

>using tabs or spaces

#include
using namespace std;
int main () {
for(int i = 1; i

The start of the block, the letter i, lines up with the end of the block, the closing brace. What's complicated about this?

Think of the if as a tag to the block. It's an integral part of the block, why should it be on its own line as it if was a separate statement?

Without the if you'd have
{
// stuff
}


Why should introducing the if "tag" to the block make it take an extra line? The block is still one composite statement just as it was without the if.

It doesn't? Just abandon it immediately.

I can't.
Kotlin introduces a lot of great improvements to java like strictly nullable parameters and safe calls.
It also introduces redundant changes like getting rid of the following
int a = (1 > 2) ? 1 : 2;

The lack of semicolons is infuriating, but lambda expressions and inheritance is much cleaner.
It could've been perfect, man.
How is that a problem? You can clearly see where the block starts and where it ends. It even aligns with the line that IDE shows.

>How is that a problem?
How's what a problem?

It's easier to the human eye when it's
if(fag)
{
//anal
}


It makes sense. What you're suggesting is basically "oh, well that would take one extra line, of course I won't put it there because muhfilesize." Unless you're a machine reading code, it doesn't make any sense to write it in one line.

> mixing spaces and tabs
Everything in this thread is opinion, except this, which is objectively wrong.

>You can make your editor insert n spaces when you press tab
Some editors display tab as 4 spaces, some as 8. Spaces are just more consistent, it will fucking look the same whatever shit your using.

> It could've been perfect, man.
You can use Scala or Haskell for an attempt at achieving that.

Kotlin is the simple proven stuff, for the most part.

What said. You're saying that putting keyword statements in their own respective lines is a problem.

But it's not even easier for the human eye. When I see a line with "if (whatever ..." I'm immediately treating it as the start of an if statement. Then I read further and see the brace there starting it. Thus I know that the next lines until the ending brace are the inner statements. Dead simple. If the starting brace is not there conveniently at the end of the line I started reading, I get confused for a millisecond before I notice it's on the line below for some reason. Completely unnecessary and inconvenient. You have 2 lines with the same indentation to start the block, instead of just 1. It's illogical.

insert tabs as spaces and everyone is happy

>Some editors display tab as 4 spaces, some as 8
And?

It works just fine if you don't have retards on the team or if you don't align things as if it improved readability.

>but it's not even easier for the human eye
What happens when nesting is involved though?

One line to start a block, one to end it. Everything between these lines is indented one lever per nesting level. Why should there be problems?

But the simple proven stuff is what makes it good and those little things matter in android because functions can still be called with null parameters in java when you don't @NotNullable annotation, yet it still tries to reinvent the bike by changing how keyword operations are defined.

Let's just agree to disagree. Just don't let me see your shitty bracketing anywhere.

How are spaces consistent?

Ok, you too

>Without the if you'd have
{
// stuff
}


This is completely valid for defining a new scope (i.e. helpful for managing temp variables).

void function()
{
var number = 10;

{
var value = // some complicated, long statement.
var value2 = // another complicated, long statement.
doThing(value, value2, number);
}

{
var value = // yet another complicated, long statement.
var value2 = // one more complicated, long statement.
doThing2(value, value2, number);
}
}


Why would adding an if-statement remove a line?

>This is completely valid for defining a new scope (i.e. helpful for managing temp variables).
Did I say it's wrong? I was arguing there should be no difference in the indentations or lines even if you tag the block with "if" or whatever.

>Why would adding an if-statement remove a line?
Why would adding an if to the same block give you a new line as if you had made a new statement?

I guess I'm arguing that since having the braces on their own line is normal for defining a new scope, it should continue being normal even if that scope is for a preceding if statement.

> @NotNullable
Yea, it is stupid that that is just an annotation in Java.

> yet it still tries to reinvent the bike by changing how keyword operations are defined.
I don't feel that is bad, a least it made things better in Scala?

I guess I haven't used Kotlin enough to think much about whether the keywords are chosen well or not.

That's a way to look at it, but the way I see it you primarily want to put only whole statements on their own lines. The exception being blocks, where you put both the starting part and the ending part on their own lines. The start of an if-block is not a statement in itself - it's the start of an if-block, and should go on its own line to start the block before being followed by the block's contents.

Always tabs unless code is short then just one line it

>It also introduces redundant changes like getting rid of the following

Haven't use Kotlin, but does it treat normal if-statements as expressions? Would the following work?

int a = if (1 > 2) 1 else 2

If you have a nested function, for example, do you press spacebar 20+ times to get the inner-most part of the function indented? That doesn't make any fucking sense.

Not him but yes. Pretty cool stuff.

kotlinlang.org/docs/reference/control-flow.html

Most programming-oriented text editors will auto indent when creating a new line and also automatically convert tabs to spaces.

Spaces for python.

Tabs for every well adjusted language that doesn't care about indentation.

That looks like complete garbage.

>Tabs for indentation, spaces for align
that still doesn't work if you are doing this kind of thing to avoid exceeding a line limit.
function_call(asdf, ggjhj,
hjkk, hjkl);

How did the spacing there get fucked up? It was aligned on the editor window.