• 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!

Reply to: Spaces or Tabs

Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Spaces or Tabs"

Collapse

  • voodooflux
    replied
    Originally posted by TimberWolf View Post
    Because it improves readability, maintainability clarity... A curly brace on the same line makes a hideous mess of the code, so why do it? The first thing I do when I have to read code looking like that is to structure it properly. Not doing so just makes deciphering it unnecessarily difficult.
    WHS

    Originally posted by NickFitz View Post
    I had this discussion with somebody at a client a few years ago. I ended it by saying "Fine, you do it that way; I'll do it the right way."
    I have a similar running "jest" with a friend of mine, albeit his/your way are obviously the wrong way

    Leave a comment:


  • TimberWolf
    replied
    Originally posted by NickFitz View Post
    Ugh - why on a new line?
    Because it improves readability, maintainability clarity... A curly brace on the same line makes a hideous mess of the code, so why do it? The first thing I do when I have to read code looking like that is to structure it properly. Not doing so just makes deciphering it unnecessarily difficult.

    I had this discussion with somebody at a client a few years ago. I ended it by saying "Fine, you do it that way; I'll do it the right way."
    Amateur

    You'd really prefer something hideous looking such as:

    Code:
    for(i = 0; i < 10; i++) {
         if(i % 2 == 0) {
             doSomething(i);         
             doSomethingelse(i); 
             etc; }}
    over :
    Code:
    for (i = 0; i < 10; i++) 
    {
        if (i % 2 == 0) 
        {
             doSomething(i); 
             doSomethingelse(i); 
             etc;
        }
    }

    Leave a comment:


  • Bob Dalek
    replied
    Config files or none. That is the question. (for piddly little 10-line scripts).

    Leave a comment:


  • expat
    replied
    Originally posted by Spacecadet View Post
    New line means its easier to visually match a } with a {
    Most important is the vertical alignment.

    Not that I ever program anything anymore that needs braces round blocks of code
    Well, no. But I don't mind telling the kids where they're going wrong

    Leave a comment:


  • Spacecadet
    replied
    Originally posted by NickFitz View Post
    Ugh - why on a new line?

    I had this discussion with somebody at a client a few years ago. I ended it by saying "Fine, you do it that way; I'll do it the right way."
    New line means its easier to visually match a } with a {

    Not that I ever program anything anymore that needs braces round blocks of code

    Leave a comment:


  • expat
    replied
    Originally posted by zeitghost
    Edlin doesn't.

    HTH.

    Neither does vi (though I always hesitate to state anything about UNIX because there is always some smarterarse...). I use vi for the same reason as I once used edlin: at least you know it will be on any machine you use.

    PS I just verified that by opening a DOs window and running edlin here. How do you get out of entry mode?

    Leave a comment:


  • Cowboy Bob
    replied
    Anyone who voted tabs deserves their next job to be remotely hotfixing code via ssh and vi. Anyone who's done such a thing will know how evil tabs are and that those who use them should burn in hell.

    Same thing applies to those who put curly braces on the same line and not on a new line, and for the same reason. Screw Sun and their coding standards, Gosling obviously never loaded a file into vi with lines wrapping all over the place and tried to work out what code was part of what loop.

    Leave a comment:


  • NickFitz
    replied
    Originally posted by TimberWolf View Post
    No, the saddest thread ever would be whether to put the first curly brace on the same line as the start of the block of statements <shudder> or on a fresh line.
    Ugh - why on a new line?

    I had this discussion with somebody at a client a few years ago. I ended it by saying "Fine, you do it that way; I'll do it the right way."

    Leave a comment:


  • Spacecadet
    replied
    Originally posted by TimberWolf View Post
    No, the saddest thread ever would be whether to put the first curly brace on the same line as the start of the block of statements <shudder> or on a fresh line.
    always a fresh line!!!
    someone needs to make a poll

    Leave a comment:


  • TimberWolf
    replied
    Originally posted by TazMaN View Post
    This is the saddest thread ever.
    No, the saddest thread ever would be whether to put the first curly brace on the same line as the start of the block of statements <shudder> or on a fresh line.

    Leave a comment:


  • OwlHoot
    replied
    Originally posted by bogeyman View Post
    .. 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?
    Tabs are evil. Anyone who puts them into source code (when not expanded automatically to spaces) will find their soul sealed in a bottle and cast down into the deepest pit of hell, there to remain in torment for all eternity next to Judas Iscariot, Brutus, and the guy who decided to use tabs in the Unix "make" utility ...

    HTH

    Leave a comment:


  • ChimpMaster
    replied
    This is the saddest thread ever.

    Leave a comment:


  • EternalOptimist
    replied
    luckily the guy whose code I am maintaining used neither, so I don't have to worry.

    the steaming pillock



    Leave a comment:


  • bogeyman
    replied
    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

    Leave a comment:


  • NickFitz
    replied
    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.

    Leave a comment:

Working...
X