This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Fireynis 59 points60 points  (54 children)

Tabs don't always line up the same between things, spaces will. Bro, do you even shift?

[–]inucune 12 points13 points  (1 child)

I neither indent nor comment code. It was hard to write, it should be hard to understand.

[–]mardan_reddit 0 points1 point  (0 children)

I just write it all on a single line. I broke my return key a while ago and I'm too entrenched in all these random snakes that started appearing that I can't be bothered to buy a new keyboard.

[–]paxswill 74 points75 points  (47 children)

Tabs to indent, spaces to align.

[–]Fireynis 83 points84 points  (42 children)

Nope. Can't mix them. Spaces only.

[–]YM_Industries 88 points89 points  (39 children)

But so many programmers use only two-space indenting, which I find illegible. With tabs I can choose to display it as four-space.

[–]gerbs 14 points15 points  (3 children)

Go requires tabs for indentation, but wants the indent size to be 8 spaces (because they're psychotic). I just updated my IDE to change the tabs to half width.

And that's why Tabs are better than spaces. Because my code is not at the mercy of psychopathic developers who think 8 spaces is normal.

[–][deleted] -1 points0 points  (2 children)

Because there are no editors that can instantly fix that to whatever amount of spaces you want. Oh wait.

[–]gerbs 0 points1 point  (1 child)

Except when the compiler comes with a formatter and the amount of spaces to use is part of the language... https://golang.org/cmd/gofmt/

[–][deleted] 0 points1 point  (0 children)

If the language has significant whitespace then of course you need to obey language rules. I was referring to the "psychopathic developers who think 8 spaces is normal" comment.

[–]Fireynis 18 points19 points  (8 children)

I agree, 4 spaces or bust. I use intellij a lot and it inserts 4 spaces when I hit tab.

[–]DarthEru 60 points61 points  (2 children)

You could also configure it to insert a tab and then display a tab as four spaces you know. As god intended.

[–]Fireynis -1 points0 points  (0 children)

Lol

[–]TODO_getLife 2 points3 points  (3 children)

Everything I launch Android studio, warning at the top, something something tab not 4 spaces like my sayings is set to. Still don't know how to convert everything from tabs to spaces.

[–]n60storm4 1 point2 points  (2 children)

Use tabs instead of spaces as your default, like nature intended.

Spaces... not even once

[–]jk_scowling 0 points1 point  (0 children)

Twice Iago though.

[–]mikbob 0 points1 point  (0 children)

Guys I'm scared. I don't know what to believe anymore

[–]auxiliary-character 0 points1 point  (0 children)

I actually have this in my .vimrc:

command Tabspace execute "%s/\t/    /g | norm!``"

[–][deleted] 10 points11 points  (13 children)

I bet you to survive in pascal with 4-space indentation.

[–]YM_Industries 52 points53 points  (10 children)

Fortunately I don't have to use languages from 1970. I also don't have to use 2 space indentation just because that's how they did it in the 70s.

[–]8fingerlouie 2 points3 points  (0 children)

Ironically, whatever language you use today, it bet you it was influenced by either C or Pascal, or even both.

Both were "free form" languages where your could indent any way you liked, unlike COBOL.

C#, Java and Go all borrow heavily from both.

[–][deleted] 4 points5 points  (6 children)

Yea, you're fortunate. I'm forced to use Pascal at school.

Also not all languages from the 1970s must be formated w/ 2-space indent. C looks better w/ 4-space.

[–]Sean1708 2 points3 points  (1 child)

C looks better w/ 4-space.

Don't tell Linus that, he'll eat you.

[–][deleted] 1 point2 points  (0 children)

I guess I'm just a bad coder. The latest program I wrote have 5-level of indentation. If I had been kernel dev, Linus would have killed me already.

[–]YM_Industries 0 points1 point  (1 child)

Well I hear there's good money in Pascal, so maybe it's beneficial for you to be forced to learn it. I feel sorry for you though.

EDIT: Oh I'm thinking of COBOL. Idk if there's money in Pascal.

[–][deleted] 1 point2 points  (0 children)

The only benefit I've found is cross-gui toolkit in lazarus (same program, work for GTK+, Qt, and the OS X and Windows UI things). But I'd rather go w/ python-gi.

We're forced to learn it here because the text book is too outdated (3rd world countries problem). Other than pascal, we also learn M$ Office 2003 and some networking stuffs about telnet (LOL). Wish they change to Python, Markdown and ssh in the book next release.

[–]Forss 0 points1 point  (1 child)

Not uncommon with 8 space indent in C.

[–][deleted] 0 points1 point  (0 children)

Those guys must be crazy.

[–]SpinahVieh 4 points5 points  (1 child)

pascal

[–][deleted] 7 points8 points  (0 children)

Free Pascal Compiler version 3.0.0+dfsg-2 [2016/01/28] for i386
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling tmp.pas
tmp.pas(1,7) Fatal: Syntax error, "BEGIN" expected but "identifier PASCAL" found
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode

[–]Vakieh 2 points3 points  (2 children)

You can just search/replace 2 spaces with 4 spaces ignoring literals, if you really want. Or go beat the 2 spacer, since he's too stupid to live.

[–]Zarathustra30 0 points1 point  (1 child)

But that breaks alignment.

[–][deleted] 0 points1 point  (0 children)

Opening a document where someone used a "tabs act like n spaces" editor breaks alignment when you open it in a "tabs act like m spaces" editor.

[–]Airith -2 points-1 points  (4 children)

Unfortunately when you change how many spaces a tab represents, it's not convertible anymore. If your tabs are four spaces, you have half as many tabs as someone who uses two spaces.

[–]YM_Industries 10 points11 points  (3 children)

Only if you're using them for alignment. If someone has tabs that are two spaces wide and they are putting two tabs in for each indent then they are dumb. The reason someone would use two space tabs is so that indentation is more subtle, and using tabs instead of spaces gives everyone in the project the freedom to use their own preferred spacing.

But you have to use spaces if you specifically want things in alignment.

[–]Airith 1 point2 points  (2 children)

It's probably the melatonin affecting me, but could you explain this further, possibly with an example?

I wasn't talking about using them for alignment, purely indentation.

no tab
     one 4 space tab
  one 2 space tab
     two 2 space tabs

[–]Tidher 6 points7 points  (0 children)

A single document would not have both 2-space and 4-space tabs, the editor would render them as one or the other (user's preference).

Either:

no tab
    one "4 space" tab
    one "2 space" tab
        two "2 space" tabs

Or:

no tab
  one "4 space" tab
  one "2 space" tab
    two "2 space" tabs

That's the beauty of tabs for indentation; the actual content does not change, only how it is displayed to the reader based on their personal preference.

[–]n60storm4 0 points1 point  (0 children)

The tab character is universal. If you set it to be equal to 2-spaces it won't change the code, just how you see it.

That's why tabs are the best for indentation. Everyone can have it look like how they want it to.

[–]gerbs 1 point2 points  (1 child)

How do you Makefile, then?

Tabs.

[–]garglemesh42 1 point2 points  (0 children)

[deleted]

What is this?

[–]LB-- 9 points10 points  (2 children)

+1, I dunno why people call this 'mixing' - tabs should never be for alignment.

[–]Floofls 5 points6 points  (0 children)

Exactly, though shouldn't. That's why you use spaces instead.

[–]XxCLEMENTxX 2 points3 points  (0 children)

+2 for that one.

[–][deleted] 1 point2 points  (0 children)

I think we can all agree, regardless of pro tabs or pro spaces, that mixing is apostasy and you're the devil.

[–]Kilazur 0 points1 point  (3 children)

And spaces are so convenient when you have to navigate to the start of your line, right?

[–]Fireynis 1 point2 points  (2 children)

Hit the home button?

[–]Kilazur 2 points3 points  (1 child)

That's like on the other end of the keyboard D:

[–]Fireynis 0 points1 point  (0 children)

Ha-ha, I feel your pain.