Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Tabs or Spaces

Name: Anonymous 2007-10-18 10:22

Should I use tabs, or spaces to indent my code?

Name: Anonymous 2007-10-18 10:23

Or a mix of both?

Name: Anonymous 2007-10-18 10:32

Learning Python will answer your questions.

Name: Anonymous 2007-10-18 10:34

Tabs.

You don't want to force your preferred indent size on everyone.

Name: Anonymous 2007-10-18 11:49

Spaces.

Tab widths can vary and make your code look crazy in a different program.

Name: Anonymous 2007-10-18 11:51

4 spaces

Name: Anonymous 2007-10-18 11:54

A mix.

Tabs for indentation, and spaces for readability:

<tab>for (int i = 0;
<tab>     i < 3;
<tab>     ++i) {
<tab><tab>abort();
<tab>}


Don't use a sucky editor that molests young tabs and spaces.

Name: Anonymous 2007-10-18 11:58

>>7
see
>>5

Name: Anonymous 2007-10-18 12:02

>>5 is wrong.

Name: Anonymous 2007-10-18 12:03

Using tab characters for indentation is retarded.

Name: Anonymous 2007-10-18 12:03

>>8
No.  It'll still look the same, just a bit more horizontal space.

People with huge tab sizes usually have huge monitors as well, so they are probably prepared.

Well, personally, I use two spaces most of the time, but that's because I'm a Haskell faggot.

Name: Anonymous 2007-10-18 12:07

>>1
Copy some tab-indented code from your code editor into another editor or into a textarea on /prog/. Enjoy your formatting issues. Tabs just introduce pointless issues. Why use tabs when spaces suffice?

Name: Anonymous 2007-10-18 12:09

>>11
No.  It'll still look the same, just a bit more horizontal space.
Yes, it will appear differently than your version. I can't see what could be good about that.


People with huge tab sizes usually have huge monitors as well, so they are probably prepared.
That is just stupid.


Well, personally, I use two spaces most of the time, but that's because I'm a Haskell faggot.
It's irrelevant that you use two spaces all the time if you're arguing for tab-character-based indentation, and I don't care what language you use.

Name: Anonymous 2007-10-18 12:12

It's bad enough that your code isn't semantically portable; and now you don't even want to write textually portable code.

Name: Anonymous 2007-10-18 12:13

Tabs are good for scalable indentation of code.

Name: Anonymous 2007-10-18 12:16

New holy war! Thanks >>1, emacs vs vim was getting old.

In theory, you can use either, as you wish, but you shall respect the forced indentation of code.

However, in the real world, many people work on the same project, and others always use shitty editors. These editors will eat tabs and/or spaces and convert one to another whenever they feel like it. For example, they may do so when you edit a line, even if you don't edit the line indentation. (In the best case, they'll just convert the whole file.) Then Python code breaks.

What's worse is that when you open it in your editor, everything looks like bullshit unless your tabs setting is the same as the moron's who edited it. And since morons rarely use the only correct setting — 4 spaces —, you'll be damned.

So don't rely on tabs. They'll always cause trouble. Use 4 (FOUR) spaces. It's the only way to heaven. Everything else is flawed. Also, 2 spaces faggots make code shitty to read, and 8 spaces faggots are such faggots they don't even deserve to code. 4 is the only perfect balance: even, power of two, not too much nor too little, and looks good.

Name: Anonymous 2007-10-18 12:18

>>16
D'accord. Thread over.

Name: Anonymous 2007-10-18 12:22

>>16
3 is the only perfect balance: prime number, not too much nor too little, and looks good.

Name: Anonymous 2007-10-18 12:23

It's hilarious that Python breaks just because somebody used tabs instead of spaces or vice versa.

What a language.

Name: Anonymous 2007-10-18 12:24

>>18
Truth.
Truth.
Truth.

Guido is a faggot for using 4.

Name: Anonymous 2007-10-18 12:27

>>19
>It's hilarious that Python breaks just because somebody used tabs instead of spaces or vice versa.
Yes, a language in which a form of syntactic tokenisation is provided by indentation. And?

Name: Anonymous 2007-10-18 12:32

>>21
Nothing, it's perfectly cool to use WHITESPACE for that. Stupid other languages, using characters which don't get eaten by editors and such.

Name: Anonymous 2007-10-18 12:33

>>21
What does that have to do with the topic? Or is that just your way of saying ONE WORD THE FORCED INDENTATION CODE THREAD OVER.

Name: Anonymous 2007-10-18 13:13

>>7
Why the fuck would you break up the for loop arguments to multiple lines? That's just ugly.

Name: Anonymous 2007-10-18 13:22

>>24
I would if the statements were really long -- Sepples::iterator long, that is!

Name: Anonymous 2007-10-18 13:52

Using two spaces is only good for hiding that you have deep code nesting (read: that your code sucks).

But it's bad for readability. Especially for old hackers, who's eyes aren't working as well as before.

8 spaces (normal tab size) is way too much again, and may makes your code lines go way past 80 characters in length. A good compremise is 4 spaces.

Still, a lot of people seem to swear by 2 spaces, as it's their pride their defending. So to those of you who use less that 4 spaces for indentation, please use tabs. That way I can set my tabsize to 4, and enjoy maintaining your code more :)

Name: 26 2007-10-18 13:58

I just wanted to point out that I like the points >>16 and >>7 make.

Name: Anonymous 2007-10-18 14:19

1 space or GTFO

Name: Anonymous 2007-10-18 14:22

press tab to insert several spaces.

Name: Anonymous 2007-10-18 15:36

Tabs, obviously. What kind of retard is going to put non-resizable indentation in their code?

Name: Anonymous 2007-10-18 16:14

>>30
python faggots fearing code break

Name: Anonymous 2007-10-18 16:16

tabs

Name: Anonymous 2007-10-18 16:23

What's so hard with doing s/\t/g    / or s/    /\t/g?
I use 8-space tabs, so what? It is a single character, \t and the way it is represented is system dependant.
If i have, say 1000 tabs in my source code it's 1000 bytes; If i'd use 4 spaces it would be 4000 bytes, which is a horrible waste of bytes.
And 1000 tabs are not many, a src of 1000 lines should have at least 1000 tabs.

Well, in C at least.

Name: Anonymous 2007-10-18 16:31

>>33
s/  /\t/g replaces more than what you want..

I agree on saving bytes being really important. I only use 1 character for variable names if possible. For example h instead of hostname. This saves me at least 7 bytes each time I use it! I also try to keep my function names to a maximum of 4 characters.

Name: Anonymous 2007-10-18 16:40

What the hell does that matter in fucking source code on today's computers?

Here you are, making a game with volumetric fog rendering and a billion post-processing effects, and you're willing to fuck up your code's readability to save a few fucking kilobytes?

Fuck.

Name: Anonymous 2007-10-18 16:42

>>34
4 is a bit silly i think; give some examples?
I prefer 6 maybe with prefixes/suffixes when needed (like libc)

as for s/  /\t/g replacing more than i want, that's not the case with s/\t/<anything>/g is it?
Tabs are superior, if i don't like them 8 spaced, i change my configuration, if you give me src with 8 spaces, i have to use some fucking regex on the file buffer which is retarded.

Name: Anonymous 2007-10-18 16:45

>>35
Because it's a FUCKING PAIN IN THE ASS to type enterprisey named functions? And don't mention name completion in `proper' text editors.

Name: Anonymous 2007-10-18 17:20

>>37

OH HI I AM AN FUQIGN EXPERT PROGRAMMER I WRITE CODE ALL DAY AND THREE EXTRA CHARACTERS ARE TOO MUCH FOR ME TO WRITE

Name: Anonymous 2007-10-18 17:39

I liked tabs once, but now I like 4 spaces because everyone seems to use tab length 4 anyway.

Name: Anonymous 2007-10-18 18:09

>>39
Why would you choose to hit space 4 times instead of hitting tab once?

Name: Anonymous 2007-10-18 19:29

>>40
Why would you choose to use an editor that makes you indent manually?

Name: Anonymous 2007-10-18 19:39

>>40
because most editors have the ability to have the tab key insert 4 spaces instead of \t

Name: Anonymous 2007-10-18 19:52

>>41
because indentation is trivial.
>>42
thats retarded.

Name: Anonymous 2007-10-18 20:13

>>43
You're telling me that it's better to do trivial things yourself than to make the computer do it for you? Do you just not know how to program or something?

Name: Anonymous 2007-10-18 20:16

>>44
NO GODAMIT YOU FUCK
I MENT
THAT INDENTATION IS TRIVIAL
AND THE EDITOR SHOUDL DO IT
IM NOT >>40
GODUFKCUGIDNAKFNASDLFJDAS

Name: Anonymous 2007-10-18 20:40

>>45
It doesn't matter who you are. I asked
Why would you choose to use an editor that makes you indent manually?
and you said
because indentation is trivial.

Name: Anonymous 2007-10-18 20:45

>>46
youre ON T4CHON
i should've put a "amirite?" there
"because indentation is trivial, amirite?"

fuck sage

Name: Anonymous 2007-10-18 21:42

>>47
Yes.

Name: Anonymous 2007-10-18 21:46

Neither.  Spacing is part of the presentation layer, not the underlying code structure that the system stores, and allows each editor to have their own indentation and spacing preferences without stomping over version control.  Oh, wait, you're still using fucking direct 8-bit text streams for source?

Name: Anonymous 2007-10-18 22:12

>>43
>>42
thats retarded.
no u

Name: Anonymous 2007-10-18 22:25

>>49
Parse trees in my SCM?

Name: Anonymous 2007-10-19 1:40

>>40

I'm not talking about tabs/spaces. lern2reading comprehension and context.

Name: Anonymous 2007-10-19 2:47

>>7
the only way

Name: Anonymous 2007-10-19 3:24

>>28
Seconded.

One space = portable and leading spaces are easily converted into tabs if you want.

I personally hate tab characters.

Name: Anonymous 2007-10-19 4:30

>>44
FORCED INDENTATION OF THE CODE

Name: Anonymous 2007-10-19 6:21

>>55
NO U

Name: Anonymous 2007-10-19 6:55

>>40
If you had a good text editor you wouldn't need to hit space four times.

Name: Anonymous 2007-10-19 7:01

Sussman uses spaces!

Name: Anonymous 2007-10-19 7:01

Call me a massive c-faggot which i probably am, but spaces in C for indendation are utterly stupid.
Tabs all the way in C.
When we talk about programming i have C in mind, while others don't (silly of me)
However, i understand why someone who uses Haskell needs spaces instead of tabs.

Name: Anonymous 2007-10-19 9:12

>>59

If you understood C, you'd use spaces.

Don't change these.
Name: Email:
Entire Thread Thread List