View Poll Results: To TAB or not to TAB (Code Indentation)

Voters
44. You may not vote on this poll
  • Use Tabs

    25 56.82%
  • Use Spaces

    19 43.18%

To TAB or not to TAB...

This is a discussion on To TAB or not to TAB... within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations ...

  1. #16
    Deleted Account
    Join Date
    Jan 2004
    Posts
    40
    Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

    Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you've been looking at your screen for 20 straight hours, you'll find it a lot easier to see how the indentation works if you have large indentations.

    Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.

    In short, 8-char indents make things easier to read, and have the added benefit of warning you when you're nesting your functions too deep. Heed that warning.

  2. #17
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by Brian2
    Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

    Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you've been looking at your screen for 20 straight hours, you'll find it a lot easier to see how the indentation works if you have large indentations.

    Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.

    In short, 8-char indents make things easier to read, and have the added benefit of warning you when you're nesting your functions too deep. Heed that warning.
    haha, I really hope that was a joke.

  3. #18
    Deleted Account
    Join Date
    Jan 2004
    Posts
    40
    haha, I really hope that was a joke.
    http://pantransit.reptiles.org/prog/CodingStyle.html

  4. #19
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    *shudders*

    I'm so glad I don't follow that convention

  5. #20
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    I have auto indent set to 4 spaces, but also have TAB converted to spaces. It is easier to cut and paste into html documents like that.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #21
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    Tab here... why would you use spaces? More keystrokes, have to keep track of how many... just tab it. *BAM* or *BAM BAM* and everything is lined up.

  7. #22
    Nosepicker DrakkenKorin's Avatar
    Join Date
    Nov 2001
    Posts
    407
    you poll lacks an "other" option.

    I neither tab nor space. I indent.

    ::lifting nose higher and higher...::
    DrakkenKorin

    Get off my Intarweb!!!!

  8. #23
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> ::lifting nose higher and higher...::

    Is that a bogie I see up there?

    Ober:

    >>> Tab here... why would you use spaces?

    You press Tab as normal, but you tell your IDE that when you press TAB it is to inesert 4 spaces. Thus no additional keystrokes are required, and no fiddling about is needed if you cut and paste a bit of code into another IDE or into NotePad for example.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  9. #24
    Nosepicker DrakkenKorin's Avatar
    Join Date
    Nov 2001
    Posts
    407
    >>Is that a bogie I see up there?<<

    NO, ITS PIERCED!
    DrakkenKorin

    Get off my Intarweb!!!!

  10. #25
    Registered User BillBoeBaggins's Avatar
    Join Date
    Oct 2003
    Posts
    107
    DrakkenKorin:
    .................... "other"?
    Polymorphic OOP:
    I didn't know that option existed (space replace tab thingy), but I don't use VC I only use Dev-C++.

    I try to use tabs, and I have my tab set to 4 spaces, but I don't want the extra job of making sure I hit the spacebar 4 times when I can hit the TAB once. But yes, maybe I will make a cpp process script that converts TAB's to 4 Spaces in the file.

  11. #26
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    More keystrokes, have to keep track of how many
    VIM does it for me. I find two spaces much easier to read.

    Tabs are 8 characters
    IIRC tabs are actually 5 characters, its been that way since the days of typewriters. Set your word processor to a fixed width font and try it out. Its 5 characters. So the arguement that it is 8 characters and not 4, 2, 12, or pi is bull$$$$.

  12. #27
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    Originally posted by BillBoeBaggins
    DrakkenKorin:
    .................... "other"?
    Polymorphic OOP:
    I didn't know that option existed (space replace tab thingy), but I don't use VC I only use Dev-C++.

    I try to use tabs, and I have my tab set to 4 spaces, but I don't want the extra job of making sure I hit the spacebar 4 times when I can hit the TAB once. But yes, maybe I will make a cpp process script that converts TAB's to 4 Spaces in the file.
    Dev-C++ should also have that option.

  13. #28
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    I use five spaces.

  14. #29
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Three spaces with the tab-to-space feature (which also allows shift-tab).

  15. #30
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    I use tabs. I know the problems associated with them, but they look better to me, and are easier to get rid of / add. Who's gonna read MY code, anyway ?
    Do not make direct eye contact with me.

Page 2 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tab Ordering of GUI Controls
    By cloudy in forum Windows Programming
    Replies: 2
    Last Post: 04-22-2006, 09:13 AM
  2. Tab order in Tab Control
    By Halloko in forum Windows Programming
    Replies: 2
    Last Post: 05-08-2005, 11:08 PM
  3. Visual C++
    By Golffor1 in forum C++ Programming
    Replies: 1
    Last Post: 08-04-2003, 04:30 PM
  4. Disable a tab in control tab?
    By Iron Mike in forum Windows Programming
    Replies: 1
    Last Post: 07-23-2003, 10:50 AM
  5. Tab controls - MFC (revived)
    By Robert602 in forum Windows Programming
    Replies: 1
    Last Post: 01-22-2002, 11:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21