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. Tabs, Spaces, 2 column widths, 4 column widths, oh my...

Tabs, Spaces, 2 column widths, 4 column widths, oh my...

Scheduled Pinned Locked Moved The Lounge
csharpc++javascriptrubysysadmin
42 Posts 23 Posters 0 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.
  • J Jeremy Falcon

    Now you know, we as nerds just love a good debate. And clearly, everyone who doesn't agree with us is intellectually inferior by substantial margins. And no other topic, save a few, has this proven to more evident than in the tabs versus spaces great debate of our generation. Now, rather than fan the flame of that saga, I'm curious to know what people still prefer for tab width (regardless of an actual tab char or if it's spaces). For years, I've always been a four column guy with tab widths. I mean years. Anything else was stupid and bunches together what would otherwise be beautiful code. But then I started doing a lot of JavaScript development where the popular thing is to use two column widths. Ruby seems to embrace that too. It's ugly I thought. I shan't cave in. It's immoral and just wrong. But in being a team player you go along with what must be done for the sake of the project. Now, a couple years later. I look at four column tab width code and think "well gee that's just too damn wide." I still don't like two column width. Looks like the code is still in kiddy land when I see that. I started doing some plug-in development for a Forex trading platform a few years back. It's a proprietary language and by default it uses 3 column widths in the code editor for it. At first I was like "ok wtf." But after years of using that proprietary language... turns out 3 column width is perfect! You can use it everywhere. C#, C/C++, JavaScript. Whatever, it's a nice compromise for everyone. In this day and age where we are expected to learn 20 million things, both client and server, rather than just one language, I tend to find myself using this more and more so I don't have to readjust my eyes to differently spaced code all day long. Only problem is... nobody else uses 3 column widths that I know of. So, I'm curious to know, what do y'all use still and why?

    Jeremy Falcon

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

    4, with Visual Studio set to insert spaces. VS has been broken since VC6 when it comes to block indent/undent when you use a mix of tabs and spaces at the beginning of a line. If VS is set to insert tabs, on a block operation they convert leading spaces to tabs, and screw up the alignment :mad:.

    Software Zen: delete this;

    J 1 Reply Last reply
    0
    • J Jeremy Falcon

      Now you know, we as nerds just love a good debate. And clearly, everyone who doesn't agree with us is intellectually inferior by substantial margins. And no other topic, save a few, has this proven to more evident than in the tabs versus spaces great debate of our generation. Now, rather than fan the flame of that saga, I'm curious to know what people still prefer for tab width (regardless of an actual tab char or if it's spaces). For years, I've always been a four column guy with tab widths. I mean years. Anything else was stupid and bunches together what would otherwise be beautiful code. But then I started doing a lot of JavaScript development where the popular thing is to use two column widths. Ruby seems to embrace that too. It's ugly I thought. I shan't cave in. It's immoral and just wrong. But in being a team player you go along with what must be done for the sake of the project. Now, a couple years later. I look at four column tab width code and think "well gee that's just too damn wide." I still don't like two column width. Looks like the code is still in kiddy land when I see that. I started doing some plug-in development for a Forex trading platform a few years back. It's a proprietary language and by default it uses 3 column widths in the code editor for it. At first I was like "ok wtf." But after years of using that proprietary language... turns out 3 column width is perfect! You can use it everywhere. C#, C/C++, JavaScript. Whatever, it's a nice compromise for everyone. In this day and age where we are expected to learn 20 million things, both client and server, rather than just one language, I tend to find myself using this more and more so I don't have to readjust my eyes to differently spaced code all day long. Only problem is... nobody else uses 3 column widths that I know of. So, I'm curious to know, what do y'all use still and why?

      Jeremy Falcon

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #34

      But then again... Here's how I indent DCL (Digital Command Language) on OpenVMS. The VT100 emulator I use doesn't allow control over the TAB stops, so it's always eight columns and that's far too many. So I use one TAB after the leading dollar sign ($) to make a nice margin so my comments and labels stand out. Then it's a one-SPACE indent for THEN, ELSE, and ENDIF and a two-SPACE indent for statements inside those. A snippet from my DCL implementation of a Turing Machine:

      $! Run the Machine
      $
      $ offset = 0
      $loop2:
      $ input = f$extract(offset,1,p2)
      $ if f$type(TM_'state'_'input') .eqs. "" then goto eoloop2
      $
      $ output = f$element(2,",",TM_'state'_'input')
      $ move = f$element(3,",",TM_'state'_'input')
      $ state = f$element(4,",",TM_'state'_'input')
      $
      $ p2['offset',1] := 'output'
      $
      $ if move .eqs. "-"
      $ then
      $ if offset .eq. 0
      $ then p2 = "_" + p2
      $ else offset = offset - 1
      $ endif
      $ else
      $ offset = offset + 1
      $ if offset .eq. f$length(p2) then p2 = p2 + "_"
      $ endif
      $
      $ goto loop2
      $eoloop2:
      $
      $ write sys$output p2
      $
      $ goto end

      :cool:

      1 Reply Last reply
      0
      • G Gary Wheeler

        4, with Visual Studio set to insert spaces. VS has been broken since VC6 when it comes to block indent/undent when you use a mix of tabs and spaces at the beginning of a line. If VS is set to insert tabs, on a block operation they convert leading spaces to tabs, and screw up the alignment :mad:.

        Software Zen: delete this;

        J Offline
        J Offline
        Jeremy Falcon
        wrote on last edited by
        #35

        It'll be ok Gary... just think about fluffy kittens. :laugh:

        Jeremy Falcon

        G 1 Reply Last reply
        0
        • D Daniel Pfeffer

          I've used so many differing styles (usually mandated by anal-retentive bosses) that today I just go with whatever (a) the company requires, or (b) the IDE inserts as a default. The only problem with using tabs as a formatting mechanism is when reading code in a different editor, whose tab setting differs. Your nicely (and carefully) formatted code then looks like a formatting disaster. :sigh:

          If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #36

          Daniel Pfeffer wrote:

          usually mandated by anal-retentive bosses

          :laugh: Amen to that brother.

          Daniel Pfeffer wrote:

          The only problem with using tabs as a formatting mechanism is when reading code in a different editor, whose tab setting differs. Your nicely (and carefully) formatted code then looks like a formatting disaster.

          That's the same exact reason I swapped to spaces. Especially in web development where you just know your code will be different machines that don't always have VS installed, etc.

          Jeremy Falcon

          1 Reply Last reply
          0
          • J Joan M

            Now with wide displays is not as important, but 2 spaces (using tab) is good as it is not very space consuming but at the same time is clear enough to see the desired effect. And of course this doesn't allow any debate. I'm right. Anyone thinking a different thing must be burnt in fire. :rolleyes:

            www.robotecnik.com[^] - robots, CNC and PLC programming

            J Offline
            J Offline
            Jeremy Falcon
            wrote on last edited by
            #37

            Joan M wrote:

            And of course this doesn't allow any debate. I'm right. Anyone thinking a different thing must be burnt in fire.

            That's a good point Joan. I'm not sure why I didn't think of that before. :doh: :-D

            Jeremy Falcon

            1 Reply Last reply
            0
            • J Jeremy Falcon

              It'll be ok Gary... just think about fluffy kittens. :laugh:

              Jeremy Falcon

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

              My fluffy kitten (ok, she's 15 years old and surly) could do a better job than MS on this.

              Software Zen: delete this;

              1 Reply Last reply
              0
              • J Jeremy Falcon

                Now you know, we as nerds just love a good debate. And clearly, everyone who doesn't agree with us is intellectually inferior by substantial margins. And no other topic, save a few, has this proven to more evident than in the tabs versus spaces great debate of our generation. Now, rather than fan the flame of that saga, I'm curious to know what people still prefer for tab width (regardless of an actual tab char or if it's spaces). For years, I've always been a four column guy with tab widths. I mean years. Anything else was stupid and bunches together what would otherwise be beautiful code. But then I started doing a lot of JavaScript development where the popular thing is to use two column widths. Ruby seems to embrace that too. It's ugly I thought. I shan't cave in. It's immoral and just wrong. But in being a team player you go along with what must be done for the sake of the project. Now, a couple years later. I look at four column tab width code and think "well gee that's just too damn wide." I still don't like two column width. Looks like the code is still in kiddy land when I see that. I started doing some plug-in development for a Forex trading platform a few years back. It's a proprietary language and by default it uses 3 column widths in the code editor for it. At first I was like "ok wtf." But after years of using that proprietary language... turns out 3 column width is perfect! You can use it everywhere. C#, C/C++, JavaScript. Whatever, it's a nice compromise for everyone. In this day and age where we are expected to learn 20 million things, both client and server, rather than just one language, I tend to find myself using this more and more so I don't have to readjust my eyes to differently spaced code all day long. Only problem is... nobody else uses 3 column widths that I know of. So, I'm curious to know, what do y'all use still and why?

                Jeremy Falcon

                S Offline
                S Offline
                Stuart Dootson
                wrote on last edited by
                #39

                I also use 3 columns, and have done forever (well, since I first programmed in Ada in the 90s!) The company I work for still has a standard of 3 columns for indentation...

                Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                1 Reply Last reply
                0
                • M Marco Bertschi

                  I go along with whatever the IDE inserts for me when I hit TAB. What I hate is when VS separates the start (<) and end (>) of generic parameters onto separate lines. I don't have a problem with method call chains or method parameters spanning multiple lines, but those generic parameters belong onto the same darn line!

                  I only have a signature in order to let @DalekDave follow my posts.

                  T Offline
                  T Offline
                  TonyManso
                  wrote on last edited by
                  #40

                  Marco Bertschi (SFC) wrote:

                  I go along with whatever the IDE inserts for me when I hit TAB.

                  I do the same thing, mostly to be consistent with my team. But...

                  if(i.haveUltimateSaySo) {
                  i.useTwoSpacesInsteadOfTabs();
                  i.putCurlyBraceAtEndOfIfLine();
                  i.useCurlyBracesOnEveryLoopOrConditional();
                  i.useCamelCase();
                  }

                  On the other hand, you have different fingers. - Steven Wright

                  1 Reply Last reply
                  0
                  • R R Giskard Reventlov

                    Meh! Chick Norris thinks in binary and writes in assembler. Everything he does is code.

                    F Offline
                    F Offline
                    Forogar
                    wrote on last edited by
                    #41

                    Quote:

                    Chick Norris

                    Is that Chuck Norris's sister?

                    - I would love to change the world, but they won’t give me the source code.

                    R 1 Reply Last reply
                    0
                    • F Forogar

                      Quote:

                      Chick Norris

                      Is that Chuck Norris's sister?

                      - I would love to change the world, but they won’t give me the source code.

                      R Offline
                      R Offline
                      R Giskard Reventlov
                      wrote on last edited by
                      #42

                      :laugh: :laugh: :laugh:

                      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