Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Indenting: spaces or tabs?

Indenting: spaces or tabs?

Scheduled Pinned Locked Moved The Lounge
visual-studiocomquestion
39 Posts 25 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Gary Wheeler

    Real programmers use EDLIN. (although the best programmer's editor was TECO on the DEC PDP-11 under RT-11)


    "Think of it as evolution in action." - 'Oath of Fealty' by Larry Niven and Jerry Pournelle

    B Offline
    B Offline
    brianwelsch
    wrote on last edited by
    #28

    Gary Wheeler wrote: Real programmers use EDLIN. no,nononono. REAL coders use punch cards. :rolleyes: BW {insert witty/thought-provoking saying here}

    G T 2 Replies Last reply
    0
    • B brianwelsch

      Gary Wheeler wrote: Real programmers use EDLIN. no,nononono. REAL coders use punch cards. :rolleyes: BW {insert witty/thought-provoking saying here}

      G Offline
      G Offline
      Gary Wheeler
      wrote on last edited by
      #29

      Been there, done that. When I took Data Structures in college, programming was on the IBM 370 mainframe, using punch cards. We had a guy in our class who was blind. This guy read the holes in the cards with his fingers. I helped him do a 'floor sort' one time; it was a good thing he liked sequence numbers in columns 73-80.


      "Think of it as evolution in action." - 'Oath of Fealty' by Larry Niven and Jerry Pournelle

      B 1 Reply Last reply
      0
      • L Luca Leonardo Scorcia

        A little survey about your code-indent style... what do you use? Spaces or tabs? I used to do a mix of tabs and spaces, but the code looked awful when edited with VS and then opened with notepad for a quick look. So I started using only spaces, but I noticed that for some files indentation made the file size grow a lot... now I'm using only tabs. I think that's the best way: any serious code editor can set the tab size to any number of space you want, code in notepad looks fine, and it's faster to type and files don't get too large. These are my 2 cents. And yours? Luca Leonardo Scorcia http://zip.to/kojak (only in Italian)

        M Offline
        M Offline
        Michael Mac
        wrote on last edited by
        #30

        I use tabs. :)


        43 68 65 65 72 73 2c 4d 69 63 68 61 65 6c

        1 Reply Last reply
        0
        • G Gary Wheeler

          Been there, done that. When I took Data Structures in college, programming was on the IBM 370 mainframe, using punch cards. We had a guy in our class who was blind. This guy read the holes in the cards with his fingers. I helped him do a 'floor sort' one time; it was a good thing he liked sequence numbers in columns 73-80.


          "Think of it as evolution in action." - 'Oath of Fealty' by Larry Niven and Jerry Pournelle

          B Offline
          B Offline
          brianwelsch
          wrote on last edited by
          #31

          Gary Wheeler wrote: We had a guy in our class who was blind. This guy read the holes in the cards with his fingers. :cool: Very impressive! I guess having used cards helps to appreciate the speed and convenience we have today. And to think I used to gripe about waiting for the cassette drive to finish loading. BW {insert witty/thought-provoking saying here}

          1 Reply Last reply
          0
          • L Luca Leonardo Scorcia

            A little survey about your code-indent style... what do you use? Spaces or tabs? I used to do a mix of tabs and spaces, but the code looked awful when edited with VS and then opened with notepad for a quick look. So I started using only spaces, but I noticed that for some files indentation made the file size grow a lot... now I'm using only tabs. I think that's the best way: any serious code editor can set the tab size to any number of space you want, code in notepad looks fine, and it's faster to type and files don't get too large. These are my 2 cents. And yours? Luca Leonardo Scorcia http://zip.to/kojak (only in Italian)

            J Offline
            J Offline
            Jason Gerard
            wrote on last edited by
            #32

            Tabs set to 4 spaces. Jason Gerard

            1 Reply Last reply
            0
            • _ _Magnus_

              I want to use tabs but have to use spaces, and it sucks.. X| With tabs everybody can have the tabwidth they want. If you want to delete the tab you just type you only have to press backspace once. Easier to reformat the code. I cant see a single advantage with using spaces. /Magnus


              - I don't necessarily agree with everything I say

              T Offline
              T Offline
              Tim Lesher
              wrote on last edited by
              #33

              I cant see a single advantage with using spaces. Because if you have your tabs set differently from me, any indentation other than the beginning-of-line, one-tab indentation gets screwed up. It's mostly a problem when you use end-of-line comments, aligned variable initializations, or indentation for the definition of long functions, all shown below:

              sometype_t CSomeClass::SomeRandomFunction(footype_t arg1,
              footype_t arg2)
              {
              somestruct_t thing;
              thing.a = -1;
              thing.longerName = 10;
              thing.evenLongerName = 5;

              doSomething();              // And explain why
              doSomethingElse();          // And explain that, too
              doSomethingWithALongName(); // And this one, too
              

              }

              The arguments won't line up if you use tabs at a different width than me, but they will line up if you use spaces. And the argument that spaces take up more disk space than tabs? Geez, what a non-starter! With 80GB hard drives costing less than US$79, what's the point? Do you also use i, j, k, and l for variable names to save space?! ;-) Tim Lesher http://www.lesher.ws

              _ 1 Reply Last reply
              0
              • B brianwelsch

                Gary Wheeler wrote: Real programmers use EDLIN. no,nononono. REAL coders use punch cards. :rolleyes: BW {insert witty/thought-provoking saying here}

                T Offline
                T Offline
                Tim Lesher
                wrote on last edited by
                #34

                REAL coders use punch cards. And REAL coders who won't/can't adapt are on the dole. ;-) Tim Lesher http://www.lesher.ws

                1 Reply Last reply
                0
                • T Tim Lesher

                  I cant see a single advantage with using spaces. Because if you have your tabs set differently from me, any indentation other than the beginning-of-line, one-tab indentation gets screwed up. It's mostly a problem when you use end-of-line comments, aligned variable initializations, or indentation for the definition of long functions, all shown below:

                  sometype_t CSomeClass::SomeRandomFunction(footype_t arg1,
                  footype_t arg2)
                  {
                  somestruct_t thing;
                  thing.a = -1;
                  thing.longerName = 10;
                  thing.evenLongerName = 5;

                  doSomething();              // And explain why
                  doSomethingElse();          // And explain that, too
                  doSomethingWithALongName(); // And this one, too
                  

                  }

                  The arguments won't line up if you use tabs at a different width than me, but they will line up if you use spaces. And the argument that spaces take up more disk space than tabs? Geez, what a non-starter! With 80GB hard drives costing less than US$79, what's the point? Do you also use i, j, k, and l for variable names to save space?! ;-) Tim Lesher http://www.lesher.ws

                  _ Offline
                  _ Offline
                  _Magnus_
                  wrote on last edited by
                  #35

                  Tim Lesher wrote: The arguments won't line up if you use tabs at a different width than me, but they will line up if you use spaces But there is no problem pressing the space key even if the tabkey produces *drumroll* tabs. :) So this arugment does not hold. Tim Lesher wrote: And the argument that spaces take up more disk space than tabs? Geez, what a non-starter! With 80GB hard drives costing less than US$79, what's the point? Do you also use i, j, k, and l for variable names to save space?! Where did you get that from? I never said that, and i never would say so..... /Magnus


                  - I don't necessarily agree with everything I say

                  T 1 Reply Last reply
                  0
                  • T Tim Lesher

                    Spaces at four; whitesmith (Microsoft)-style indenting

                    int func()
                    {
                    for (int i=0; i< 4; ++i)
                    {
                    // Like This
                    ;
                    }
                    return 0; // With no parens around the zero, dammit!
                    }

                    Tim Lesher http://www.lesher.ws

                    T Offline
                    T Offline
                    Tim Lesher
                    wrote on last edited by
                    #36

                    Bah... article thread view appears to get rid of initial spacing. Tim Lesher http://www.lesher.ws

                    1 Reply Last reply
                    0
                    • L Luca Leonardo Scorcia

                      A little survey about your code-indent style... what do you use? Spaces or tabs? I used to do a mix of tabs and spaces, but the code looked awful when edited with VS and then opened with notepad for a quick look. So I started using only spaces, but I noticed that for some files indentation made the file size grow a lot... now I'm using only tabs. I think that's the best way: any serious code editor can set the tab size to any number of space you want, code in notepad looks fine, and it's faster to type and files don't get too large. These are my 2 cents. And yours? Luca Leonardo Scorcia http://zip.to/kojak (only in Italian)

                      T Offline
                      T Offline
                      Tim Lesher
                      wrote on last edited by
                      #37

                      Spaces at four; whitesmith (Microsoft)-style indenting

                      int func()
                      {
                      for (int i=0; i< 4; ++i)
                      {
                      // Like This
                      ;
                      }
                      return 0; // With no parens around the zero, dammit!
                      }

                      Tim Lesher http://www.lesher.ws

                      T M 2 Replies Last reply
                      0
                      • _ _Magnus_

                        Tim Lesher wrote: The arguments won't line up if you use tabs at a different width than me, but they will line up if you use spaces But there is no problem pressing the space key even if the tabkey produces *drumroll* tabs. :) So this arugment does not hold. Tim Lesher wrote: And the argument that spaces take up more disk space than tabs? Geez, what a non-starter! With 80GB hard drives costing less than US$79, what's the point? Do you also use i, j, k, and l for variable names to save space?! Where did you get that from? I never said that, and i never would say so..... /Magnus


                        - I don't necessarily agree with everything I say

                        T Offline
                        T Offline
                        Tim Lesher
                        wrote on last edited by
                        #38

                        But there is no problem pressing the space key even if the tabkey produces *drumroll* tabs. Correct, but Dev Studio auto-indents the arguments for you, and if you have tabs as your default, it uses a mixture of spaces and tabs. Of course, the error may be relying on Dev Studio's auto indent. It also butchers long for statements if you break after each semicolon. And the argument that spaces take up more disk space than tabs? Geez, what a non-starter! Where did you get that from? I never said that, and i never would say so..... You didn't, but it was mentioned in the thread, and I couldn't be bothered to go back and put it after the right response... :-) Tim Lesher http://www.lesher.ws

                        1 Reply Last reply
                        0
                        • T Tim Lesher

                          Spaces at four; whitesmith (Microsoft)-style indenting

                          int func()
                          {
                          for (int i=0; i< 4; ++i)
                          {
                          // Like This
                          ;
                          }
                          return 0; // With no parens around the zero, dammit!
                          }

                          Tim Lesher http://www.lesher.ws

                          M Offline
                          M Offline
                          Mike Nordell
                          wrote on last edited by
                          #39

                          Tim Lesher wrote: return 0; // With no parens around the zero, dammit! Obviously not, "return" isn't a function call, is it?! :-)

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups