• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Spaces or Tabs

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    Originally posted by NotAllThere View Post
    I though all modern code editors did all the indenting rubbish for you. Even the SAP one does.
    most not all

    and then sometimes you're not using a code editor to edit code
    Coffee's for closers

    Comment


      #12
      Originally posted by Spacecadet View Post
      most not all

      and then sometimes you're not using a code editor to edit code
      And, annoyingly, some do it with tabs by default!

      I use ultraedit for windows, and vi for UNIX, just because it's so much fun to work with.
      Best Forum Advisor 2014
      Work in the public sector? You can read my FAQ here
      Click here to get 15% off your first year's IPSE membership

      Comment


        #13
        Originally posted by NotAllThere View Post
        I though all modern code editors did all the indenting rubbish for you. Even the SAP one does.
        So, when it does the indenting, does it use spaces or tabs?

        I always set things up to use spaces for portability. There always comes the day when you're forced to look at something in an old editor that uses 8 spaces per tab, just like a typewriter fresh from the factory.

        As for the number of spaces to indent: for C-style languages (Java, JavaScript, C#, PHP and so forth) I use four spaces; the same for CSS and SQL.

        In Python I know a lot of people who prefer two spaces, but the last time I was on a team using it we agreed that it was best to adhere to PEP 8 and go for four there as well.

        One interesting case came up when we - or rather, Norm - were establishing coding standards for the various languages in use at Yahoo! Although most languages were to be indented with four spaces, he argued that for HTML it should be two spaces, for the simple reason that HTML is often deeply nested, and otherwise much sideways scrolling would result. Others argued that four was more readable, and that the deep nesting issue was ameliorated by the fact that much of what we did involved template fragments which were put together by the framework, rather than complete HTML pages.

        The discussion over that one continued for quite some time - as in several days...

        Comment


          #14
          Originally posted by NickFitz View Post
          So, when it does the indenting, does it use spaces or tabs?

          I always set things up to use spaces for portability. There always comes the day when you're forced to look at something in an old editor that uses 8 spaces per tab, just like a typewriter fresh from the factory.

          As for the number of spaces to indent: for C-style languages (Java, JavaScript, C#, PHP and so forth) I use four spaces; the same for CSS and SQL.

          In Python I know a lot of people who prefer two spaces, but the last time I was on a team using it we agreed that it was best to adhere to PEP 8 and go for four there as well.

          One interesting case came up when we - or rather, Norm - were establishing coding standards for the various languages in use at Yahoo! Although most languages were to be indented with four spaces, he argued that for HTML it should be two spaces, for the simple reason that HTML is often deeply nested, and otherwise much sideways scrolling would result. Others argued that four was more readable, and that the deep nesting issue was ameliorated by the fact that much of what we did involved template fragments which were put together by the framework, rather than complete HTML pages.

          The discussion over that one continued for quite some time - as in several days...
          Why does HTML need to be deeply nested?

          Surely the days of nested-table hell are behind us, and who codes long screeds of markup these days anyway, now that it's mostly spat out in modular chunks by the backend platform/language of your choice?

          Anyway. Sod portability. Tabs are the way to go for indenting.

          If you want to convert tabs to 4/5/6... spaces then any editor (or grep) can do that for you.

          Why add white-space bloat to the source code?

          You've come right out the other side of the forest of irony and ended up in the desert of wrong.

          Comment


            #15
            spaces

            Comment


              #16
              Originally posted by BrilloPad View Post
              spaces
              Careful now, you'll wear out your space bar with your tappity-tap-tapping when you're in the 5th level do loop.

              If you find you are deeply indenting, then you are probably doing it wrong anyway.

              I recommend reading "Code Complete" by Steve McConnell if you don't know why deep nesting is bad. It's an oldie but a goodie - as relevant as ever.

              You've come right out the other side of the forest of irony and ended up in the desert of wrong.

              Comment


                #17
                Oh sweet Jesus - massive flashback to my Cobol programming days as a civil servant....

                "YOU MUST ALIGN YOUR "TO'S"!!!!
                "YOU MUST ALIGN YOUR "TO'S"!!!!
                "YOU MUST ALIGN YOUR "TO'S"!!!!
                "YOU MUST ALIGN YOUR "TO'S"!!!!

                <shudder>
                The pope is a tard.

                Comment


                  #18
                  Originally posted by bogeyman View Post
                  Why does HTML need to be deeply nested?

                  Surely the days of nested-table hell are behind us, and who codes long screeds of markup these days anyway, now that it's mostly spat out in modular chunks by the backend platform/language of your choice?

                  Anyway. Sod portability. Tabs are the way to go for indenting.

                  If you want to convert tabs to 4/5/6... spaces then any editor (or grep) can do that for you.

                  Why add white-space bloat to the source code?
                  Actually, I think the reason Norm suggested that was just to stir things up a bit - he deliberately added a few things to the coding standards (which were exhaustive) that he knew were contentious, justifying them with arguments that might make some sense but weren't really good enough, simply to get people discussing things - a very effective technique, as it turned out

                  He said as much to me a couple of days later when I called him on the idea of using single-quotes around attribute values, which was such a contentious issue that one senior developer threatened to resign over it before Norm finally admitted that it was a wind-up

                  As for whitespace in source code: assuming we're referring to stuff sent over the wire like HTML, JS and CSS (as it doesn't matter for things like C which are just sitting in source control), such whitespace is effectively eliminated by gzip compression, and you should be using that to send stuff over the wire anyway - the performance improvement is much better than anything you might get from chopping out spaces.

                  The purpose of these coding standards is to ensure that things are consistent, as that improves maintainability, particularly in an environment where people are allowed to follow their own choice of editor and so forth. If, two years from now, somebody revisits the comment template for Yahoo! Answers, they shouldn't have to be bothered about which editor it was last edited in and what the tab settings were, nor should they have to spend time changing it to their preferred style or reconfiguring their editor, and so forth - all files should be formatted consistently. It doesn't really matter if it's with two, three or eight spaces, as long as everybody does it the same way.

                  Comment


                    #19
                    Originally posted by NickFitz View Post
                    Actually, I think the reason Norm suggested that was just to stir things up a bit - he deliberately added a few things to the coding standards (which were exhaustive) that he knew were contentious, justifying them with arguments that might make some sense but weren't really good enough, simply to get people discussing things - a very effective technique, as it turned out

                    He said as much to me a couple of days later when I called him on the idea of using single-quotes around attribute values, which was such a contentious issue that one senior developer threatened to resign over it before Norm finally admitted that it was a wind-up

                    As for whitespace in source code: assuming we're referring to stuff sent over the wire like HTML, JS and CSS (as it doesn't matter for things like C which are just sitting in source control), such whitespace is effectively eliminated by gzip compression, and you should be using that to send stuff over the wire anyway - the performance improvement is much better than anything you might get from chopping out spaces.

                    The purpose of these coding standards is to ensure that things are consistent, as that improves maintainability, particularly in an environment where people are allowed to follow their own choice of editor and so forth. If, two years from now, somebody revisits the comment template for Yahoo! Answers, they shouldn't have to be bothered about which editor it was last edited in and what the tab settings were, nor should they have to spend time changing it to their preferred style or reconfiguring their editor, and so forth - all files should be formatted consistently. It doesn't really matter if it's with two, three or eight spaces, as long as everybody does it the same way.
                    I know what you mean Nick. Done my share of sitting in meetings discussing standards for code and other things. Contentious and off-the-wall suggestions often enliven the discussion but rarely bring about consensus in my experience.

                    Anyhow. The Bogey Standard says use tabs for indent, because one \t == one level of logical indentation.

                    Two, three or any other multiple of spaces does not equal one logical level of indentation without a constant divisor.

                    So there

                    You've come right out the other side of the forest of irony and ended up in the desert of wrong.

                    Comment


                      #20
                      luckily the guy whose code I am maintaining used neither, so I don't have to worry.

                      the steaming pillock



                      (\__/)
                      (>'.'<)
                      ("")("") Born to Drink. Forced to Work

                      Comment

                      Working...
                      X