Tabs vs Spaces

Please compose all posts in Emacs.

Moderators: phlip, Prelates, Moderators General

Re: Tabs vs Spaces

Postby endolith » Tue Mar 11, 2008 12:09 pm UTC

EvanED wrote:For some strange new definition of the word "solution".

His site and video only cover the somewhat easy cases, and arguably not perfectly. (For instance, note in the video how at 1:28 how the comment on line 11 doesn't move.)


But it's a step in the right direction. Whenever there's a "holy war" over some thing like this, where everyone claims advantages for their "side" and that the other side is categorically wrong, there's actually probably a modern, technical solution that would appease both, but people are too busy criticizing the other alternatives to think of it.
endolith
 
Posts: 224
Joined: Tue Jan 01, 2008 2:14 am UTC
Location: New York, NY

Re: Tabs vs Spaces

Postby edge walker » Thu Mar 13, 2008 6:54 pm UTC

Amnesiasoft wrote:Tabs for indent. Spaces for alignment.

Amen brother.
edge walker
 
Posts: 35
Joined: Thu Mar 13, 2008 5:04 pm UTC

Re: Tabs vs Spaces

Postby Anpheus » Fri Mar 14, 2008 9:00 am UTC

I don't understand why people are looking to technology to solve that question, when we've pretty well argued this, and the simplest solution is to change your bad habit and make a good one.
Spoiler:
Code: Select all
  /###\_________/###\
  |#################|
  \#################/
   |##┌         ┐##|
   |##  (¯`v´¯)  ##|
   |##  `\ ♥ /´  ##|
   |##   `\¸/´   ##|
   |##└         ┘##|
  /#################\
  |#################|
  \###/¯¯¯¯¯¯¯¯¯\###/
User avatar
Anpheus
I can't get any worse, can I?
 
Posts: 860
Joined: Fri Nov 16, 2007 10:38 pm UTC
Location: A privileged frame of reference.

Re: Tabs vs Spaces

Postby zahlman » Tue Aug 26, 2008 3:07 pm UTC

Yay. Got referred here from elsewhere. Hooray for necro-posting!

EvanED wrote:Unfortunately, not everyone does. There's some people in the one-true-style thread I think who think it should be a heretical 2 spaces. ;-)


I am one of them. The people I really don't understand are the ones who want to make it three spaces. Apparently, the author of the forum software is one of them, considering how tabs are converted in code boxes here. :)

Rysto wrote:Can we all agree that anybody who mixes tabs and spaces for indentation will spend an eternity burning in hell, though?


I'd like to. Unfortunately, that consigns far too many innocent people who are horribly abused by their IDEs. The people who *really* need to be, shall we say, doing their part to avoid an infernal ice age, are the ones who thought it would be a good idea to implement this when doing the auto-indentation in the IDE (the most common style I've seen is: 4 spaces; 1 tab; 1 tab and 4 spaces; 2 tabs; etc.), presumably to save a few bytes in the source files or something.

Seriously. We're all relative nobodies, and a bunch of people in this thread understand perfectly well how tabs and spaces are supposed to be combined. Why can't we get an editor which behaves this way by default? (Vim has the nasty habit of using mixed tabs and spaces for alignment, even once you've convinced it to use tabs exclusively for indentation.)

I've actually ended up modifying my style to use "indentation instead of alignment where reasonable", like so:

Code: Select all
# I'm using a Python example because my Python code is
# most prone to containing complex *expressions*:
# --> represents a tab
def func(
-->type reallyLongParameterNameOne,
-->type reallyLongParameterNameTwo
):
-->doSomething()
-->x = [
-->-->reallyComplexExpressionOf(thing)
-->-->for thing in funkyGenerator(
-->-->-->reallyLongParameterNameOne
-->-->) if interesting(thing)
-->]


Anpheus wrote:C++ keywords sorted by length:


Somewhat pedantic: "TRUE" and "FALSE" are not C++ keywords. "true" and "false" are.


EvanED wrote:If someone using an 8-character stop has to deal with lines longer than 80 characters, then too bad; he can just set it to 4-character stops, and you're almost no worse off than if you had used spaces in the first place. (In fact, if this person is editing the code, he'd probably need to change settings anyway if you used spaces, lest he start inserting 8 of them where there should only be 4.) At least with tabs you've given him a choice of (1) not worrying about the 80-col limit, (2) saying that his preference for 8-space tabs overrides his preferences for 80-col limits and leaving the settings the same, and (3) saying his preference for 80-col limits overrides his preferences for 8-space tabs and changing to shorter tabs.


OTOH, if this kind of thing is a problem in practice, it might indicate that the code is simply more complex than it ought to be. ;)

That must sound weird coming from the 2-space-indent guy. But I'm not using that as an excuse for more deeply nested code; it just looks right to me. I don't try to claim it's "right". It's just really really hard for me to imagine staring at really wide indents all the time and processing it OK.

masher wrote:The editor I use converts tabs to spaces. I use 3 spaces per tab, and I don't have to work on anybody else's code, so it's alright....


Aaaugh! It's one of THEM! ;)

Arancaytar wrote:Seriously, if the editor takes care of auto-indentation anyway, there is no reason to use a character that doesn't even have a defined width.


You're missing the point. There is a perfectly good reason to use a character that doesn't have a defined width. That reason is: it doesn't have a defined width.

If two people are using this editor, and they want the indentation to be a different amount (and a quick survey of the thread indicates that this is very common), then if the editor has saved tabs to the underlying text file, it only has to adjust the tab stop used for the text control. If it has saved spaces, it has to apply heuristics and convert back and forth (if it doesn't convert both ways from a "reference", then the VCS will get polluted with whitespace changes, and it will also have to know who saved which version of the file in order to know how to convert the spaces). Then we notice that we simplify that code by letting the "reference" use 1 space indent, and actually letting that space be a different character from the spaces used for alignment (so that we don't need the fancy heuristics) - and gee, I wonder what character we'll pick?
Belial wrote:I once had a series of undocumented and nonstandardized subjective experiences that indicated that anecdotal data is biased and unreliable.
zahlman
 
Posts: 638
Joined: Wed Jan 30, 2008 5:15 pm UTC

Re: Tabs vs Spaces

Postby endolith » Tue Aug 26, 2008 3:19 pm UTC

Anpheus wrote:I don't understand why people are looking to technology to solve that question, when we've pretty well argued this, and the simplest solution is to change your bad habit and make a good one.


Riiiight...

So which of several conflicting "good habits" should we all adopt?
endolith
 
Posts: 224
Joined: Tue Jan 01, 2008 2:14 am UTC
Location: New York, NY

Re: Tabs vs Spaces

Postby Qoppa » Tue Aug 26, 2008 5:54 pm UTC

I use vim and have it set up to enter 4 spaces when I press tab. I hate it when my code looks like shit in another editor.
Code: Select all
_=0,w=-1,(*t)(int,int);a()??<char*p="[gd\
~/d~/\\b\x7F\177l*~/~djal{x}h!\005h";(++w
<033)?(putchar((*t)(w??(p:>,w?_:0XD)),a()
):0;%>O(x,l)??<_='['/7;{return!(x%(_-11))
?x??'l:x^(1+ ++l);}??>main(){t=&O;w=a();}
User avatar
Qoppa
 
Posts: 694
Joined: Sat Nov 24, 2007 9:32 pm UTC
Location: Yes.

Re: Tabs vs Spaces

Postby EvanED » Tue Aug 26, 2008 6:09 pm UTC

zahlman wrote:I am one of them. The people I really don't understand are the ones who want to make it three spaces. Apparently, the author of the forum software is one of them, considering how tabs are converted in code boxes here. :)
Three is silly, but the correct answer is 4. This is self-evident. ;-)

(I don't have a "good" reason for this, I just think it's hard to blur your eyes and get an overview of the code structure, or scroll quickly for a file looking for a particular pattern, with two. Eight I think quickly forces things too the right much. (Even with two levels of indent, you're using 8 more characters than 4; I tend to use longer function, class, and variable names, so I can eat through those 80 characters quickly. I also like lining up corresponding things on subsequent lines, which often "wastes" more space and also prevents line breaks.) So basically, 2 is too few, 8 is too wide. And 3 is an odd number. ;-) Four does have the problem that stuff lines up that I don't like: like the line following either an 'if' or a 'for', depending on whether you leave a space after the keyword, will line up with the contents of the parentheses.)
EvanED
 
Posts: 4126
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI

Re: Tabs vs Spaces

Postby enk » Wed Aug 27, 2008 12:56 am UTC

zahlman wrote:Vim has the nasty habit of using mixed tabs and spaces for alignment, even once you've convinced it to use tabs exclusively for indentation.


I have also been bugged by this so I decided to ask the mailinglist. The solution is simply :set copyindent
phlip wrote:Ha HA! Recycled emacs jokes.
User avatar
enk
 
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark

Re: Tabs vs Spaces

Postby Amnesiasoft » Wed Aug 27, 2008 5:30 am UTC

Qoppa wrote:I hate it when my code looks like shit in another editor.

You know why it looks bad? Because you are doing it WRONG! If you used tabs properly, it would look good in any editor.
User avatar
Amnesiasoft
 
Posts: 2575
Joined: Tue May 15, 2007 4:28 am UTC
Location: Colorado

Re: Tabs vs Spaces

Postby Qoppa » Thu Aug 28, 2008 1:12 am UTC

Well no. Sometimes I mix tabs and spaces. For example
Code: Select all
while (x == 1 && y == 2 && z == 3 && w == 4 // ... lots of variables
       somethingelse == 'x') // 1 tab and 3 spaces

As opposed to
Code: Select all
while (x == 1 && y == 2 && z == 3 && w == 4 // ...
    somethingelse == 'x') // 1 tab
// or
while (x == 1 && y == 2 && z == 3 && w == 4 // ...
        somethingelse == 'x') // 2 tabs
Code: Select all
_=0,w=-1,(*t)(int,int);a()??<char*p="[gd\
~/d~/\\b\x7F\177l*~/~djal{x}h!\005h";(++w
<033)?(putchar((*t)(w??(p:>,w?_:0XD)),a()
):0;%>O(x,l)??<_='['/7;{return!(x%(_-11))
?x??'l:x^(1+ ++l);}??>main(){t=&O;w=a();}
User avatar
Qoppa
 
Posts: 694
Joined: Sat Nov 24, 2007 9:32 pm UTC
Location: Yes.

Re: Tabs vs Spaces

Postby Anpheus » Thu Aug 28, 2008 1:16 am UTC

Why is this topic still here? This is so simple.

Tabs and spaces done right will look good in any editor in any monospaced font.
Code: Select all
if (x... &&
____y || z...


See how that lines up? Those are spaces, four spaces always lines up with four other monospaced characters.

Code: Select all
-tab->if (x... &&
-tab->____y || z...


Still lines up with tabs of equivalent to 6 spaces.

Code: Select all
-tabtab-tab-tab-tabtabtabtab--tabtab->if (x... &&
-tabtab-tab-tab-tabtabtabtab--tabtab->____y || z...


Still lines up whether you use one tab or a dozen tabs of varying spaces as long as they're uniformly applied.


As everyone else has said, for the love of god, tabs for indentation, spaces for alignment, everyone will be happy and your code will look pretty.
Spoiler:
Code: Select all
  /###\_________/###\
  |#################|
  \#################/
   |##┌         ┐##|
   |##  (¯`v´¯)  ##|
   |##  `\ ♥ /´  ##|
   |##   `\¸/´   ##|
   |##└         ┘##|
  /#################\
  |#################|
  \###/¯¯¯¯¯¯¯¯¯\###/
User avatar
Anpheus
I can't get any worse, can I?
 
Posts: 860
Joined: Fri Nov 16, 2007 10:38 pm UTC
Location: A privileged frame of reference.

Re: Tabs vs Spaces

Postby EvanED » Thu Aug 28, 2008 2:23 am UTC

Qoppa wrote:Well no. Sometimes I mix tabs and spaces. For example
Code: Select all
while (x == 1 && y == 2 && z == 3 && w == 4 // ... lots of variables
       somethingelse == 'x') // 1 tab and 3 spaces

As opposed to

This is probably exactly the wrong way to mix tabs and spaces... if someone changes the tab stop to 8, your code now looks like
Code: Select all
while (x==1 ...
           somethingelse == 'x')
or with a tab-width of two characters,
Code: Select all
while (x==1 ...
     somethingelse == 'x')

In both cases, the "something else" is no longer aligned with the x==1. It's this sort of thing that cause a lot of people to say that you shouldn't use tabs because changing the indent size can mess up the code.
EvanED
 
Posts: 4126
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI

Re: Tabs vs Spaces

Postby masher » Thu Aug 28, 2008 2:33 am UTC

zahlman wrote:
masher wrote:The editor I use converts tabs to spaces. I use 3 spaces per tab, and I don't have to work on anybody else's code, so it's alright....


Aaaugh! It's one of THEM! ;)


I have changed. I still use 3 spaces, but I don't convert tabs.

I use tabs for indenting and spaces for alignment.
masher
 
Posts: 822
Joined: Tue Oct 23, 2007 11:07 pm UTC
Location: Melbourne, Australia

Re: Tabs vs Spaces

Postby Qoppa » Thu Aug 28, 2008 3:00 am UTC

EvanED wrote:
Qoppa wrote:Well no. Sometimes I mix tabs and spaces. For example
Code: Select all
while (x == 1 && y == 2 && z == 3 && w == 4 // ... lots of variables
       somethingelse == 'x') // 1 tab and 3 spaces

As opposed to

This is probably exactly the wrong way to mix tabs and spaces... if someone changes the tab stop to 8, your code now looks like...
Except when I press tab, 4 spaces are inserted. So it's going to be 7 spaces, 0 tabs in any editor. But I still press tab, which is why I'm saying tab... Using only spaces (which is what I do) is no doubt the safest route to go.
Last edited by Qoppa on Thu Aug 28, 2008 3:01 am UTC, edited 1 time in total.
Code: Select all
_=0,w=-1,(*t)(int,int);a()??<char*p="[gd\
~/d~/\\b\x7F\177l*~/~djal{x}h!\005h";(++w
<033)?(putchar((*t)(w??(p:>,w?_:0XD)),a()
):0;%>O(x,l)??<_='['/7;{return!(x%(_-11))
?x??'l:x^(1+ ++l);}??>main(){t=&O;w=a();}
User avatar
Qoppa
 
Posts: 694
Joined: Sat Nov 24, 2007 9:32 pm UTC
Location: Yes.

Re: Tabs vs Spaces

Postby Anpheus » Thu Aug 28, 2008 3:01 am UTC

Those aren't tabs then, that's your editor using spaces instead of tabs.

Which is just going to annoy other developers who have their own preferences on how wide a tab should be.
Spoiler:
Code: Select all
  /###\_________/###\
  |#################|
  \#################/
   |##┌         ┐##|
   |##  (¯`v´¯)  ##|
   |##  `\ ♥ /´  ##|
   |##   `\¸/´   ##|
   |##└         ┘##|
  /#################\
  |#################|
  \###/¯¯¯¯¯¯¯¯¯\###/
User avatar
Anpheus
I can't get any worse, can I?
 
Posts: 860
Joined: Fri Nov 16, 2007 10:38 pm UTC
Location: A privileged frame of reference.

Re: Tabs vs Spaces

Postby Qoppa » Thu Aug 28, 2008 3:02 am UTC

Anpheus wrote:Which is just going to annoy other developers who have their own preferences on how wide a tab should be.
It's my code damnit! If I want one tab to be four spaces, then dag nabbit, one tab will be four spaces.

:P
Code: Select all
_=0,w=-1,(*t)(int,int);a()??<char*p="[gd\
~/d~/\\b\x7F\177l*~/~djal{x}h!\005h";(++w
<033)?(putchar((*t)(w??(p:>,w?_:0XD)),a()
):0;%>O(x,l)??<_='['/7;{return!(x%(_-11))
?x??'l:x^(1+ ++l);}??>main(){t=&O;w=a();}
User avatar
Qoppa
 
Posts: 694
Joined: Sat Nov 24, 2007 9:32 pm UTC
Location: Yes.

Re: Tabs vs Spaces

Postby Anpheus » Thu Aug 28, 2008 3:03 am UTC

It's not a tab though, you've got spaces there.
Spoiler:
Code: Select all
  /###\_________/###\
  |#################|
  \#################/
   |##┌         ┐##|
   |##  (¯`v´¯)  ##|
   |##  `\ ♥ /´  ##|
   |##   `\¸/´   ##|
   |##└         ┘##|
  /#################\
  |#################|
  \###/¯¯¯¯¯¯¯¯¯\###/
User avatar
Anpheus
I can't get any worse, can I?
 
Posts: 860
Joined: Fri Nov 16, 2007 10:38 pm UTC
Location: A privileged frame of reference.

Re: Tabs vs Spaces

Postby Qoppa » Thu Aug 28, 2008 3:04 am UTC

Anpheus wrote:It's not a tab though, you've got spaces there.
Yes, and? I'm using the word tab to refer to an indent. It's a tad ambiguous, I know...
Code: Select all
_=0,w=-1,(*t)(int,int);a()??<char*p="[gd\
~/d~/\\b\x7F\177l*~/~djal{x}h!\005h";(++w
<033)?(putchar((*t)(w??(p:>,w?_:0XD)),a()
):0;%>O(x,l)??<_='['/7;{return!(x%(_-11))
?x??'l:x^(1+ ++l);}??>main(){t=&O;w=a();}
User avatar
Qoppa
 
Posts: 694
Joined: Sat Nov 24, 2007 9:32 pm UTC
Location: Yes.

Re: Tabs vs Spaces

Postby Anpheus » Thu Aug 28, 2008 3:08 am UTC

This is religious wars and the topic is "Tabs vs Spaces," so if you want to argue about what is and is not a tab, this is the right place.

But I think back when character codes were standardized, tabs and spaces weer decreed to be different things and assigned different codes. :)
Spoiler:
Code: Select all
  /###\_________/###\
  |#################|
  \#################/
   |##┌         ┐##|
   |##  (¯`v´¯)  ##|
   |##  `\ ♥ /´  ##|
   |##   `\¸/´   ##|
   |##└         ┘##|
  /#################\
  |#################|
  \###/¯¯¯¯¯¯¯¯¯\###/
User avatar
Anpheus
I can't get any worse, can I?
 
Posts: 860
Joined: Fri Nov 16, 2007 10:38 pm UTC
Location: A privileged frame of reference.

Re: Tabs vs Spaces

Postby Qoppa » Thu Aug 28, 2008 3:10 am UTC

In that case, let me reword my previous statement.

I use only spaces. Nothing else. Tabs are for squares.
Code: Select all
_=0,w=-1,(*t)(int,int);a()??<char*p="[gd\
~/d~/\\b\x7F\177l*~/~djal{x}h!\005h";(++w
<033)?(putchar((*t)(w??(p:>,w?_:0XD)),a()
):0;%>O(x,l)??<_='['/7;{return!(x%(_-11))
?x??'l:x^(1+ ++l);}??>main(){t=&O;w=a();}
User avatar
Qoppa
 
Posts: 694
Joined: Sat Nov 24, 2007 9:32 pm UTC
Location: Yes.

Re: Tabs vs Spaces

Postby headprogrammingczar » Thu Aug 28, 2008 12:53 pm UTC

I use Eclipse and the first thing I do with an opened file is press ctrl+shift+f. HAHA! :D
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you
User avatar
headprogrammingczar
 
Posts: 3024
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: Tabs vs Spaces

Postby Berengal » Thu Aug 28, 2008 2:08 pm UTC

headprogrammingczar wrote:I use Eclipse and the first thing I do with an opened file is press ctrl+shift+f. HAHA! :D

Ditto. The only problem is with read-only files, which eclipse won't even write to in the text buffer. This causes a problem with the java stl, as it contains mixed tabs and spaces everywhere. Sometimes it's a tab, sometimes four spaces, sometimes eight spaces... It's horrible, and the indentation makes no sense for any tab width.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.
User avatar
Berengal
Superabacus Mystic of the First Rank
 
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway

Re: Tabs vs Spaces

Postby sakeniwefu » Fri Aug 29, 2008 9:03 am UTC

Do you realize the amount of bytes you are wasting using spaces in place of tabs!? By a conservative estimate, a mean average of 6 extra useless bytes per line! You could even be doing multi-line conditions and function calls and putting spaces between expressions. What's next, comments?
What do you think you are coding in, Visual Basic? It's C, people, it's supposed to be unreadable, we only use tabs because code looks cooler that way, but that's as far as artistic licenses go.
sakeniwefu
 
Posts: 168
Joined: Sun May 11, 2008 8:36 pm UTC

Re: Tabs vs Spaces

Postby Anpheus » Fri Aug 29, 2008 9:04 am UTC

Your argument might have been valid back when my great grandparents had to etch bits into stone tablets in Sanskrit, but today you can buy billions of bits for less than a dollar.
Spoiler:
Code: Select all
  /###\_________/###\
  |#################|
  \#################/
   |##┌         ┐##|
   |##  (¯`v´¯)  ##|
   |##  `\ ♥ /´  ##|
   |##   `\¸/´   ##|
   |##└         ┘##|
  /#################\
  |#################|
  \###/¯¯¯¯¯¯¯¯¯\###/
User avatar
Anpheus
I can't get any worse, can I?
 
Posts: 860
Joined: Fri Nov 16, 2007 10:38 pm UTC
Location: A privileged frame of reference.

Re: Tabs vs Spaces

Postby EvanED » Sat Aug 30, 2008 9:10 am UTC

I'm pretty sure that was sarcasm ;-)
EvanED
 
Posts: 4126
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI

Re: Tabs vs Spaces

Postby Anpheus » Sat Aug 30, 2008 2:21 pm UTC

And my great grandparents really did write code on stone tablets :)
Spoiler:
Code: Select all
  /###\_________/###\
  |#################|
  \#################/
   |##┌         ┐##|
   |##  (¯`v´¯)  ##|
   |##  `\ ♥ /´  ##|
   |##   `\¸/´   ##|
   |##└         ┘##|
  /#################\
  |#################|
  \###/¯¯¯¯¯¯¯¯¯\###/
User avatar
Anpheus
I can't get any worse, can I?
 
Posts: 860
Joined: Fri Nov 16, 2007 10:38 pm UTC
Location: A privileged frame of reference.

Re: Tabs vs Spaces

Postby Wiglaf » Mon Sep 01, 2008 10:34 pm UTC

I still have the "my precious cycles! my precious bits!" reflex.
I guess its because the counter-argument is terrible: "Oh, because we have big mighty computers, go ahead and waste resources instead of searching for the elegant solution." Have they considered, perhaps, that a lot of little waste stacked up == big waste?

(on-topic "So my vote is in with tabs. But really, who would use an editor that can't auto format according to good indenting practice?")
Wiglaf
 
Posts: 79
Joined: Sun Feb 10, 2008 8:54 pm UTC

Re: Tabs vs Spaces

Postby Berengal » Tue Sep 02, 2008 3:02 am UTC

Sometimes the elegant solution is one wasting time and space. Of course, the elegance of it might in turn save you time and space elsewhere.

What I'm trying to say is that I've seen python programs run as fast as their c equivalents, because they weren't bogged down by poor algorithms caused by the programmers lack of overview
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.
User avatar
Berengal
Superabacus Mystic of the First Rank
 
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway

Re: Tabs vs Spaces

Postby GameFreak » Fri Feb 20, 2009 2:03 am UTC

Spaces make my delete key bleed.
Windows: Life without walls.
In a world without walls or fences, nobody would need windows or gates.


Xsera is coming!
User avatar
GameFreak
 
Posts: 18
Joined: Thu Oct 09, 2008 8:01 pm UTC
Location: Internet

Re: Tabs vs Spaces

Postby hotaru » Fri Feb 20, 2009 2:33 am UTC

GameFreak wrote:Spaces make my delete key bleed.

then perhaps you should get a better editor.
Code: Select all
uint8_t f(uint8_t n)
{ if (!(
n&1)) return 2;
  if (
n==169) return 13; if (n==121||n==143) return 11;
  if (
n==77||n==91) return 7; if (n==3||n==5) return 0;
  
n=(n>>4)+(n&0xF); n+=n>>4n&=0xF;
  return (
n==3||n==6||n==9||n==12||n==15)?3:(n==5||n==10)?5:0; } 
User avatar
hotaru
 
Posts: 949
Joined: Fri Apr 13, 2007 6:54 pm UTC

Re: Tabs vs Spaces

Postby GameFreak » Wed Feb 25, 2009 11:02 pm UTC

hotaru wrote:
GameFreak wrote:Spaces make my delete key bleed.

then perhaps you should get a better editor.

I mean when I have to make changes without an ide.
Windows: Life without walls.
In a world without walls or fences, nobody would need windows or gates.


Xsera is coming!
User avatar
GameFreak
 
Posts: 18
Joined: Thu Oct 09, 2008 8:01 pm UTC
Location: Internet

Re: Tabs vs Spaces

Postby hotaru » Thu Feb 26, 2009 2:10 am UTC

GameFreak wrote:
hotaru wrote:
GameFreak wrote:Spaces make my delete key bleed.

then perhaps you should get a better editor.

I mean when I have to make changes without an ide.

ed, se, vi, etc.
Code: Select all
uint8_t f(uint8_t n)
{ if (!(
n&1)) return 2;
  if (
n==169) return 13; if (n==121||n==143) return 11;
  if (
n==77||n==91) return 7; if (n==3||n==5) return 0;
  
n=(n>>4)+(n&0xF); n+=n>>4n&=0xF;
  return (
n==3||n==6||n==9||n==12||n==15)?3:(n==5||n==10)?5:0; } 
User avatar
hotaru
 
Posts: 949
Joined: Fri Apr 13, 2007 6:54 pm UTC

Re: Tabs vs Spaces

Postby TheOrangeMan » Mon Mar 23, 2009 12:12 am UTC

I'm kind of in the middle about this one. I like the idea of tabs better conceptually, but I often end up wanting to align things a little more precisely, so I usually end up using spaces to avoid mixing the two.
Science is like math turned inside out.
User avatar
TheOrangeMan
 
Posts: 25
Joined: Wed Feb 27, 2008 4:29 am UTC
Location: Directlly above you... IN THE FOURTH DIMENSION :O

Re: Tabs vs Spaces

Postby MHD » Thu Apr 30, 2009 9:17 pm UTC

1 press on the tab key = 4 spaces.

PERIOD!
EvanED wrote:be aware that when most people say "regular expression" they really mean "something that is almost, but not quite, entirely unlike a regular expression"
User avatar
MHD
 
Posts: 631
Joined: Fri Mar 20, 2009 8:21 pm UTC
Location: Denmark

Re: Tabs vs Spaces

Postby enk » Tue May 12, 2009 3:59 pm UTC

I usually prefer my tabs to be tabs, four spaces wide. But when I started writing some assembly, regular old-school eight space tabs came in handy:

Code: Select all
get_input:
        leal    -8(%ebp), %eax
        pushl   %eax
        pushl   $formatstring
        call    scanf
        addl    $8, %esp



Btw. the Google C++ style guide says use two spaces per indent level (may be connected with their 80 char line limit). Who does that, besides Google?
phlip wrote:Ha HA! Recycled emacs jokes.
User avatar
enk
 
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark

Re: Tabs vs Spaces

Postby stephentyrone » Tue May 12, 2009 4:30 pm UTC

enk wrote:Btw. the Google C++ style guide says use two spaces per indent level (may be connected with their 80 char line limit). Who does that, besides Google?


I used to. It comes in handy if you're writing a lot of spaghetti code (not sure what this says about Google).
GENERATION -16 + 31i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.
stephentyrone
 
Posts: 779
Joined: Mon Aug 11, 2008 10:58 pm UTC
Location: Palo Alto, CA

Re: Tabs vs Spaces

Postby ash.gti » Tue May 12, 2009 4:31 pm UTC

I do, I have soft tabs that are 2 wide. No reason to waste space.

for me
Code: Select all
def a b, c, e, f
  if e
    s = f - e
  else
    s = f
  end
  b - c
end


isn't that different from
Code: Select all
def a b, c, e, f
    if e
        s = f - e
    else
        s = f
    end
    b - c
end


I don't need 8/4 spaces for each tab, thats just wasted space I could be filling with more code.
# drinks WAY to much espresso
User avatar
ash.gti
 
Posts: 404
Joined: Thu Feb 07, 2008 1:18 am UTC
Location: Probably a coffee shop.

Re: Tabs vs Spaces

Postby enk » Tue May 12, 2009 9:04 pm UTC

ash.gti wrote:I don't need 8/4 spaces for each tab, thats just wasted space I could be filling with more code.


But sometimes when you have more consecutive lines per level than in your example, you need a bigger offset to properly disinguish them, I find.
phlip wrote:Ha HA! Recycled emacs jokes.
User avatar
enk
 
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark

Re: Tabs vs Spaces

Postby ash.gti » Tue May 12, 2009 9:48 pm UTC

So do you mean like when you run into

Code: Select all
def foo(bar):
  fooz = bar
  barz = fooz
  barz(fooz)
  another
  another
  if 1:
    another
    another
    another


vs

Code: Select all
def foo(bar):
    fooz = bar
    barz = fooz
    barz(fooz)
    another
    another
    if 1:
        another
        another
        another
# drinks WAY to much espresso
User avatar
ash.gti
 
Posts: 404
Joined: Thu Feb 07, 2008 1:18 am UTC
Location: Probably a coffee shop.

Re: Tabs vs Spaces

Postby enk » Tue May 12, 2009 10:42 pm UTC

ash.gti wrote:So do you mean like when you run into [...]


Yeah.. I tried many sizes (even wrote a vim function to set an arbitrary size from 1 to 8 at a single keypress) but always returned to four as the best compromise.
phlip wrote:Ha HA! Recycled emacs jokes.
User avatar
enk
 
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark

PreviousNext

Return to Religious Wars

Who is online

Users browsing this forum: No registered users and 4 guests