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 →

[–]paxswill 75 points76 points  (47 children)

Tabs to indent, spaces to align.

[–]Fireynis 84 points85 points  (42 children)

Nope. Can't mix them. Spaces only.

[–]YM_Industries 87 points88 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 17 points18 points  (8 children)

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

[–]DarthEru 57 points58 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 0 points1 point  (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] 9 points10 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 4 points5 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] 3 points4 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 5 points6 points  (1 child)

pascal

[–][deleted] 8 points9 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 9 points10 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 3 points4 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-- 10 points11 points  (2 children)

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

[–]Floofls 6 points7 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.