Slashdot Mirror


Does Coding Style Matter?

theodp writes "Over at Smashing Magazine, Nicholas C. Zakas makes the case for Why Coding Style Matters. 'Coding style guides are an important part of writing code as a professional,' Zakas concludes. 'Whether you're writing JavaScript or CSS or any other language, deciding how your code should look is an important part of overall code quality. If you don't already have a style guide for your team or project, it's worth the time to start one.' So, how are coding style guidelines working (or not) in your world?"

479 comments

  1. It's easy with an IDE by tirerim · · Score: 5, Insightful

    At my workplace, we just all plug the same code style settings into our IDEs, and everyone's code gets formatted the same way automatically. And yes, it matters: having everyone's code formatted the same way makes it much easier to read.

    1. Re:It's easy with an IDE by Anonymous Coward · · Score: 5, Informative

      ... and it makes version control diffs shorter and to the point.

    2. Re:It's easy with an IDE by Anonymous Coward · · Score: 1

      Coding style is much more than code formating, e.g. naming rules, allowed language features, length limitations ...

      I don't know about other industries but the automotive industry has a standardized coding style for its embedded systems called MISRA C to ensure safety, reliability and portability.

    3. Re:It's easy with an IDE by PhrostyMcByte · · Score: 1

      Intent/line breaks/spacing styles that IDEs can do aren't all that matters though. Simply knowing when to put a blank line in can make all the difference in code readability, but i haven't seen any IDEs smart enough to do that.

    4. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      First post is about an IDE but doesn't mention Visual Studio. Is this a feature V.S. is missing?

    5. Re:It's easy with an IDE by JabberWokky · · Score: 1

      JetBrains IDEs allow you to do that... I can't imagine that most don't have context rules for adding blank lines.

      --
      "$30 for the One True Ring. $10 each additional ring!" -- JRR "Bob" Tolkien
    6. Re:It's easy with an IDE by sribe · · Score: 5, Insightful

      ... and it makes version control diffs shorter and to the point.

      ...and makes global search and replace easier, because you can more often use plain strings, rather than having to construct a regex.

    7. Re:It's easy with an IDE by Derekloffin · · Score: 3, Insightful

      I would say, white space rules are definitely important, but not the only style stuff that may be important. Standard variable naming conventions can also greatly help, as can keeping certain common code structure being all done in the same manner. Both of these can make it much easier to find things. The question is where is the point where standard style starts to become more an exercise in keeping to the style rather than getting the work done.

    8. Re:It's easy with an IDE by StormReaver · · Score: 2

      That's along the lines what I was thinking (but not exactly). A good IDE makes coding styles far less important than they use to be. I can load someone's horrendous looking K&R styled code, hit the "reformat" keyboard shortcut, and have readable code as a result.

      Coding style only matters if you're not using a decent IDE.

    9. Re:It's easy with an IDE by chengiz · · Score: 1

      So you make everyone use an IDE instead of their favourite editor? Sounds dictatorial to me.

    10. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      wtf
      Who uses global search and replace these days?

    11. Re:It's easy with an IDE by sribe · · Score: 4, Insightful

      Sounds like pandering to the lowest-common denominator.
      Why don't you switch to programming in VB while you're at it?

      Bullshit. If I want to search for every time that a certain condition is evaluated, I should be able to search for "if (foo.bar ==", not "if\s*\(\s*foo\.bar\s*=="

      Wait? Is that even right? Can = be used without escaping when it is outside of a capture or a positional assertion???

    12. Re:It's easy with an IDE by robthebloke · · Score: 4, Insightful

      Why don't you try managing a large scale programming project with hundreds of developers, rather than 2 or 3? A large project has developers of all abilities, from recent grads, all the way up to seasoned pro's. In that enviornment, pandering to lowest common denominator is a good thing. For example, a coding convention that bans complicated C++ meta-template programming techniques, helps to extract the maximum from recent grads, by making sure they don't have to read 'Modern C++ Design' cover to cover 7 times before making their first commit (and that also applies to R&D folks who have PHd's in maths/physics, yet would struggle to write their own linked list template). Remove variation in programming style from the equation, and large projects suddenly start moving forward at a much faster pace. You can argue against that if you want, it just marks you out as a terrible team member, and a terribly inexperienced software developer. My 2 cents.....

    13. Re:It's easy with an IDE by obarel · · Score: 1

      MIRSA C does not contain any naming conventions. It only recommends that you have a style guide that includes a naming convention.

      It doesn't cost much, and well worth the read, even if you don't agree with every point.

    14. Re:It's easy with an IDE by obarel · · Score: 1

      MISRA C, not MIRSA C (clearly...)

    15. Re:It's easy with an IDE by Anonymous Coward · · Score: 4, Insightful

      That's silly. You let the experts in your team write the "complicated C++ meta-template programming techniques" and the mediocre programmers use them. That's the point of C++-templating: Make it easy for the users of the code. It's incredible what kind of extremely convenient libraries can be written by template wizards.

      Gladly the next standard will also make it easier to write, see "static_if" proposal.

    16. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      that's a funny one. If you are going to dictate how they write the code, why not dictate what they write it in?

    17. Re:It's easy with an IDE by Dr_Barnowl · · Score: 4, Interesting

      Having a consistent style means that you don't end up in the situation we are, where we have several patches that are probably a days work to merge with the main line, not because our patches are large, but because some bonehead decided it would be good to run an automated code reformatter on his source tree.

      This not only reformatted everything to a style that no-one else on the project uses, but re-sorted all the fields and methods in the source files affected. This made everyone elses copy of the source conflict violently with essentially every change made in the reformatted files, giving everyone else the headache of re-implementing their patches.

      Peoples edits continue to make the format of these files a mess because they are indented in a way that's inconsistent with the source.

      Alas, we can't undo these patches because the bonehead is the lead developer. But catering to prima-donnas means more work for everyone else.

    18. Re:It's easy with an IDE by Emetophobe · · Score: 2

      Eclipse can do it. You can setup a formatting style and then have it auto-format on save or do it manually with Ctrl+Shift+F.

      Here's a screenshoft.

    19. Re:It's easy with an IDE by WaywardGeek · · Score: 3, Interesting

      It all comes down from the guy in charge. I've set the coding style at two of the last three companies I've worked for, and while new guys may not like it, it does promote effective teamwork. It's a lot more than just indentation. We use the same data structure styles, iterator styles, and everything from start to finish. It can be very difficult to determine who wrote any given piece of code, and a git-blame shows that it's a patchwork quilt with everyone contributing all over the place.

      The guy who I will say is now the lead developer of our main software suite writes code that looks exactly like mine. We've even on occasion wrote entire functions, in the same place, which were identical down to the last character, even in the obligatory comment. No git conflict in that case. At the other company, there literally were no coding style guidelines, and the result is no one was able or willing to easily edit anyone else's code. That makes it very difficult to move people around to projects that need them most.

      There are a ton of developers out there who are loners. It's a field that attracts geeks who are somewhat social-phobic. I've never seen programmers voluntarily adopt a common coding style. It's more fun to fiddle around on your own. So, instead of working together as a team to solve real problems rapidly, individual programmers go off in different directions, learning more about different ways to write code than actually writing code.

      --
      Celebrate failure, and then learn from it - Nolan Bushnell
    20. Re:It's easy with an IDE by Dr_Barnowl · · Score: 3, Insightful

      .. and then you commit your changes and everyone wants to kill you. You just broke all their patches.

      There have been various proposals for an IDE that stores the sources as a raw format that has no formatting, and you apply the formatting in the view, but they obviously have the disadvantage of not working with a plain text editor, needing a special IDE, probably a special version control system as well.

    21. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      There's always one of you guys isn't there?

    22. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      This would require you all to use the same IDE, or one of a set you've ported your code style settings to, which is not unlikely to be harder than deciding on a common code style.

    23. Re:It's easy with an IDE by Carewolf · · Score: 4, Funny

      Coding style has one function and one function only: To keep the Aspergers productive. For normally functioning people, any coding style is as good as any other (in other words anything that isn't a mess), but for Aspergers it is important it is consistant and strictly enforced, otherwise they will complain loudly and start arguing over which style is better (as evidence I present every thread in this story).

      After enforcing strict coding style only one more thing is important to keep the Aspergers productive: Never mention or talk about coding style, and forbid anybody from ever bringing it up. If it is brought up, nothing will get done that day.

    24. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      Depends on the regex(p) syntax used. For example, sometimes you need to escape parentheses while in another syntax you do not. Some varieties of regexp don't even have \s and \S to denote whitespace and non-whitespace characters respectively. Furthermore, what qualifies as whitespace depends on the regexp. For something like sed, I'm fairly certain it conforms strictly to the POSIX specification regarding what constitutes a spacing character, which is a horizontal tab (0x09), a line feed (0x0A), a vertical tab (0x0B), a form feed (0x0C), a carriage return (0x0D) and a literal space character (0x20). For something like JavaScript, it is probably any character matching a code point that is a part of whatever the spacing character class is in the Unicode standard. Some don't have things like a \b (word boundary) and its complement \B or use different notations for it. Simply put, regexps can be difficult, especially when handling multiple forms.

    25. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      Blank lines are a good indication that two things you're putting in the same function are unrelated and you should probably put them into separate functions.

    26. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      This is like saying architectures should be monolithic applications without tiers or DLL's or web services because otherwise it's complexity not best suited to neophytes. You have the architects design the architecture, and the senior devs worry about understanding it and giving compartmentalized pieces to the junior devs so that they don't have to. IOW, you're doing it wrong.

    27. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      Lead developer here. You're fired. Please use your severance check to buy some tampons for your bleeding vag.

    28. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      Does that advice also apply to C#? Why or why not?

    29. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      P.s. And FFS don't let scientists and mathematicians touch production code. Their proper role is to provide the formulas and domain knowledge to the devs, not to know good software engineering practices, especially medium to large scale. http://developers.slashdot.org/story/12/09/20/2015204/why-non-coders-shouldnt-write-code

    30. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      The guy who I will say is now the lead developer of our main software suite writes code that looks exactly like mine. We've even on occasion wrote entire functions, in the same place, which were identical down to the last character, even in the obligatory comment.

      So why did you duplicate the work? You view this as acceptable? Ever hear of code re-use?

      I wouldn't want to write code like you.

    31. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      Agree fully. But the mediocre programmers still have to figure out the resulting error messages :)

    32. Re:It's easy with an IDE by stanlyb · · Score: 2

      I have seen it how it works. At the end, no one but the author of all these templates knows what the code is doing, how to use it, and how not to use it. So go ahead, if you wanna to have unmaintainable code, use as much "templates" as possible.

    33. Re:It's easy with an IDE by stanlyb · · Score: 2

      I am usually the guy with his own coding style, but after witnessing some code without any code styling at all, man, now i am just happy to have one standard for everyone, even if it says "use tabs, not spaces" :)
      And btw, only idiot would use tabs instead of spaces, 3 spaces actually :P

    34. Re:It's easy with an IDE by stanlyb · · Score: 1

      Actually it is very sane document, and i wonder why it is not widespread for the "normal" systems too....

    35. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      If your group can happily agree on a standard, I have no problem with agreeing on one. But that does not mean that a machine can automatically format code in the best possible way. Consider the problem of splitting a long statement over multiple lines of text. One might want to put the line breaks in places where they facilitate readability and reflect some logic or motivation (perhaps grouping related terms by line) that is not explicitly expressed by the raw meaning of the code. It is possible for a communicative human to express more in code than is contemplated in a programming language's definition.

      More important than adherence to a standard is that the programmer reading the code gets the idea that the programmer who wrote it, quite likely a co-worker and/or collaborator, did so thoughtfully and considerately.

    36. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      It all comes down from the guy in charge. I've set the coding style at two of the last three companies I've worked for, and while new guys may not like it, it does promote effective teamwork. It's a lot more than just indentation. We use the same data structure styles, iterator styles, and everything from start to finish. It can be very difficult to determine who wrote any given piece of code, and a git-blame shows that it's a patchwork quilt with everyone contributing all over the place.

      The guy who I will say is now the lead developer of our main software suite writes code that looks exactly like mine. We've even on occasion wrote entire functions, in the same place, which were identical down to the last character, even in the obligatory comment. No git conflict in that case. At the other company, there literally were no coding style guidelines, and the result is no one was able or willing to easily edit anyone else's code. That makes it very difficult to move people around to projects that need them most.

      There are a ton of developers out there who are loners. It's a field that attracts geeks who are somewhat social-phobic. I've never seen programmers voluntarily adopt a common coding style. It's more fun to fiddle around on your own. So, instead of working together as a team to solve real problems rapidly, individual programmers go off in different directions, learning more about different ways to write code than actually writing code.

      where can an AC find a copy of your coding style spec.?

    37. Re:It's easy with an IDE by robthebloke · · Score: 2
      Once again..... Try managing a large scale project of a few hundred developers, rather than 2 or 3.

      You let the experts in your team write the "complicated C++ meta-template programming techniques"

      No, No, and No again! What you are suggesting is nothing more than compartmentalising a team such that programmer A owns that bit of code, and programmer B owns that bit of code. It's nothing more than an artifical barrier for less experienced members of the team, designed to prevent them making small commits to address any bugs they may find. It makes it much harder to distribute the workload evenly between team members, and ensures that the senior devs spend all day programming, rather than spending time advising and guiding the junior team members.

      That's the point of C++-templating: Make it easy for the users of the code.

      There is a big difference between programming with templates (e.g. using a container, or templated method), and meta-template programming (e.g. using TypeLists et-al, as a form of functional programing, but with a syntax that is far harder to understand & maintain than say, haskell).

      C++ templates make life easier for the users of the code, if and only if, it is 100% bug free, and 100% feature complete. If there are bugs, junior devs may be the ones who end up having to debug it. I'd rather they were able to fix the problem themselves, rather than having to utilise a senior devs time (who may be involved in more important things, which may cause a delay in getting the bug fixed). Now you may say "Ahh, well, you should be writing unit tests! Bad developer!". I'd counter that by saying that time constraints often get in the way of unit tests, and on occasion you will encounter bugs which you'd never have been able to foresee (which makes writing a unit test beforehand very difficult indeed). More often than not, this is usually the result of a new feature being added to the template, which has some subtle side effects to other aspects of it's usage, and the origal tests haven't been expanded accordingly.

    38. Re:It's easy with an IDE by FalseModesty · · Score: 1

      Because the former is less of a burden than the latter?

    39. Re:It's easy with an IDE by 21mhz · · Score: 1

      For example, a coding convention that bans complicated C++ meta-template programming techniques, helps to extract the maximum from recent grads, by making sure they don't have to read 'Modern C++ Design' cover to cover 7 times before making their first commit (and that also applies to R&D folks who have PHd's in maths/physics, yet would struggle to write their own linked list template).

      That's a good reason alone, but really, banning meta-template shit like Boost and STL helps to extract greater efficiency across the board. Your ABIs can stay manageable, your binaries do not get more bloat than what you put there on purpose. Choose a good base library such as Qt, it will save you more time in the long run.

      --
      My exception safety is -fno-exceptions.
    40. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      That's a good reason alone, but really, banning meta-template shit like Boost and STL helps to extract greater efficiency across the board. Your ABIs can stay manageable, your binaries do not get more bloat than what you put there on purpose. Choose a good base library such as Qt, it will save you more time in the long run.

      Qt relies heavily on templates and even more on code generation - offering Qt as a clean solution is ... special.

    41. Re:It's easy with an IDE by 21mhz · · Score: 1

      Ironically, using template metaprogramming shit actually hampers effective use of dynamic linkage. When using it in libraries, you have to painstakingly maintain a separation between internally used templates and library APIs that should not expose template classes not designed for such use, like proper thin templates are. Templates, for purposes of an ABI, are clouds of lexical tokens producing weakly linked instantiations that litter multiple binaries and are subject to constant change. So you end up doing things like bridging your templated types with opaque accessors used in the public API. And then some noob goes and leaks a list iterator into the public function signatures, thus exposing an implementation detail, and other noobs start using it from other modules, so your library is broken.

      --
      My exception safety is -fno-exceptions.
    42. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      Clearly search boxes need a "ignore whitespace" and maybe "ignore punctuation" check boxes as well as "ignore case" which they already have.

    43. Re:It's easy with an IDE by maxwell+demon · · Score: 1

      I'd say the correct solution would be to have code search in addition to textual search. The IDE should know by itself that if (a == b) means the same as if( a==b ) or even if /* for some strange reason */ ( /the variable named */ a /* happens to be */ == /* yeah, you guessed it */ b /* oh, really? */).

      --
      The Tao of math: The numbers you can count are not the real numbers.
    44. Re:It's easy with an IDE by maxwell+demon · · Score: 1

      Agree fully. But the mediocre programmers still have to figure out the resulting error messages :)

      Yeah, it's a shame that concepts didn't make it into C++11. That would finally have allowed sane error messages for templates.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    45. Re:It's easy with an IDE by gbjbaanb · · Score: 1

      why stop there? If you're worried some members of the team won't be able to understand someone else's code... then let them all write in Visual Basic, just to be sure.

    46. Re:It's easy with an IDE by dkf · · Score: 1

      Wait? Is that even right? Can = be used without escaping when it is outside of a capture or a positional assertion???

      If it's POSIX REs, yes. PCRE, mostly (except for a few spots where the = is really part of a multi-character token). Other flavors, who knows?

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    47. Re:It's easy with an IDE by dkf · · Score: 1

      And btw, only idiot would use tabs instead of spaces, 3 spaces actually :P

      An indent of 3 works really well for blog postings (or academic papers), where you've usually got to keep lines really short, but in production code the most common indent across lots of languages seems to be 4. (This is independent of the space/tab "debate".)

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    48. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      Thanks for this. I think the crazy aspergers syndrome explanation explains a lot. I looked into creating some sort of coding guidelines several years ago and did a bit of research on what others had created. 80% of the people care about stupid crap like you're mentioning, "style". Where people put braces or indentation was just SOOOOO not the problem though, but people acted like it was. At the time I never thought this was just simply another crazy aspect of the subset of autistic developers who can't get past

      After a bit more research I decided the only coding guidelines that made any sense were just simply value statements about what makes good code. I guess I must be pretty normal since as long as the code isn't a total mess, the style doesn't bother me. What's always bothered me is shitty code that's impossible to maintain.

    49. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      The code style settings in the IDE are extremely helpful. Otherwise, one or more persons on the team gets saddled down with the style enforcement task which is not pleasant for anyone -- and this is AFTER the team has fought the religious war that always precedes the settlement of the style rules/guidelines.

    50. Re:It's easy with an IDE by 21mhz · · Score: 1

      Qt's templates are designed to be lightweight and they are backed with a stable binary API. There are some exceptions, but most of Qt template classes are thin wrappers around library calls that implement the heavy lifting, rather than emitting everything in the compilation unit where the template is used.

      Code generation in Qt is actually very different from how C++ templates work: the moc runtime support code is emitted in strictly one place per each class. The meta-object data provide features that C++ was never designed to do: runtime type introspection that works, down to class members and their signatures.

      --
      My exception safety is -fno-exceptions.
    51. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      I'm working on setting coding style standards for our dev group, alongside an Aspie. So I LOL'ed at this.

      Fortunately, he's not very extreme on the spectrum, and we also both agree that the particulars are less important than consistency.

    52. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      > where we have several patches that are probably a days work to merge with the main line, not because our patches are large

      a) If you would make code changes in small parts, you would never have that kind of problem.

      b) Just format your own code using the same rules, before taking an update. Automerge should be able to take care of the rest. If automerge doesn't work, copy your files safe, update and revert source tree to clean state, copy your (formatted) changes on top of it, and you are back in the game.

      > because the bonehead is the lead developer

      It would have been smart of him to warn others beforehand. Unless obviously he wanted to teach you a lesson to commit code in small parts. Which is still not too late, if I can remind you. Just revert all your changes and start again, this time much smarter.

      Anyway, your selection of words tells me that you got a "people problem". A non-technical problem, which no-one ever wants to fix, also the worst kind of a problem that can ruin a project and happiness of people. Unfortunately I know only one solution to that: talking with the person who made you mad. If that doesn't work, consider if your people skills need improvement. There are many books written about the subject of how to talk with others, how to give negative feedback etc. If you are certain that the other person is just impossible to fix, gather evidence and talk to a manager.

    53. Re:It's easy with an IDE by gnasher719 · · Score: 1

      Having a consistent style means that you don't end up in the situation we are, where we have several patches that are probably a days work to merge with the main line, not because our patches are large, but because some bonehead decided it would be good to run an automated code reformatter on his source tree.

      Sorry, but that should be zero days work on your side. Let the bonehead do the merge, you review it before it is checked in, and if any of his formatting changes are there, you reject it.

    54. Re:It's easy with an IDE by Pseudonym · · Score: 1

      No, No, and No again! What you are suggesting is nothing more than compartmentalising a team such that programmer A owns that bit of code, and programmer B owns that bit of code.

      I didn't see the word "own" anywhere. Nobody has advocated a rule (explicit or tacit) which says "new programmers should not touch this".

      Any development environment worth working at, assuming it makes sense (e.g. if it's safety-critical, or classified) lets anyone check in anything. But it's understood that you touch that particular piece of code at your own risk, because that is the key piece of technology that makes us money.

      Anyone is encouraged to become the type of developer who can hack on that code. But it's unrealistic to expect that a new employee is automatically someone who can hack on that code. Hack on it if you like, but make sure you know how to back out changes first.

      Incidentally, where I work, I'm that guy. I'm the one who "owns" a key piece of money-maker code. It's only about 1500 lines, but it's the "inner loop" of the whole product line. It's ultra-performance-critical, dense, bit-twiddly, and computer-science-rich. Everyone knows how it works and what it does on a theoretical level, but I'm the only one who ever got their hands dirty in that particular bit of code.

      I don't actually want to "own" this particular code, but we have only three developers in total working on the product line, all of them senior. If we had some junior devs, I would absolutely spend the time getting them up to the point where they could handle it if they wanted it.

      There is a big difference between programming with templates (e.g. using a container, or templated method), and meta-template programming (e.g. using TypeLists et-al, as a form of functional programing, but with a syntax that is far harder to understand & maintain than say, haskell).

      And there's a continuum of possibilities between the two.

      To be fair, I suspect this is moot for almost everyone. About 95% of what you want in the way of advanced template hackery is already in Boost, and the remaining 5% probably isn't that advanced.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    55. Re:It's easy with an IDE by Pseudonym · · Score: 1

      That's a good reason alone, but really, banning meta-template shit like Boost and STL helps to extract greater efficiency across the board. Your ABIs can stay manageable, your binaries do not get more bloat than what you put there on purpose. Choose a good base library such as Qt, it will save you more time in the long run.

      For the sake of all that is holy, no!

      For the record, I have no problem with Qt. I like programming in Qt. But an awful lot of people don't realise until it's too late that you actually program "in" Qt, not "with" Qt.

      You can program in C++, or you can program in Qt. You can't do both without a performance-inhibiting layer of insulation. You'll find this out the hard way the first time you need to integrate with a third-party library which assumes that you're doing it the standard way.

      How many times have you seen this?

      QSomething* something = new QSomething();

      If you don't know why that line of code contains a bug, then you're a Qt programmer, not a C++ programmer. Though your tag line suggests that you do indeed know why it contains a bug, and you're still a Qt programmer.

      That's fine. I encourage you to program much cool and useful stuff in Qt, and I will happily use it. But not everyone has your job, and I need to use C++.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    56. Re:It's easy with an IDE by Pseudonym · · Score: 1

      I would imagine that they were written at the same time, because they needed the same functionality. If it's anything like the time I did it, the duplication was probably caught and fixed at check-in time.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    57. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      For the formatting aspect, where I worked last we had a rule which said "all code files shall be fed through astyle (with specified rules) before commit, what you do with your checked-out code is your business. Bug reports shall specify canonical line numbers."

      That doesn't resolve the question of naming conventions, but at least it deals with whitespace.

    58. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      Wait? Is that even right? Can = be used without escaping when it is outside of a capture or a positional assertion???

      Of course it can, idiot. What the hell are you doing in a programming job if you can't even remember the basic syntax of a tool you use every day?

    59. Re:It's easy with an IDE by 21mhz · · Score: 1

      How many times have you seen this?

      QSomething* something = new QSomething();

      If you don't know why that line of code contains a bug, then you're a Qt programmer, not a C++ programmer. Though your tag line suggests that you do indeed know why it contains a bug, and you're still a Qt programmer.

      I'm also a practical C++ programmer. I don't give a shit about bad_alloc or "exception safety" because they simply provide no value in the systems I work with. Software where that does matter, if it's even written in C++ to begin with, would have to redesign, rewrite, or harden most of the useful libraries available out there (I'm not talking about Boost, I mean libraries that actually implement some useful functionality). And you are in a world of pain if you try to bridge C code with code that takes C++ exceptions seriously.

      And you are right about programming in Qt: you've got to take all that "efficient C++" schooling out to the backyard. Same is true about programming Mozilla, Chromium, GCC, or pretty much any popular open project or programming environment based on C++.

      --
      My exception safety is -fno-exceptions.
    60. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      > grep 'foo.bar' ./ -R | grep '==' | more

      It's simpler then your example and actually gets all the times it's evaluated.

    61. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      Coding style has one function and one function only: To keep the Aspergers productive.

      Yeah right! Have you tried maintaining code that has a mix of 5 spaces, 4 spaces, TAB(s) + 4 spaces and what not other hideously chosen indentation patterns.

      And by maintaining I mean adding just the necessary stuff and not entirely reworking the indentation prior to doing any useful change.

    62. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      It was called Visual Age for Java. No, not that crappy rewrite. The real one.

    63. Re:It's easy with an IDE by KingMotley · · Score: 1

      To be fair, I know a lot of programmers who don't even know what a regular expression is, let alone the differences in each of the major types on their syntax quirks.

      Some jobs really don't need to parse complex strings in that manner. Personally, I try to know everything about everything, but I can honestly say that I personally don't. What I value as having been important enough to know isn't necessarily what is important for every programmer in the world to know.

      Not sure why you feel it necessary to say that ALL programmers need to know regex expressions, and you shouldn't be programming if you don't.

    64. Re:It's easy with an IDE by KingMotley · · Score: 1

      Yes, it sounds like he is trying to make something that every current programmer on the team will know, any consultants they bring in will know, and any future employee they want to get up to speed will know.

      You can call that pandering to the lowest-common denominator, most others would call it being practical and efficient.

      Not sure why you brought up VB unless you aren't a programmer. If you think you can't actually get useful stuff done in VB (I assume you mean VB.NET), your just being dense. Also not sure why you think that because you are programming in VB/VB.NET that coding standards all of a sudden aren't important. I am guessing either you are a new programmer who knows only his one language and only knows of VB/VB.NET from hearsay on the net, or some small tic-tac-toe like program you wrote once.

    65. Re:It's easy with an IDE by KingMotley · · Score: 1

      If you are using C#, then I would suggest getting codemaid. Fixes 95%+ of these issues, and our whole team loves it.

      http://visualstudiogallery.msdn.microsoft.com/76293c4d-8c16-4f4a-aee6-21f83a571496

    66. Re:It's easy with an IDE by KingMotley · · Score: 1

      No, you are free to use any IDE you chose.

      You are however responsible for making sure your code conforms to the coding style. If your IDE is incapable of doing this for you, then you must do it yourself manually, switch to a different IDE of your choice that does, or take responsibility for any improper code you check in, and expect a reprimand for it.

    67. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      This topic was first investigated by DoD, SEI and a ton of Universities back in the days of the “Structured Programming Revolution” with research projects. Graduate comp sci and psychology students needed thesis work. DoD, the largest user of computers on Earth at the time, needed to save money. 80% or more of the lifetime cost of a system is not in writing code; it is in maintaining the code. The four types of maintenance (Corrective, Adaptive, Perfective and Preventive) might overlap, but you cannot escape them.

      When I worked for AIRMICS, we collected this early research from everyone. We track eye movement when reading code, timed long it took to find known bugs, etc. The bottom line was just running code thru a “Pretty Printer” and using consistent (not even good!) naming conventions saved 8-12% when programmers experienced on one medium to large system were asked to perform maintenance tasks. These were people who lived with this code for years and knew it inside out. In those days, that meant they read core dumps from COBOL programs really inside out.

      Programmers who were new to a system basically fell on their faces when they ran into “Cowboy code” (unstructured, poorly formatted, idiosyncratic data element names, etc). One of the great quotes from this period was “If it was hard to write, it ought to be hard to read” and it was quite literally how the cowboys viewed their performance.

      The Cowboy Coders were the subject of just one psychology study that I wish I could find again. The researcher was not a computer person, but a psychologist with a specialty in cognitive language skills. The cowboys defended their measurably bad code by defensively insulting everyone else (the slander was “compulsive retards” and “anal” instead of “Aspergers”) and hiding their code from reviews. The researcher also tested their documentation on a Flesch readability scale, spelling and a grammar checkers.

      No great surprise, but when we tracked maintenance tickets to the modules the cowboy wrote over years, these guys were significantly more likely to have problem code. Even worse, if they did the maintenance, the code got worse (i.e. more tickets more frequently).

    68. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      Yes yes, Aspergers is why we have baseball teams all wear the same uniforms, because normal people can tell the players apart just by looking at the wrinkles on their nutsacks.

    69. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      K&R is the only way to format code correctly, at least for C. Everything else is just ccccccccccccccccccccccccccraaaaaaaaaaaaaaaapp.

    70. Re:It's easy with an IDE by Pseudonym · · Score: 1

      I don't give a shit about bad_alloc or "exception safety" because they simply provide no value in the systems I work with.

      Right. Many systems, especially GUI-front-end-type systems (which is Qt's niche), can just crash. But many of the programs you use every day don't have that luxury. Even "medium-end" database servers can't do that; if MySQL crashing at this point means data corruption, it must go to some trouble to avoid crashing at this point.

      I used to get paid to work on mission critical systems. "Mission critical" here means "if the software fails or is unavailable, our organisation is less viable". In that scenario, exceptions matter, and they matter a lot.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    71. Re:It's easy with an IDE by 21mhz · · Score: 1

      So, you substitute "this code does not lose data because it's well-tested" with "this code will never lose data because of our silver bullet: exceptions!" Guess what, you still have to test your code, and each throw site constitutes a separate error-handling path or a few, that all need to be tested. There is a problem, though: exception unwind paths are not easily mapped back to the code, so they may go overlooked in coverage tools and such.

      Re bad_alloc: do you run database servers in an OS that lacks virtual memory allocation? It's about the only case where run-of-the-mill allocations can fail. On a typically configured Linux server, for example, unless you try to allocate huge buffers, the oom killer will get your process before you start seeing any bad_alloc's thrown. You see, practically minded people have figured long ago that having no memory left to allocate means you're already screwed; so they tend to find other solutions than guarding every allocation, wasting your time and code size on error handling paths that can hardly be properly exercised and tested. It should be more preemptive, too. On a server, low memory means you either have a memory leak, or your server is poorly specced/configured for the workload. Just restart it, shutting down services gracefully. On mobile devices, they gracefully suspend background apps and services when memory runs low. std::bad_alloc is irrelevant in most modern software development.

      --
      My exception safety is -fno-exceptions.
    72. Re:It's easy with an IDE by Pseudonym · · Score: 1

      First, a history lesson.

      When Parnas invented exceptions (though he didn't call them that), he framed it around the notion of "undesired events" (UEs for short). He developed the idea when writing for the operational flight program of the A-7E aircraft, where any piece of hardware could, in theory, fail at any moment, and the program must not crash if that happens. Stuart Faulk commented that "these are not problems that arise from programming errors but are unavoidable consequences of executing programs in any real-world environment".

      I'm going to quote the design criteria that he used. Apologies for the now-sexist language; this was the 1970s.

      The criteria are:

      1. UE response routines are written by each programmer in terms of the abstract machine which he uses for his normal case code. UEs are reported in those terms. He is never forced to use information about the implementation of other modules in the system.
      2. Programs can be written so that the code for UE detection, UE correction, and normal case, are lexically separate and can be modified independently.
      3. The system can evolve from an initial version that does little recovery to one which uses sophisticated recovery techniques without a change in the structure of the system.
      4. Even with unsophisticated recovery procedures, the task of locating the module containing a bug discovered at run-time does not require internal knowledge of many modules.
      5. Costs incurred because of the recovery techniques are low as long as no UE occurs.

      IME, it's #3 that not enough people appreciate. Writing your code for exception safety to begin with (and it's honestly not hard) allows you to increase the robustness of the system without touching intermediate code. That alone has saved my bacon more than once.

      Re bad_alloc: do you run database servers in an OS that lacks virtual memory allocation? It's about the only case where run-of-the-mill allocations can fail.

      On Linux, the only time I've ever received a bad_alloc exception was running out of virtual address space. This only ever happens on a 32-bit machine, where the amount of memory (physical and swap) is greater than the size of the address space.

      As you correctly point out, on a 64-bit machine, the first you know of using too much memory is that the OOM killer kills your process. It's a right royal pain if your program is designed to recover. Our system also ran on Solaris, which has much better behaviour when memory is exhausted.

      You see, practically minded people have figured long ago that having no memory left to allocate means you're already screwed [...]

      Not at all! It depends on the system, but there's often plenty of stuff you can do in a server environment.

      If there's a cache (there's always a cache), you can start by ejecting a bunch of entries. If you have a one-thread-per-client scenario (a very common scenario), you could find the client of least value, and kill that thread; unwinding will roll back any transactions in progress and recover any memory that connection was using.

      Even if your ultimate plan is to shut down the system, you can still take steps to shut down cleanly.

      Having said that, the problem usually isn't bad_alloc. Using smart pointers means that other exceptions don't cause memory leaks.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    73. Re:It's easy with an IDE by 21mhz · · Score: 1

      Writing your code for exception safety to begin with (and it's honestly not hard) allows you to increase the robustness of the system without touching intermediate code. That alone has saved my bacon more than once.

      Yes, exceptions are very useful... in managed environments that are designed to support them. Too bad in C++ they are basically feature creep that, among the other creepy features, stretched the language to the point where it can't be used to do anything in a simple way. You got to wrap everything in "smart pointers", of which until recently there was no standard variety, so everybody now uses their own flavor, not compatible with the others. The Boost/C++11 smart pointers are not designed to be passed around in function signatures: they are made to be convenient for type-casting, so they interact with the overcomplicated overload resolution rules in sometimes counter-intuitive ways (and produce kilobyte-long mangled symbol names for the benefit of your dynamic linker). So you have to leave your preferred smart pointer bubble at an API boundary, where an overlooked exception may bite you again, or you end up making a lot of deep copies just to work around the broken language design.

      --
      My exception safety is -fno-exceptions.
    74. Re:It's easy with an IDE by 21mhz · · Score: 1

      You see, practically minded people have figured long ago that having no memory left to allocate means you're already screwed [...]

      Not at all! It depends on the system, but there's often plenty of stuff you can do in a server environment.

      Remember that anything you do in this situation cannot allocate any new memory at all. So God forbid you hit a logging statement on your way to freeing memory after a bad_alloc. It's not guaranteed that you can safely close files, database connections, and so on — something that exception unwind paths will be eager to do.

      So if you want to reach OOM-safety, you still have to test every occasion in which it may happen. And it's not even a static list derived from simple code analysis.

      --
      My exception safety is -fno-exceptions.
    75. Re:It's easy with an IDE by Pseudonym · · Score: 1

      Remember that anything you do in this situation cannot allocate any new memory at all.

      ...until you free some. Thankfully, this usually isn't a problem in practice.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    76. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      A specific regular expression has an equivalent finite state machine.

      Automata also covers critically important topics of turing machines and computability.

      If you do not understand automata you are not a programmer. You are a programming tools end-user, and a shitty one at that.

    77. Re:It's easy with an IDE by Anonymous Coward · · Score: 0

      "No, No, and No again! What you are suggesting is nothing more than compartmentalising a team such that programmer A owns that bit of code, and programmer B owns that bit of code."

      What a crock of shit. You ever use a third-party library? If changes are needed to the library are you going to put just anyone on the task? It is no different with in-house libs. Further, unless you don't document or hire shitty programmers to write the libs how is it hard for the rank and file to use it? No harder than any other API.

      Of course the easy way out is to stop hiring shitty programmers,but few do that.

      It is simple with large teams:

      1. You have a library team(s) - one that writes the libraries needed. Actual programmers are required.
      2. You have a team that stitches them together - Programmers are not required, except for the lead, everyone else can be a minimum wage API monkey.

  2. Er by Anonymous Coward · · Score: 3, Insightful

    Of course coding style fucking matters. Code's generally going to be part of a much larger product that existed long before you joined a company and will continue to exist long after. You don't want the codebase turned into some sort of elaborate puzzle with 200 different methods of laying out code contained within. Uniformity makes maintenance much easier.

    1. Re:Er by Anonymous Coward · · Score: 1

      Do you really find different coding styles to be an "elaborate puzzle"? What do you do when you have to incorporate free or commercial source code into your product? Do you have to reformat it all?

      Novice programmers have trouble following logic unless the code is formatted a certain way but most seasoned programmers don't care too much about that stuff. If they really do care, they run the source code through a text format utility at review time. It isn't a good idea to reformat 3rd party source code at check-in because of maintenance problems - you'll have problems applying up-stream fixes.

    2. Re:Er by udachny · · Score: 2

      coding style fucking

      - I am aware of different styles of fucking, but this new 'coding style fucking' intrigues me. So you are coding and she is .... trying to distract you from it with your 'fucking implement'? Or is it about maintaining proper indentation at every point of the fucking perimeter? Do expand on this theme.

    3. Re:Er by Your.Master · · Score: 2

      You're stuck on the idea that coding style is just whitespace. There is not, and cannot be, a text format utility that unifies coding styles.

      Moreover if you read the article, one thing a coding style could help to catch is a missed break in a switch statement. It would be wrong to automatically add a break (because it might be intended to fall through), or a fall through comment (it might be intended to break). That's a layer of defense that doesn't exist if you don't have all your code (or at least, all your new code) follow the standard of adding fall through comments, because otherwise the absence is not notable.

      You don't need to reformat 3rd party source code, you just need to have a style in your code and understand the API surface of 3rd party code.

    4. Re:Er by Austerity+Empowers · · Score: 0

      Well it's important to do your for() play before putting anything in her {}. Now some people like to go from one to the other back to back such as for() {, while others prefer to separate the {} shortly after. From study I'd say it hardly matters. What I have little patience for is for() play with no {} at all.

    5. Re:Er by Anonymous Coward · · Score: 0

      Have you seen the sort of crap you can create in something like C++? Elaborate puzzle very much applies there. Some of the code I've seen might as well be encrypted as legible as it is(n't). It might be different if you're dealing with a language designed to encourage simplicity or with code that was developed by people who were rational in their use of programming language features but that's not always true. Style guides force people to be sensible.

      Third-party code is an entirely separate issue. You link against it. You develop against the API. You don't control it. It is what it is. Take it as it comes. If the interface isn't stable, ditch it. You don't go beyond that level.

    6. Re:Er by Pseudonym · · Score: 1

      Do you really find different coding styles to be an "elaborate puzzle"? What do you do when you have to incorporate free or commercial source code into your product? Do you have to reformat it all?

      That code lives in its own subdirectory, and we don't edit it unless we absolutely have to. If it turns out we absolutely have to, and it's free code, we follow the coding style of the project and contribute it back. Then it's no longer our problem.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  3. Betteridge says ... by Anonymous Coward · · Score: 0

    Betteridge's law of headlines says "No" ... Unfortunately, he is wrong this time! ;-P

    - AC

    1. Re:Betteridge says ... by Anonymous Coward · · Score: 0

      It's ok, the actual headline of the article is 'Why coding styles matter' It's just the shitty editing here that invoked Betteridge.

  4. Kinda Subjective but... by Onuma · · Score: 4, Insightful

    I've always preferred to use tabs over spaces for indentation, 2 breaks in between major sections or functions, and clearly named vars or functions. The kind of code most people can drop into and say "Oh, I see where this is going" and immediately begin to understand and therefore modify.

    I can't stand opening up any type of code, even web pages, and finding ugly difficult-to-follow lines which seemingly make no sense. Then again, it's all a matter of preference and perspective, isn't it?

    --
    What else can happen when an unstoppable force collides with an immovable object?
    1. Re:Kinda Subjective but... by MrEricSir · · Score: 4, Insightful

      Out of curiosity, why do you prefer tabs? Seems like unless everyone has the same tab size set, it can make the code more difficult to read than spaces.

      Further, most IDEs and text editors have "smart tabs", allowing the simplicity of working with tabs even though you're using spaces.

      --
      There's no -1 for "I don't get it."
    2. Re:Kinda Subjective but... by Anonymous Coward · · Score: 5, Insightful

      I use tabs because anyone can set the width to whatever they like (2, 4 or 8 spaces usually).

    3. Re:Kinda Subjective but... by Anonymous Coward · · Score: 2, Informative

      Tabs indent, spaces align. Your code should look equally good no matter whether tabstop is three characters or eight.

    4. Re:Kinda Subjective but... by slashping · · Score: 1

      Hard tabs should always be kept at 8 spaces, it's the standard, and makes all the tools work as expected without any tweaking. So, unless your code also indents by 8 positions, use spaces.

    5. Re:Kinda Subjective but... by A+Friendly+Troll · · Score: 4, Insightful

      Out of curiosity, why do you prefer tabs? Seems like unless everyone has the same tab size set, it can make the code more difficult to read than spaces.

      For the same reason why CSS was invented to style HTML. Tabs are entirely font-agnostic and they are semantic. Spaces are not, and are directly visual.

      There are people who like two characters of indentation and there are those who like eight. Some like six! There are people who like proportional fonts for coding. There are people who like special narrow monospaced pixel fonts. Even Consolas on Windows, a very popular coding font, is narrower than the standard monospaced width, so code is less indented with Consolas than Courier.

      Tabs are also easier on the eyes if you have "show special characters" turned on in your IDE. Also, tabs are easier to work with if you ever need to run some regex on your code.

      There are no benefits whatsoever to using spaces, only downsides.

    6. Re:Kinda Subjective but... by 93+Escort+Wagon · · Score: 2

      For the same reason why CSS was invented to style HTML. Tabs are entirely font-agnostic and they are semantic. Spaces are not, and are directly visual.

      We're talking about code here. Is anyone using anything but a monospaced font when viewing it?

      --
      #DeleteChrome
    7. Re:Kinda Subjective but... by Anonymous Coward · · Score: 2

      Tabs indent, spaces align. I do this with my own code too. When I use different editors with different tab settings, I often don't even change the tab setting, my code still aligns nicely, just bigger indent. And this is from someone how loves to align things, even inserting spaces or changing variable names to get all "=" nicely linked up in variable initialisations.
      Even when I break lines (on my small netbook screen), use the appropriate number of tabs to match the indent, then align the
      rest with spaces, and everything behaves as it should when the tab size changes.

      Following coding styles is good, especially when working on something with other people, but tabs-size should _not_ be part of the standard at all ! everyone can set the tab size to whatever they like.

    8. Re:Kinda Subjective but... by Anonymous Coward · · Score: 1

      If you like this so-called standard, set your editor's tab width to 8 spaces. Yes, that's tweaking, but unless you're using some utter crap, you only need to set it ONCE and you'll get exactly what you want. It seems much more sane that forcing your preferences on other people.

    9. Re:Kinda Subjective but... by A+Friendly+Troll · · Score: 2

      We're talking about code here. Is anyone using anything but a monospaced font when viewing it?

      Yes, plenty of people. I was using a proportional font for a while when I had a low-res monitor and needed more stuff on the screen. I have two coworkers using proportional fonts right now.

      What is readable to one person might very well not be readable to someone else. That is why some people like their code on black backgrounds and some will get severe eye strain if they look at white-on-black for a couple of minutes.

      Nevertheless, see the post above about monospaced fonts wildly differing in character width.

    10. Re:Kinda Subjective but... by Teckla · · Score: 3, Informative

      I use tabs because anyone can set the width to whatever they like (2, 4 or 8 spaces usually).

      There still exists a lot of tools that assume tab stops are 8, without the ability to change them. Some people use those tools by choice, some people use those tools by mandate.

    11. Re:Kinda Subjective but... by rgbrenner · · Score: 5, Insightful

      a tab is a tab. It is not 8 spaces. It might be the same width as 8 spaces, but that is because your editor displays a tab as that width. Most editors allow you to change it.

      If your code style calls for tabs, do not insert 8 spaces instead of a tab. it's annoying, and you break the tab settings everyone chose for themselves.

    12. Re:Kinda Subjective but... by Onuma · · Score: 1

      It started when I was learning code as a teenager and just stuck. I don't code much anymore, as I'm more of a hands-on guy these days, but I suppose it's habit now.

      --
      What else can happen when an unstoppable force collides with an immovable object?
    13. Re:Kinda Subjective but... by swillden · · Score: 1

      I use tabs because anyone can set the width to whatever they like (2, 4 or 8 spaces usually).

      That only works if you're also careful to use spaces for all additional indentation used to line things up -- and in many cases lining things up can significantly improve readability.

      I used tabs for base indentation (to the block depth) and spaces for extra indentation for a while, but even with good editor support I ultimately decided that it just caused me to spend too much time playing with whitespace.

      If you want your code to look good no matter what the tab width is there's only one practical way: Don't use tabs, use spaces only.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    14. Re:Kinda Subjective but... by 93+Escort+Wagon · · Score: 2

      Yes, plenty of people. I was using a proportional font for a while when I had a low-res monitor and needed more stuff on the screen. I have two coworkers using proportional fonts right now.

      I havrn't seen this first-hand, so thank you for the information.

      (I'm not being snarky - and on Slashdot I do feel the need to say that!)

      --
      #DeleteChrome
    15. Re:Kinda Subjective but... by Anonymous Coward · · Score: 4, Insightful

      And when you use tabs, it doesn't matter what tab size they assume. That is the point. Proper use of tabs means you use tabs to indent to the block level and spaces for further indentation, like so:

      {
      <-tab->a = long expression
      <-tab->____continued;
      }

      ...where underscores are spaces, because Slashdot messes with spaces, even in <code> sections.

    16. Re:Kinda Subjective but... by coldmist · · Score: 1

      There are no benefits whatsoever to using spaces, only downsides.

      Yes, when you have your HTML editor set to show 2 character indents for tabs, but your browser's 'view source' option shows it at as 8.

      Besides using a non-monospace font, it will always look the same no matter what editor you (or someone else) brings it up in.

      Flexibility has it's downsides, just as being too rigid has its downsides.

      It's a choice. Most people pick one and stick with it.

      --
      Don't steal. The government hates competition.
    17. Re:Kinda Subjective but... by slashping · · Score: 2, Informative

      Yes, most editors allow you to change, but I also use command line tools like grep, less, or diff, and they just send the tabs to the terminal which interprets them the standard way with a spacing of 8. Sure, I can set my terminal to change the tab width, but if I then grep some other sources, such as the Linux kernel tree, in the same terminal window, it gets messed up again. The solution is obvious and simple. Just leave the tab width at 8, and everything works fine, even it uses a mix of tabs and spaces for formatting.

    18. Re:Kinda Subjective but... by Clueless+Moron · · Score: 0

      Tabs do not work. Don't use them. Consider this, where there's a tab before the "int" and the "//" comment using the 8-space standard and the intent is to get the comments to line up. I'm using "_" instead of spaces to get around slashdot formatting grief:

      ________int_a;__________//_Hello
      ________int_Whatever;___//_Yeah

      If you set your editor, printer, viewer, whatever to use 4 space tabs it becomes this:

      ____int_a;______//_Hello
      ____int_Whatever;___//_Yeah

      I for one am sick and tired of having to reverse engineer what some frustrated artistic genius decided to use for their tab offset. Set your editor to expand tabs to spaces to whatever you want and save everyone the grief of trying to figure out what you were trying to do, because I really don't give a damn if you use 2, 3, 4, 6 or 8 space indentation; I just don't want to have to guess my way to making your code line up.

    19. Re:Kinda Subjective but... by A+Friendly+Troll · · Score: 3, Interesting

      Here's the funny thing, and I'm honestly not joking: one of these guys is using Comic Sans as his coding font, as he's dyslexic and it helps him. The other is using Tahoma, because it's very narrow.

      Visual preferences vary. That is why we are able to set our own fonts and colours in our IDEs. It is strictly a personal thing. I'm a black-on-white guy, but the Tahoma guy from above is using the old Borland nineties colour scheme, yellow-on-blue. Strangely enough, I "grew up" on those same colours, and since switching to LCD monitors, I can't stand it any longer. No idea why...

    20. Re:Kinda Subjective but... by sribe · · Score: 1

      There are no benefits whatsoever to using spaces, only downsides.

      Until you want to evaluate some code, and paste it into some console which treats tab as auto-complete. I generally much prefer tabs, but this behavior drives me nuts, and has in some cases pushed me to spaces--and now I'm remembering how much I hated all the nonsense with spaces...

    21. Re:Kinda Subjective but... by MangoCats · · Score: 1

      Yeah, tabs work really great in two pages of example code. Expand that out to a couple of years worth of code over thousands of pages and see how great your tabs look when opened in anything other than EXACTLY the same editor you wrote it in. If you're spending time fixing your tabs so they are portable between editors, I think your employer is not getting your brain-cycles focused on the things they care about most. Fixed space fonts, spaces not tabs (and block-column selection / copy / paste) is more productive, unless the source code is the actual product, like in a textbook. You weren't thinking about getting on my lawn, were you?

    22. Re:Kinda Subjective but... by AuMatar · · Score: 2

      Some people don't even use a font- I work with a blind programmer. He uses a screen reader.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    23. Re:Kinda Subjective but... by DrMcCoy · · Score: 5, Insightful

      No, this just means you (and/or the people you work with) are using tabs in the wrong way.
      Tabs for indenting, spaces for alignment. Makes sense logically too, because those two functions are fundamentally different.

      I.e. it should be:

      <TAB>int_a;________//_Hello
      <TAB>int_whatever;_//_Yeah

      Where <TAB> is a tab and _ is a space.

      Works beautifully. Think, people!

    24. Re:Kinda Subjective but... by Giant+Electronic+Bra · · Score: 1

      Yeah, I remember that. Always thought it was ugly, but it seemed to be pretty readable on CGA.

      Gotta agree on the whole tab thing. Logical code indents should be tabs. Thankfully I'm in charge of coding practices (and everything else) at my place, so yay we get to do it :).

      --
      "Malo periculosam, libertatem quam quietam servitutem." -- Jefferson
    25. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      That's why the modeline was invented. Set your parameters in the file and happy you go.

    26. Re:Kinda Subjective but... by rgbrenner · · Score: 5, Insightful

      man expand

      read it.

      And your post is exactly why people standardize on spaces. Because some people think they can insert a bunch of spaces instead of a tab, breaking everyones formatting, making diffs a huge mess and putting your whitespace changes in the commit log. Tab is not space.

      A space is ascii # 32
      A tab is ascii # 9

      stop mixing them.

    27. Re:Kinda Subjective but... by Anonymous Coward · · Score: 1

      There are no benefits whatsoever to using spaces, only downsides.

      I call BS on that statement. I use spaces because it allows anyone to just dump the file to a printer and have it look right. If everyone uses a fixed pitch font, it also looks right in any text editor, even if you don't have the original font.

    28. Re:Kinda Subjective but... by Anonymous Coward · · Score: 1

      Why the fuck are you lining shit up?
      It's one of the stupidest hobbits I've encountered in code.
      I just need to add one fucking item to the list and it's name is one character longer than all the others, so I can just go and re-indent the whole thing.
      Fuck that. I could also decide to use a less descriptive name that fits, but that's also a stupid choice imho.
      The only code where I line things up is vhdl, and that's only because emacs-vhdl mode has this awesome beautify command that fixes all of the indentation and alignment.

      I do agree about the tabs and spaces things though. I used be a tabs person, but now I prefer spaces.
      Every tool assumes that a tab is 8 spaces. While I could go around and change it everywhere that's just annoying,
      and messes up things if I ever find some shit code that mixes tabs and spaces.

    29. Re:Kinda Subjective but... by wisnoskij · · Score: 1

      Well they are clearly superior. That is the entire point of a tab. Why use the space character as a crappy replacement when you have tabs.

      --
      Troll is not a replacement for I disagree.
    30. Re:Kinda Subjective but... by icebraining · · Score: 5, Informative

      one of these guys is using Comic Sans as his coding font, as he's dyslexic and it helps him

      Has he looked into fonts designed to help dyslexics, like Gill Dyslexic and Open-Dyslexic?

    31. Re:Kinda Subjective but... by slashping · · Score: 1

      I know expand, but I don't want add '| expand -t4' to every command I type, and neither do I want to set the tab width every time I open another file in the editor. And if everybody leaves the tab width at 8, it's not going to break any formatting. It's the morons that set the tab width to anything else than the holy 8 that broke the formatting.

    32. Re:Kinda Subjective but... by slashping · · Score: 1

      If your code style calls for tabs, by all means use tabs, but deal with the fact that it must look good when tabs are defined as 8. Don't set tabs at 3 or 4, and then use tabs to line up things that will produce a horrible mess when viewed with tabs at 8.

    33. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Wait... Who would dump source code file to a printer?

      When you deal with content that should look the same no matter where you look at it, you have more suitable formats than plain text files that preserve formatting, say ODF. But with source code it's not about look, it's about readability - and for different people, different indentation is considered readable.

      Stop with this "x spaces everywhere" mantra.

    34. Re:Kinda Subjective but... by rgbrenner · · Score: 0

      it creates a mess because you're mixing spaces with tabs. Stop it, and it will not be a mess. That is what I've been saying!

    35. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      The tabs look equally great as before. Tabs are used to denote identation level, so if you use them consistently - opening in some other editor gives you same consistency, even if tab length will differ. The identation ratio will remain the same.

    36. Re:Kinda Subjective but... by rgbrenner · · Score: 3, Informative

      no, it's you who broke the formatting by mixing whitespace characters.

      and you don't want to type "| expand -t4", so you're going to make a mess of the commit log, make diff a mess, and force everyone else to run everything through indent.

      It's sloppy and inconsistent.. and you're making it harder for everyone else on your team because of your laziness.

    37. Re:Kinda Subjective but... by slashping · · Score: 1

      I'm not mixing tabs with spaces. I'm just typing 'more somebody_else\'s_source.c' and it looks like shit because they have tabs set at 4.

    38. Re:Kinda Subjective but... by rgbrenner · · Score: 2

      Ok... I've figured out the problem: you have no idea what you're talking about; do not understand the differences between whitespace characters; and/or don't understand the settings of your own editor.

      There is a difference between setting "replace tabs with X spaces", and "display tabs as X spaces"

    39. Re:Kinda Subjective but... by A+Friendly+Troll · · Score: 1

      I think he looked into some special fonts, but they lacked our local language glyphs. For straight-up code that wouldn't be a problem (as everything is in English, though a project or two have localized comments), but the UI does need to have text.

      I'll point him to those two fonts and see what he has to say. Thanks :)

    40. Re:Kinda Subjective but... by alexhs · · Score: 1

      I know expand, but I don't want add '| expand -t4' to every command I type

      Then, try man tabs, e.g. tabs -4.

      --
      I have discovered a truly marvelous proof of killer sig, which this margin is too narrow to contain.
    41. Re:Kinda Subjective but... by Clueless+Moron · · Score: 0

      No, this just means you (and/or the people you work with) are using tabs in the wrong way.

      I don't use tabs, so this does not apply to me.

      But the main point is, I have seen tons of code over the past 20 years of my coding experience with this problem. The very existence of the Unix "expand" program which converts tabs to spaces per choice is concrete evidence of this.

      So, since apparently most everybody uses tabs incorrectly, and there does not seem to be any point at all with using tabs instead of spaces, then why use tabs at all? Are there really people who get their jollies by changing the tab value to make code look different on their screens?

      Tab (ascii 9) goes back to typewriters and teletypes and is effectively an 8 indent because terminals and printers and other devices assume it by default. So if you don't want an 8-space indent, don't use a tab. If you do want an 8-space indent, you can't assume the viewers device will treat it that why, so why bother with a tab at all?

      .

    42. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      sed

    43. Re:Kinda Subjective but... by Teckla · · Score: 2

      And when you use tabs, it doesn't matter what tab size they assume. That is the point. Proper use of tabs means you use tabs to indent to the block level and spaces for further indentation, like so: { <-tab->a = long expression <-tab->____continued; }

      ...where underscores are spaces, because Slashdot messes with spaces, even in <code> sections.

      It does matter, because some tools that are hard coded to 8 space tabs make things hard to read, like side by side diffs.

      Also, I have used editors, like the AS/400 editor SEU, which displays a single inverse block character for tabs. It was pretty much impossible for me to maintain that code until I converted the project from tabs to spaces.

    44. Re:Kinda Subjective but... by arkane1234 · · Score: 1

      I really miss the font style that Borland Turbo C used. (not color) It really stuck out at me, and fit my mind just right. :(

      --
      -- This space for lease, low setup fee, inquire within!
    45. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      tab is the natural way of indenting, when bad tools cannot customize the width, then use better tools. Spaces are spaces, they are not made for indention.

    46. Re:Kinda Subjective but... by rgbrenner · · Score: 1

      Proper use of tabs means you use tabs to indent to the block level and spaces for further indentation

      No, it doesn't mean that at all

    47. Re:Kinda Subjective but... by slashping · · Score: 1

      Sure, but then everything that has tabs set at 8 (i.e. everything else) will break instead.

    48. Re:Kinda Subjective but... by allo · · Score: 1

      you must be having a bad editor.
      a tab should expand up to a tab-stop. so

      ab[tab]c
      a[tab]bc
      [tab]abc

      should line up the stuff after the tab at the same horizontal position.
      Of course, this assumes you use enough tabs that one tab is more than the longest difference on the left side. But for the usual lineup indention-stuff you can find a number of tabs, which works without breaking any common (2,4,8) tabwidth.

    49. Re:Kinda Subjective but... by DrMcCoy · · Score: 1

      > So, since apparently most everybody uses tabs incorrectly

      Well, the solution is to educate stupid people, not letting them continue in their stupidity.

      > and there does not seem to be any point at all with using tabs instead of spaces

      There is.
      1) Differentiate the semantic differences of indenting and alignment
      2) Let everyone change their level of indentation to their own choice

      > Are there really people who get their jollies by changing the tab value to make code look different on their screens

      Yes.

      > Tab (ascii 9) goes back to typewriters and teletypes and is effectively an 8 indent

      A tab is not 8 spaces, it's a tab. Which is the point.

      > So if you don't want an 8-space indent, don't use a tab

      A tab is not 8 spaces, it's a tab. Which is the point.

      > If you do want an 8-space indent, you can't assume the viewers device will treat it that [way]

      A tab is not 8 spaces, it's a tab. Which is the point.

    50. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      How about not using tabs to begin with?

    51. Re:Kinda Subjective but... by DrMcCoy · · Score: 1

      Also, completely off-topic: Is it just me, or is the Comment Post Mode option wonky? I can't seem to switch it away from "Code" anymore. No matter what I set, it's not correctly saved. It's back to code when I want to comment.

    52. Re:Kinda Subjective but... by robthebloke · · Score: 1

      I use tabs because anyone can set the width to whatever they like (2, 4 or 8 spaces usually).

      And that is why you should use spaces rather than tabs. I've worked on projects previously where we sold the code to third parties, and we always used spaces to ensure the formatting would always look correct, no matter what tab indentation you used (2 spaces to be precise). The reason it's useful, is that you can be sure your code always looks 'professional' to whomever is looking at it, whatever their indentation may be. Believe me when I say that you get far fewer support requests when third parties look over code that is always perfectly formatted, rather than code that can look 'messy' (when you apply an 8 space tab indentation). Third party users of your code tend to be more confident in its abilities when it looks like professionally cared for code, and so they hassle you less. Who really gives a f**k about what whether the developers on your team prefer 2/4/8 tab indentation? The whole team should be working together as a whole, not as a collection as single entities....

    53. Re:Kinda Subjective but... by Clueless+Moron · · Score: 2

      Are there really people who get their jollies by changing the tab value to make code look different on their screens

      Yes.

      And why should anybody pander to your bizarre fetish?

      Use Unix "unexpand" and shove in tabs everywhere you want. Whack off while changing the indents; I don't care. But for the source code I have to deal with, why must I try to figure out what particular tab setting made you orgasm?

      If you are truly obsessed with a 7-space indent, then go ahead and use that but don't make me have to try to guess it.

    54. Re:Kinda Subjective but... by robthebloke · · Score: 3, Insightful

      No, you're just being obtuse. If I developed with a tab spacing of 4, and I allow a maximum page width of 120 characters, what happens other people view my code with a tab spacing to 8? Chunks of code extend beyond the maximum page width, and it simply looks like an unreadable mess. Using spaces is the only way to be absolutely certain of how your code looks when viewed by other people.

    55. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      > Tabs do not work.
      Tabs work just fine.
      What doesn't work is when people who write text editors pretend that they can be configured, when they can't. Oh, sure you can make it so that you can configure the text editor, but the file format known as "plain text" doesn't have any specified mechanism to convey that configuration to other text editors (or other programs in general) which may need to read it. So as soon as someone other than the author has to deal with the file (or the author has to use the file with something other than said text editor), the illusion of configurable tabs disintegrates.
      Tab stops are every 8 columns, have been since at least the days of the ASR-33 and quite possibly longer, and will be until someone manages to come up with a way of embedding a configuration option in a "plain text" file (if that isn't an oxymoron). Being able to tell your text editor to pretend otherwise doesn't make it so.

    56. Re:Kinda Subjective but... by jader3rd · · Score: 1

      Out of curiosity, why do you prefer tabs?

      Because tab is the character that's developed for indentation. So since I want to indent, I'll use the character for indentation.

    57. Re:Kinda Subjective but... by rgbrenner · · Score: 0

      so.. you can't change the line wrapping setting of your editor?

    58. Re:Kinda Subjective but... by DrMcCoy · · Score: 1

      > Use Unix "unexpand" and shove in tabs everywhere you want

      Which is of course not always possible, because using spaces for indent *and* alignment is lossy. You are expressing two different concepts with the same character. Which is exactly my fricking point.

      > But for the source code I have to deal with

      You are (probably) not the only person having to deal with the source code. If you're so egoistical that you're making it harder for everyone else by mangling two different things together, I sincerly hope you and I are never working on the same codebase together.

    59. Re:Kinda Subjective but... by Fred+Ferrigno · · Score: 1

      No, this just means you (and/or the people you work with) are using tabs in the wrong way.

      Which is inevitable in a team of any significant size. People aren't aware of the distinction, they have their editors set incorrectly, or they're just "rebels" who refuse to conform to what The Man tells them to do. You're going to end up with code that only looks right with one tab setting or the other anyway, sometimes mixed together in the same file. The only enforceable standard is just to ban tabs altogether, which can be an automated check at submit time.

    60. Re:Kinda Subjective but... by DrMcCoy · · Score: 2

      So because apparently some people will inevitable do it wrongly, it's best to just not do it at all? I find this idea completely and utterly weird.
      Everybody will spell things wrongly every now and then, so just ban coherent spelling altogether? Some people will use this interface in the wrong way, so just throw out the whole shebang?

      I'm feeling reminded by the Hitchhiker quote about how coming down from the trees was a mistake.

    61. Re:Kinda Subjective but... by interval1066 · · Score: 1

      2 breaks in between major sections or functions, and clearly named vars or functions.

      A bit pedantic but I can see where you're going. I always get a little nervous when I start work somewhere and the first thing I get is a code formatting sheet that's over one page in length... never the less obviously some kind of formatting is useful. The two rules I find most useful & universal are; use a tab for indenting, since the tab character is usually configurable as the number of spaces between editors, so simply set the number of spaces your pedantic manager seems to need, and if I can get them to see the light of placing open parens on the next line under method signatures and on the same line as branches I'm as happy as a clam.

      --
      Python: 'And then suddenly you have a language which says "we're all stuck with whatever the whiniest coder wants".'
    62. Re:Kinda Subjective but... by Clueless+Moron · · Score: 1

      You are (probably) not the only person having to deal with the source code. If you're so egoistical that you're making it harder for everyone else by mangling two different things together, I sincerly hope you and I are never working on the same codebase together.

      If you look back at my original post, my whole point is that I don't give a flying fuck how people indent their code as as long as don't have to scratch my head to figure out how they liked their tabs. Which is why tabs are annoying.

      You're the Nazi here, not me. I have to figure out what your tabs mean. Gee thanks a lot.

    63. Re:Kinda Subjective but... by DrMcCoy · · Score: 1

      > as long as don't have to scratch my head to figure out how they liked their tabs

      Which is why the code style guidelines in my projects explain how to use tabs: Tabs for indenting, spaces for alignment.
      The same sentence I've used several times in this discussion. Should I draw you an even more detailed explanation?

      > You're the Nazi here

      *sigh* Using the word Nazi in such a callous manner is really not a good idea.

      > I have to figure out what your tabs mean

      Tabs for indenting, spaces for alignment. Not that hard.

      Of course, if you're using spaces *and* tabs for indenting, I have to guess which of those each of your spaces are. Now that's guesswork.

    64. Re:Kinda Subjective but... by bertok · · Score: 2, Insightful

      Seriously, what the fuck are you doing that depends on the exact way that tabs are displayed by other people!? Why would it possibly be that important? Just how fragile is your workflow that it's broken by someone else's display metrics?

      Maybe you need to take a long hard look at your toolchain, then throw it outside in a heap and set fire to it.

      I've been using whitespace-insensitive diff and merge tools since the 90s, and I reformatters since 2001 to solve even the largest formatting inconsistencies. There is never a reason for any programming task to be "broken" by the use of tabs, spaces, or any combination with any configuration. The tools to fix any conceivable problem have been around for over a decade.

      If you're finding you're writing regular expressions looking for a specific number of space-equivalents made up from tab characters, just stop. Re-think your career in programming, and considering going into the secretaries typing pool. You'd fit right in, because many of them also still haven't figured out that a tab is not the same thing as 'n spaces'.

      Next, you'll be complaining that people are putting spaces in their file names...

    65. Re:Kinda Subjective but... by dfghjk · · Score: 1

      A tab is not defined by how people choose to reinterpret it. A tab was originally 8 spaces. Since then, people have claimed the history to be otherwise, it just isn't true.

      It doesn't really matter if your editor is the only editor that a file will ever see, but if you care about any other person's editor, you should understand what a tab really is, not just what your editor thinks it is.

      Tab isn't a variable indention placeholder, it's a move to the next 8-character column.

    66. Re:Kinda Subjective but... by smartin · · Score: 1

      Halleluiah, i don't know why most IDE's bugger with the tab setting but the only proper one is 8. Anything else requires agreements that everyone must follow, which printers and terminals don't support.

      --
      The difference between Canada and the USA is that in Canada healthcare is a right and gun ownership is a privilege.
    67. Re:Kinda Subjective but... by dfghjk · · Score: 1

      whitespace characters are freely mixable, you just need to learn what you don't understand.

      There you go spouting off about diffs and commits again. There is a solution for this, you are just too dumb to realize it.

      The laziness on the team is with the ones who insist their view that ignores editors other than there own are the only thing that matters. Programmers are going to use their preferred tools and those tools do things in different ways. If you don't have a process that compensates for those differences then you don't know what you are doing.

    68. Re:Kinda Subjective but... by dfghjk · · Score: 1

      and you are wrong. Tabs are defined as 8, tabs and spaces can be freely mixed. You want to change your tabstop setting then keep the side effect to yourself. It's not everyone else's burden to compensate for your misunderstanding.

    69. Re:Kinda Subjective but... by dfghjk · · Score: 1

      Look who's talking.

      You're the programmer that creates these problems and expects others to conform to your uneducated viewpoint. Learn how a variety of editors work, not just your own.

    70. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Except when somebody else comes along and uses a narrower screen than you do and bitches about your ridiculous 4 space formatting.

      If you instead used tabs and a IDE with sane wrapping, you could all have 2,4, or 8 tab spacing and still have readable code.

    71. Re:Kinda Subjective but... by dfghjk · · Score: 1

      Spaces are "made" just as much for indention as anything else. Tabs aren't "made" for indention any more than spaces are.

      There are editors, arguably superior ones depending on your point of view, that treat the tab key as a cursor movement mechanism, just like on a typewriter where they originated, and insert no whitespace on their own. This style of editor can be made to save files with indentions optimized with tabs or purely as spaces. but will only do so with the understanding that a tab is 8 spaces, as it always was since the beginning. Programmers that are ignorant of that concept frequently claim a tab is something else, but that only makes it true in dumb people's editors.

      Yes, there are variable tab stops in many devices and have been since before many of use where born. Not all devices support that and, when they don't, their tab stops are fixed at 8. For anyone who cares about interoperability of source files, they MUST assume tabs are 8. There is no other correct answer, and anyone who violates this rule and then complains about diffs and changelogs is a fool.

      Tabs and spaces are the same, the only difference is a "tab stop" is 8 and a "space stop" is 1. Spaces could have variable stops too, they just don't. Whether your editor has variable stops is irrelevant to interoperability. Learn to get along, not force your garbage on others. Talk about "bad tools"...

    72. Re:Kinda Subjective but... by dfghjk · · Score: 1

      a tab expands to a tab stop for tab stops that are 8 characters. Any editor that doesn't do that is deviating from the definition of a tab. It's your editor that's bad if you don't understand that. Fine for you inside your own project but if it's causing problems on a team it's your fault for getting tabs wrong.

      There is no way EVER that a variable tab width solution can result in things being lined up consistently in code. Narrower tabs do nothing except for you. In order to solve the problem for everyone, you have to standardize on the tab AND we always have. It's 8. Period. No variable tab answer can ever work.

      Of course, if everyone on a team sets tabs=4 then it works for everyone on that team, but tabs aren't doing what the naive people here think they do in that case. They only work because they are invariant.

    73. Re:Kinda Subjective but... by dfghjk · · Score: 0

      But if tabs are for indention and spaces are for alignment, as you say, then spaces can only work for alignment for one and ONLY one value of a tab. This is why tab always equal 8; otherwise alignment can ever be achieved.

      Think people!

    74. Re:Kinda Subjective but... by dfghjk · · Score: 0

      It seems DrMcCoy needs to be educated, not allowed to continue in his stupidity.

      You cannot allow changes in indentation level through the tab character and maintain alignment. Ever.

      A tab is a tab AND it is 8 character stops. A tab on the typewriter didn't "type" anything, it just moved the carriage just like the space. Variable tab spacing came later and it did not redefine what a tab was, it only offered flexibility on what it did on THAT machine only. It does not change a tab on the next typewriter over. There it is still 8 characters.

      A tab is only useful in a heterogeneous programming environment if it has a standardized meaning. That's the point you can't seem to get.

    75. Re:Kinda Subjective but... by DrMcCoy · · Score: 1

      > But if tabs are for indention and spaces are for alignment, as you say, then spaces can only work for alignment for one and ONLY one value of a tab

      Wrong.

      <pre>
      <TAB>int a = 5;_// Explanatory comment:
      <TAB>___________// Foobar
      </pre>

      (Let's hope those pre-tags work. Because they don't work in the preview, although my Comment Mode is now set to text + html. In either case, it should hopefully be clear what I mean.)

    76. Re:Kinda Subjective but... by rgbrenner · · Score: 1

      I was wondering why you posted so many replies to my posts... thought no one could be this irate about freakin whitespace.. But I understand now..

      The rest of us are using computers to type our code instead of typewriters

    77. Re:Kinda Subjective but... by dfghjk · · Score: 0

      "Which is of course not always possible, because using spaces for indent *and* alignment is lossy. You are expressing two different concepts with the same character. Which is exactly my fricking point."

      You are an idiot. In your bizarro world there is something magical and unique about the first non-whitespace character than makes it's "alignment" different than the alignment of everything else. Perhaps you need to think a little harder. There is no difference between the first alignment and every other alignment.

      "You are (probably) not the only person having to deal with the source code."

      And perhaps you haven't had to deal with source code nearly enough. There is a set of standards that fix this problem once and for all and they predate you. Some people know what that is. You aren't one of them.

      "I sincerly hope you and I are never working on the same codebase together."

      That's, of course, because he knows the problem better than you and doesn't appreciate you dumping your crap on his plate.

    78. Re:Kinda Subjective but... by grumbel · · Score: 1

      There are no benefits whatsoever to using spaces, only downsides.

      Spaces have the advantage that they work everywhere. The issue with Tabs is that there are to many editors that will break them, most famously Emacs, which will use Tabs for alignment and indention, so whenever somebody hits reindent with a different Tab-width setting all the code gets changed. Spaces just work, they are the worse solution, but at least they stay equally bad everywhere.

    79. Re:Kinda Subjective but... by dfghjk · · Score: 0

      "Which is why the code style guidelines in my projects explain how to use tabs: Tabs for indenting, spaces for alignment."

      Your coding style guidelines are written by someone stupid, quite possibly you. If a team effort cares about tabs and spaces in source files, they should have tools that enforce it to prevent thrashing the change logs of their SCCS. That can easily be done and installed in the checkin path. It's 1990 all over again...

      Of course, tools like that only actually work when there's a standard tab stop and that's also a standard part of a style guideline. If it's not, the people who write it are incompetent.

      Any guideline that allows variable tab stops prevents the use of a whole class of editors. That only works when no one on the team uses such an editor. It also permanently breaks alignment outside the first indent, something you fail to realize.

      Explain why you need to "guess" which characters are tabs and which are spaces in the indention area of one of these problem files you speak of?

    80. Re:Kinda Subjective but... by DrMcCoy · · Score: 1

      > In your bizarro world there is something magical and unique about the first non-whitespace character than makes it's "alignment" different than the alignment of everything else

      There is. It's called indenting. And it /is/ different than, say, aligning "=" in following lines.

      > There is a set of standards that fix this problem once and for all

      Exactly. And it's called: Tabs for indenting, spaces for alignment. Works beautifully. Always has, always will.

    81. Re:Kinda Subjective but... by DrMcCoy · · Score: 1

      Of course tabs have changed throughout the years. Look at what word processors do with tabs. They actually use it for alignment within proportional text.

    82. Re:Kinda Subjective but... by dfghjk · · Score: 0

      "So because apparently some people will inevitable do it wrongly, it's best to just not do it at all? I find this idea completely and utterly weird."

      You are the one doing it "wrongly". You are the one that forces solutions like his to get enforced because you think what's convenient for you should be the rule.

      "Some people will use this interface in the wrong way, so just throw out the whole shebang?"

      The choice is to throw it out of give up on consistent formatting, so yes, throw it out. Not the solution I have chosen on my projects, though. My files contain tabs in a canonical form, 8 spaces per plus space characters to produce the right column. As god intended. To achieve that I wrote a text filter that makes sure the file is right before checkin. Fixes changelog thrashing in the process.

    83. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      That works great in editors, but unfortunately fails in tools (source browsers like LXR/Google code search/etc.), diffs, VCS blame, etc.) That, and people tend to not leave modelines behind noting what settings they used, and ending up with files with inconsistent settings...

    84. Re:Kinda Subjective but... by dfghjk · · Score: 1

      "For the same reason why CSS was invented to style HTML. Tabs are entirely font-agnostic and they are semantic. Spaces are not, and are directly visual."

      You couldn't be more wrong. Tabs are semantic only in poorly devised languages, like make for instance. Indention isn't semantic in any general sense.

      Anyone who uses a proportional font for coding has already accepted broken alignment. Tabs do nothing special for them.

      There is a great benefit to using spaces rather than tabs, it's the only thing that produces a predictable view when tab stops are variable.

      Variable tab stops break everything and fix nothing.

    85. Re:Kinda Subjective but... by dfghjk · · Score: 1

      Accommodating variable indention whims is way down the list of important things when working on team projects. Variable indention can only be made to work for the *first* thing that aligns on a line. There are other things of importance.

      The only people who would say this are people who've never really faced these issues. Getting a consistent view of source and a protocol for everyone to follow is of fundamental value and everyone with experience knows it.

    86. Re:Kinda Subjective but... by dfghjk · · Score: 1

      The tab character was not "developed for indentation".

    87. Re:Kinda Subjective but... by rgbrenner · · Score: 1

      Next, you'll be complaining that people are putting spaces in their file names...

      Good question... let me tell you why spaces in file names are wrong: if you type it in a shell, you have to escape the space with a backslash (one extra character) or worse, by using quotes (two characters)

      That is 1-2 characters extra you are forcing everyone on your team to type, making everyones job harder, simply because you didn't think of using a "_" instead of a space.

      (this is tongue-in-cheek if you can't tell... oh, and I use 2 spaces for indentation.. anything else is an abomination!)

    88. Re:Kinda Subjective but... by Mr.+Slippery · · Score: 1

      ....and I allow a maximum page width of 120 characters

      Please don't. 80 columns allows code to be read or printed anywhere at a reasonable font-size. There's a reason printed text has margins and keeps to 50-70 characters per line. Wrap your long lines.

      --
      Tom Swiss | the infamous tms | my blog
      You cannot wash away blood with blood
    89. Re:Kinda Subjective but... by VortexCortex · · Score: 1

      Actually, my editor uses spaces for everything. Pressing TAB moves to the next indent guide or code alignment hint (and creates code alignment hints). For instance, to get your first line I type:
      [TAB]int[TAB]a;[TAB]//_Hello
      This produces:
      [INDENT]int_a;__//_Hello

      Then I press [ENTER] and I get an automatic indent to match the previous line's indent (backspace to [UNINDENT] from there). So then I type this:
      float[TAB]whatever;[TAB]//_Yeah
      Which actually produces this result:
      [INDENT]int___a;________//_Hello
      [INDENT]float_whatever;_//_Yeah

      Note the alignement of the var names and type names and comments. Typenames can be quite long in many languages, adding another line will reflow all of the code above the current line until the first blank line or non aligned hints. (or overridden via SHIFT+SPACE). The default save settings turn the indents into tabs, and the alignment into spaces (as you prefer), and saves the code alignment hints in my project's settings; However, I can select to save with tabs wherever possible, or only spaces, or even embed the alignment hints into a comment block at the end of the file. Furthermore, I can import your crappy "single space after typenames" format and tell it to reflow into my desired style guide -- I can even export my preferred style back into your crappy one, to appease maintainers without sacrificing my superior style preferences.

      We have the technology. Your preference is irrelevant, I have my own.

    90. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Why have a 120 char limit? Especially considering 24-7" multi-monitor setups are fairly common now. Some code styles are just outdated -- "printable" page width and other such limits.

    91. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      On my 1920s Remington typewriter, the tabs are exactly where you set them. Because you manually set the tab stops. So, no, they weren't originally 8 spaces or any other uniform number. They were, you might say, where people interpret the tab should be.

    92. Re:Kinda Subjective but... by swillden · · Score: 1

      you must be having a bad editor. a tab should expand up to a tab-stop. so

      ab[tab]c a[tab]bc [tab]abc

      should line up the stuff after the tab at the same horizontal position.

      Nonsense. A good editor should indent the whole line correctly for the currently-specified style based on the structure of the code, regardless of where your cursor is when you press the tab key. So, assuming each of your "abc"s represents a complete statement and none indicates the beginning or ending of a block, with a good editor, the three lines should all start at the same horizontal position.

      But I often don't want it all lined up at the same horizontal position. For example, a function call with several parameters may be long enough that I need to wrap the line, possibly several times. I'd like each parameter starting a new line to line up with the first argument, the one following the open parenthesis. Thus, each of those subsequent lines needs to be indented as far as the first letter of the function name, plus the length of the function name, plus one (for the open paren). Odds are, that indentation level won't be a multiple of the tab width. Even if it happens to work out to be a multiple, as soon as someone changes the tab size, it won't be.

      The solution is to indent with tabs to the level of the function call, then use spaces after that (since the length of the function name won't change when the tab size is altered). But getting that mix of whitespace exactly right is pretty difficult, even with good editor support.

      If you want your code to look good regardless of tab width you have two options: Regularly test the layout by changing the tab width so you know where it needs to be fixed, or just use spaces.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    93. Re:Kinda Subjective but... by UnknownSoldier · · Score: 1

      > It's the morons that set the tab width to anything else than the holy 8 that broke the formatting.
      *YOU* are the moron for ASSUMING tab = 8 spaces. There is NO rule that says tabs MUST be 8 spaces, ONLY _convention_.

      Anyways, there are 3 choices for whitespace:

      * ONLY Tabs
      * ONLY Spaces
      * Tabs for indent. Spaces for alignment

      That last one gives the most flexibility.

    94. Re:Kinda Subjective but... by swillden · · Score: 1

      There is no way EVER that a variable tab width solution can result in things being lined up consistently in code.

      This isn't true, actually. Not that I think it's a good idea to try to support variable tab widths, but it certainly can be done.

      The key is that block level indentation should be done only with tabs, and any extra indentation beyond the block level should be done only with spaces. For example, imagine a C function containing a for loop which contains an if statement whose body contains a function call, which has several arguments and is wrapped. The function declaration should be at indentation level 0. The contents of the function body are at level 1, so the for loop is indented one tab. The body of the loop, and the if statement are at level 2, so two tabs. The function call is at level 3. The arguments that are wrapped to the next line are at level three (three tab stops) PLUS spaces to push them over so they line up under the first argument.

      With that approach, changing the tab width will change the block level indentation, and the spaces will keep the rest lined up.

      In practice, even with editor support maintaining that sort of whitespace become far more of a burden than it's worth, but it can be done.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    95. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Don't count on it: I use tabs and a proportional font.

    96. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      1 tab is equivalent to 8 spaces. However, so is a space followed by a tab. Or two spaces followed by a tab. In fact, up to 7 spaces followed by a tab are equivalent to 8 spaces. Tabs are not simply the same as 8 spaces.

    97. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      I use tabs for indentation. It doesn't matter what size they are. One tab, one indentation level. I use a proportional font for readability. No one sane uses a non-proportional font for anything they want read. I don't f' about with spaces trying to line up comments, or any other aspect of my code. Any code where that would be worthwhile, is code that's repetitive and, therefore, error-prone. It usually means it needs to be refactored.

    98. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      I just use tabs to indent. My code would look like this (only indented by tabs to the right):

      int a; // Hello
      float whatever; // Yeah

      Which I think is more readable because it uses a proportional font.

    99. Re:Kinda Subjective but... by murdocj · · Score: 1

      Don't be ridiculous. You can set your tab size to anything that works for you. We specifically indent with tabs and then people can set their tab size to whatever they prefer. I prefer a larger tab size so indentation is obvious. Some people prefer a smaller tab size so code doesn't run off the right hand size of their window. There's zero downside to being flexible on tab size.

    100. Re:Kinda Subjective but... by murdocj · · Score: 1

      If you don't mix tabs & spaces, it doesn't matter whether the tabs are set to 2, 4, 8, or 16. Indentation will be correct.

    101. Re:Kinda Subjective but... by murdocj · · Score: 1

      Yeah... and then you accidently type in column 6 and it's a continuation card... sorry, this talk printing on 120 column paper caused me to flash back to FORTRAN. I think the world has moved on since those times.

    102. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Yes, I always program with proportional fonts.

      I only use monospaced fonts for the terminal, and I'd like to avoid that too.

    103. Re:Kinda Subjective but... by FalseModesty · · Score: 1

      If your code style calls for spaces, do not insert a tab instead. It's annoying, and you break the indentation that everyone has agreed on.

    104. Re:Kinda Subjective but... by robthebloke · · Score: 1

      Because if you use your 24" monitor in landscape, it allows 2 pages side by side (without wasting space), and it's the right width for a 24" monitor rotated 90 degrees in portrait.

    105. Re:Kinda Subjective but... by robthebloke · · Score: 1

      Rotate a 24" 1080p monitor 90 degrees, and you'll see why it makes sense.

    106. Re:Kinda Subjective but... by multicoregeneral · · Score: 1

      Hard tabs should always be kept at 8 spaces, it's the standard, and makes all the tools work as expected without any tweaking. So, unless your code also indents by 8 positions, use spaces.

      5 spaces is the standard in general. 8 spaces is too wide, and makes the code too difficult to read. I know people that set their tabs at three spaces. Hence the problem with tabs. Of course, none of that really matters unless you're coding in Python. Inheriting Python code is absolutely awful unless you have document markup turned on in your editor ahead of time (so you can determine that you're not mixing tabs and spaces).

      --
      This signature intentionally left blank.
    107. Re:Kinda Subjective but... by FalseModesty · · Score: 1

      You may be using a computer, but you're not understanding what you're doing with it.

    108. Re:Kinda Subjective but... by FalseModesty · · Score: 1

      If you don't understand the difference between coding and writing a text document, you are beyond help.

    109. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Seriously, what the fuck are you doing that depends on the exact way that tabs are displayed by other people!?

      ASCII art in comments :3

    110. Re:Kinda Subjective but... by allo · · Score: 1

      > The key is that block level indentation should be done only with tabs, and any extra indentation beyond the block level should be done only with spaces.
      You say it, as if it were fact. Its you coding style, nothing more.

    111. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Theoretically yes but practically I remove every tabs from my code base for 2 reasons
      1) Too clever IDEs ( and VI ) are mixing tabs and spaces when you hit return on a line, makng the whole code a mess if viewed in a different tab width
      2) Cut and paste in Linux does not copy over tabs but spaces.
      3) People are stupid and mix tabs and spaces based on their settings ( I.e. instead of using tab they indent using N spaces )

      Because #1, and #2 I started to use only spaces. Because of #3 I started to hate seeing tabs in code

      I rate tabs the same as the "caps lock" key on my keyboard. "Trying to help by being clever and assuming a certain behavior, yet in reality pisses of most users."
      BTW. Don't come up with you should use it properly thingy, That would assume most programmers on a project would care. Well I found, by looking at millions of lines of professional grade code, the vast majority does not care.

    112. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      It works until someone decides to use a variable-width font.

      This flame war is fun!

    113. Re:Kinda Subjective but... by complete+loony · · Score: 1

      Use tab's for indenting, use spaces when you want to indent a multi-line statement. If the control flow of you application is so horribly nested that you can't fit it on a narrow screen, you have bigger problems.

      --
      09F91102 no, 455FE104 nope, F190A1E8 uh-uh, 7A5F8A09 that's not it, C87294CE no. Ah! 452F6E403CDF10714E41DFAA257D313F.
    114. Re:Kinda Subjective but... by ByteSlicer · · Score: 1

      Yup. This is exactly what I've been doing for years: Only tabs between the line start and the first non-tab char, only spaces after that. It's the only way to make variable tab widths work.

      I usually don't bother lining up code on the right (equal signs and such), it costs too much time to maintain and usually leads to a sort of OCD where one spends more time with code format than with code logic.

      Side note: I usually put line comments on the line above the code they comment on, that way I don't have to re-indent the second line (// Foobar) in case the code changes (int a = 500;). It's also more convenient for adding a second/third line of comment later.

      And the closest thing to a pre-tag seems to be the ecode-tag (basically a cross between quote and pre).

    115. Re:Kinda Subjective but... by bondsbw · · Score: 1

      I can't stand lining up comments to the right of code, for several reasons:

      - Comments that are lined up to the right are often off the screen. The code grows horizontally, and entire pages worth of comments get pushed off the right edge of visible area.
      - Because of the first issue, I may not notice multi-line comments when inserting new lines of code. Wash, rinse, repeat, add a few more comments to those, and suddenly nothing to the right makes sense anymore.
      - Even if I can see the comments, the description of variables and other short lines are often so far away that it is harder to read.

      People, please, comment above your code instead of to the right!

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    116. Re:Kinda Subjective but... by chrismcb · · Score: 1

      So, since apparently most everybody uses tabs incorrectly, and there does not seem to be any point at all with using tabs instead of spaces, then why use tabs at all?

      The reason I use tabs (you could argue this is a problem with Visual Studio) is it takes one keystroke to indent, but 4 to remove the indent. I use tabs for my personal project, and spaces at work. And it annoys me.
      But yeah, tabs only at the beginning of the line. Spaces in the middle. Works just fine.

    117. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      spaces in bloody filenames is a problem when gnu make is used anywhere in the tool chain! Triskaidekaphobic unix programmers throwing a wobbly whenever they see the character 13 (carriage return) in a file too. And as for linux source code littered with files with the same name but just differing by case, its as if they are trying to make it hard for people to cross-compile from windows. Windows deciding to capitalise the first character of filenames, or change apostrophes in text files into "smart quotes" is just being mean.

    118. Re:Kinda Subjective but... by swillden · · Score: 1

      > The key is that block level indentation should be done only with tabs, and any extra indentation beyond the block level should be done only with spaces. You say it, as if it were fact. Its you coding style, nothing more.

      No, I'm saying that if you do it that way, you can actually make the code always line up no matter what the tab size is. Think about it, or try it.

      I don't use it as my coding style, and I don't recommend it because it's too much effort to maintain the necessary mix of tabs and spaces. My point is just that it does in fact work.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    119. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Care to elaborate? I can't possibly imagine a situation when it would matter how long identation the other guy sees on his display. It does matter to preserve a consistent level of identation, and tabs are largely helpful there precisely because they denote, guess what, levels of identation.

    120. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Thank you - every single person I know in real life who uses spaces doesn't understand this simple idea.

    121. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      It will not always look the same in different editors. People who use vim or emacs often have complex routines to reflow source code because they want to see 2 space indents instead of 4, and often times things go horribly wrong. This crap would never have happened if people just stuck with tabs.

      I hate with a passion you spaces-for-indentation people. Sadly you appear to be in the majority these days.

      FWIW, I've always used tabs, but I have changed my coding style several times over the past 15 years. I don't just pick any style and stubbornly stick with it. I've actually listened to reason and changed my habits accordingly.

    122. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Aligning comments to the right of code = huge waste of time (ref: Knuth)

    123. Re:Kinda Subjective but... by gnasher719 · · Score: 1

      If your code style calls for tabs, by all means use tabs, but deal with the fact that it must look good when tabs are defined as 8. Don't set tabs at 3 or 4, and then use tabs to line up things that will produce a horrible mess when viewed with tabs at 8.

      If you come to where I work, you better deal with the fact that tabs are set to 4, and if you mess with that, you will be strangled.

    124. Re:Kinda Subjective but... by shiftless · · Score: 1

      How about just sucking it up?

    125. Re:Kinda Subjective but... by Maxmin · · Score: 1

      If you set an alias, like x4="expand -t4", it gets a lot easier. I use tabs and set my aliases to better handle them.

      --
      O lord, bless this thy holy hand grenade, that with it thou mayest blow thine enemies to tiny bits, in thy mercy.
    126. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Spaces look the same everywhere. That's why no single standard ever uses tabs. Tabs also screw up diff and patch tools.

    127. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Tabs for indent, space for aligning, is convenient for everyone, because everyone gets to look at the code at their own preferred indentation, and it still looks fine.

      Spaces are convenient for the formatting-nazis who won the discussion about how many spaces to use, and inconvenient for everyone else.

      We use 4 spaces at work, because that's the Visual Studio default. That's small enough that I often use alt+down (block select) as a ruler to see which indent matches. Had we used tabs for indent, space for alignment, I could have used 8 and someone else could use 2 or 3, and it would still line up perfectly.

    128. Re:Kinda Subjective but... by Mathinker · · Score: 1

      > There are no benefits whatsoever to using spaces, only downsides.

      I envy you your utopia, where everyone indents using tabs in a semantic way only (and all editors work that way, also). Where I work, twelve different people edit the same code, all with different editors (and often from different OS platforms). Once (semantic) tabs get mixed with (visual) spaces, your argument falls apart --- in that case, it is would be infinitely better if everyone would use spaces.

      Another drawback with using tabs semantically, is that some indentation schemes have varying amounts of indentation depending on the programming construct being indented (Ellemtel comes to mind) --- in other words, the ordinary way tabs are interpreted in most editors cannot reproduce this indentation scheme visually.

    129. Re:Kinda Subjective but... by Anonymous Coward · · Score: 0

      Huh? What kind of IDE and language do you use that would force a maximum page width of 120 characters per line before it wraps? Are we still printing on green bar paper when we code? You set your tabs how you want (at 4 spaces) and I'll set mine.

  5. Op Op Op Op by Anonymous Coward · · Score: 0

    Oppan Allman Style

    1. Re:Op Op Op Op by Anonymous Coward · · Score: 1

      Yes. Allman style is the best style.
      People complain about all those empty lines with just 1 bracket on them, but whatever, for me it just makes the start and end of a scope clear.

      One of my least fofourite has to be GNU style.
      I don't know how the fuck stallman came up with the braindead idea to put the braces halfway between the previous and current indent level, but it drives me crazy.

    2. Re:Op Op Op Op by maxwell+demon · · Score: 1

      Had to google it, only to find out that this is the style I already use (except that the Wikipedia displays it with indent levels of 4, while I use indent levels of 2) :-)

      --
      The Tao of math: The numbers you can count are not the real numbers.
    3. Re:Op Op Op Op by maxwell+demon · · Score: 1

      One of my least fofourite has to be GNU style.
      I don't know how the fuck stallman came up with the braindead idea to put the braces halfway between the previous and current indent level, but it drives me crazy.

      Probably because of a literal translation of the logical structure of C:

      The if statement takes exactly one substatement which you normally indent:

      if (condition)
        statement;

      Now the {} form is just a compound statement where you generally indent the statements in between relative to the braces, like this:

      {
        statement1;
        statement 2;
      }

      Now insert the second into the first, and you immediately get:

      if (condition)
        {
          statement1;
          statement2;
        }

      Of course a literal translation would also lead to things like

      if (cond1)
        statement1;
      else
        if (cond2)
          statement2;
        else
          if (cond3)
            statement3;
          else
            statement4;

      which I guess even Stallman would instead write as

      if (cond1)
        statement1;
      else if(cond2)
        statement2;
      else if(cond3)
        statement3;
      else
        statement4;

      --
      The Tao of math: The numbers you can count are not the real numbers.
  6. Bike shed effect by Anonymous Coward · · Score: 1

    The thing I dislike most about discussions of coding style is that since the topic of coding style has an extremely low barrier of entry, everyone has an opinion. I know bad code when I see it, I could give a fuck how many spaces are in a tab or how many characters to a line.

    1. Re:Bike shed effect by arkane1234 · · Score: 1

      I know bad code when I see it, I could give a fuck how many spaces are in a tab or how many characters to a line.

      That's about equivalent to saying 'I know a bad driver when I see them, I could give a fuck how many times they run into the wall'....

      Those two things are almost a 101 kind of programming grammar.

      --
      -- This space for lease, low setup fee, inquire within!
  7. Learn one word by roman_mir · · Score: 4, Insightful

    Learn one word: consistency.

    Be consistent from one piece of code to the next, from one project to the next. Be consistent about your design ideas, be consistent in your thinking. It's going to help you and anybody else working on the same stuff.

    Everything else is sugar.

    1. Re:Learn one word by Anonymous Coward · · Score: 0

      I like his posts, people who use the words libertard and batshit (I am assuming you do) are usually pretty uninformative.

    2. Re:Learn one word by arkane1234 · · Score: 1

      You must be a republitard hrhrhrhr
      Seriously, be semi-adult.

      --
      -- This space for lease, low setup fee, inquire within!
    3. Re:Learn one word by KiloByte · · Score: 1

      I have never been part of a project that did not enforce a given style of code formatting. If you mix them, stuff is really hard to read.

      --
      The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
    4. Re:Learn one word by Anonymous Coward · · Score: 0

      Learn one word: consistency.

      Be consistent .... Be consistent ... be consistent...

      Consistency is great, but you should also learn some Emerson:

      A foolish consistency is the hobgoblin of little minds, adored by little statesman and philosophers and divines. ... Speak what you think now in hard words, and to-morrow speak what to-morrow thinks in hard words again, though it contradict every thing you said to-day.

      Note that it's "foolish consistency", and not just "consistency" (a very important distinction). The trick is to be consistent in only those things that don't matter. When things *do* matter, do what is best, and throw those who say "you can't do that because then we'll be inconsistent with established practice" to the jackals.

      Note that 99% of code formatting decisions (especially ones fiercely defended) fall solidly in the "doesn't matter" bin.

    5. Re:Learn one word by Xtifr · · Score: 1

      Be consistent from one piece of code to the next

      Agree.

      from one project to the next.

      Disagree mildly. Each project should have a consistent style, but unless these are your private little home-projects, finding a consistent style for a project that all the team members can live with is more important than sticking to one overall style for all projects. Especially if the projects are in different languages (I use Sun guidelines for Java, but dislike them for C/C++).

      Other things being equal, consistency between projects is better than inconsistency, but people being people, other things are rarely equal. :)

    6. Re:Learn one word by roman_mir · · Score: 0

      But doesn't your comment make my point? My comments are consistent, you remember that they are consistent, you know where I stand on things to a higher degree than you know of many other participants in /. discussions.

      Since I am consistent in my views, it's not too difficult to see how all comments fit together, isn't it?

    7. Re:Learn one word by VortexCortex · · Score: 1

      No. Learn two words instead: Flexibility. Autoreformatting. Then you can stop worrying so much about the style of the damn code, and get your ideas into the computer without fussing over adhering to your own style. If you hop from one project to the next they'll have a different style guide. You don't worry about it. Configure the autoreformatter to save in their style and display in your preferred style.

      Be careful being so consistent that you devolp habits, respond irrationally to change, and become inflexible. Another word for inflexible is Extinct.

    8. Re:Learn one word by Anonymous Coward · · Score: 0

      I'll add the following: be consistent with the style of your language and its library. If your language uses camel case, use camel case. If it uses underscores, use underscores.

      I'll reiterate: STYLE WAS CHOSEN FOR YOU A LONG TIME AGO! It is whatever style the language designer chose. If you don't follow it, the result is inconsistent!

    9. Re:Learn one word by gbjbaanb · · Score: 1

      not really - he means be consisted within a project, so if you decide to use _ in names for example, and create int my__variable then do not create int MyNextNewVariable afterwards. (or vice versa).

      This applies to all projects, so if your coding standards say always use underscores in naming, and you have to work on existing code that uses pascal case for names, then you use the pascal case - not the standard. The point is that all the code needs to be roughly the same style in a project but it really doesn't matter what that style is.

      Reformatting only really deals with syntax of the code, which is trivial stuff - braces in certain places etc, using one will screw your source code diffs, and will not help you with other parts of the code style. So they're a bad choice. But the flexibility to change styles is good advice.

    10. Re:Learn one word by c++0xFF · · Score: 1

      And I've never been on a project that didn't have the oddest mixture of coding styles. And that's not because there was a lack of a style guide. But over the years (decades, sometimes) projects get combined, different styles work their way in over time as opinions change on the best style and as code gets reformatted ten times over.

      Consistency is fine and all, but it tends to degrade over time.

      On whatever code I'm working on, its always best to match what's there as much as possible.

      If there's something I've learned, it's that the exact style doesn't matter, as long as it looks good, doesn't get in the way, and you try to enforce consistency.

    11. Re:Learn one word by KiloByte · · Score: 1

      And that's why people put effort in keeping code consistent. It's worth the time spent.

      Not just formatting, but used techniques in general. Some refactoring might cost a bit right now but is beneficial in the long gain, if you want the codebase to stay maintenable.

      --
      The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
    12. Re:Learn one word by drew_eckhardt · · Score: 1

      And I've never been on a project that didn't have the oddest mixture of coding styles.

      I have.

      A pre-commit hook in your revision control software to bounce changes which won't confirm does the job nicely with a

      make style

      target making achieving pre-checkin compliance painless.

      Occasionally you need something which technically violates the style checker, although the need for a manual override via something embedded in comments like /* BEGIN CSTYLED */ /* END CSTYLED */

      limits that to rare intentional occurrences.

    13. Re:Learn one word by drew_eckhardt · · Score: 1

      No. Learn two words instead: Flexibility. Autoreformatting.
      Then you can stop worrying so much about the style of the damn code, and get your ideas into the computer without fussing over adhering to your own style.

      That sounds intriguing to me.

      How do I apply auto-reformating to JIRA, gmail, bugzilla, Coverity, enscript, and the plethora of other tools which get used in the software development process?

  8. Let people code how they like by SuperKendall · · Score: 1, Insightful

    I do not see any point in coding styles whatsoever. All they do is slow down coding for all but the two guys that actually like the coding style as defined; for the rest it's needless busy-work to comply.

    I agree that one persons code should look consistent; so someone should pick a style and stick with it. Also if I am making a SMALL change in someone else's code, I try to mimick the style of code around it.

    It's so easy to run a code formatter on something now that someone else can read code however they like if it's really important. But while code is underway conformance to a specific style is not helpful.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:Let people code how they like by Anonymous Coward · · Score: 3, Insightful

      Note to self, don't hire this one.

      The reason we enforce code style is the same that we enforce requirements traceability. We must have maintainable, auditable code. If we were writing throwaway scripts to delete old comments on a website, perhaps that would be okay. However, when we're writing production code that needs to work and be maintained, code style is very important. Yes, we audit code. Yes, it works. We have yet to have gotten hit with a real-world exploit, critical bug or unexpected behavior from garbled input.

      Is writing code this way slower and more expensive? Hell yes, if you believe that SLOC is a good measure of success. However, we care about lifecycle cost, and our approach is working very well. And, it's easy to take a month of vacation when you know your code's good enough that nobody will call and ask about it.

    2. Re:Let people code how they like by 93+Escort+Wagon · · Score: 1

      I do not see any point in coding styles whatsoever. All they do is slow down coding for all but the two guys that actually like the coding style as defined; for the rest it's needless busy-work to comply.

      It depends. Some people here seem to be defining "readability" and "documentation/comments" as coding style - and I do think readable, well-commented code is important.

      Otherwise I tend to line up with you. I will admit, though, that I've never been part of a large group jointly working on a software project. When I'm dealing with another person's code, most of the time it's something another person wrote by himself, and I'm now having to add some feature or fix some bug after the fact.

      --
      #DeleteChrome
    3. Re:Let people code how they like by Misagon · · Score: 4, Insightful

      Coding style is not just be about making code look pretty (according to someone's personal definition of pretty). The purpose of a coding standard is to make the code more readable and thus, more understandable. Having the code look consistent helps in that regard.
      Most of the time as a programmer is not spent on producing code but on skimming through other people's code and trying to figure out how something works, or why something doesn't work. Time is money, and it is better that a code writer spends a few extra seconds on making the code more readable than a code reader spending maybe fifteen minutes on the same piece of code because he misunderstood some detail of it the first time around because it was written in a weird way.

      There are some things that are more important than whitespace and braces, that are too often overlooked. A coding style/code standard should also include conventions for code patterns, comments and how to choose reasonable variable names ... and these things can not be changed by a "pretty printer".

      --
      "We mustn't be caught by surprise by our own advancing technology" -- Aldous Huxley
    4. Re:Let people code how they like by lkcl · · Score: 1, Interesting

      I do not see any point in coding styles whatsoever.

      then you have never worked on a free software collaborative project; you have never submitted patches to free software projects; you have never worked for a large software engineering firm with ISO9001 (Software TickIT) practices in place; in fact you have probably never worked with revision control tools ever in your life.

      please allow me to know exactly who you are so that i never, ever employ you or allow you to go anywhere *near* any of the free software projects i am involved in or will be involved in, in the future.

      It's so easy to run a code formatter on something now that someone else can read code however they like if it's really important.

      running a code formatter and then creating a patch automatically includes your modifications in amongst a bunch of whitespace modifications, by violating the golden rule of submitting single-purpose patches.

      even if you were to submit a patch with a massive white-space "code formatting" modification, the existing developers would, quite rightly, tell you to fuck off. if you committed it *without* asking them then they'd be fully justified in complaining and, if you persisted, in getting you fired.

      a key in the statement you wrote is "read the code". if your sole job is "reading the code", then you're not really truly involved in the development. i'm assuming that you're a useful contributor: that means you have to submit modifications. forcing *your* coding style - especially when you've clearly and up-front stated that you don't see any point in *any* coding styles - onto everyone else is bound to cause serious problems.

      bottom line is: i'm not impressed. fortunately, this conversation allows everyone else to understand *why* coding styles are important.

    5. Re:Let people code how they like by AuMatar · · Score: 1

      I've never seen how to choose variable names or when to comment in a coding style. Typically, people are expected to just know that. Every coding style guideline I've ever used has been nit picky bullshit about braces and spacing, enforced by that one anal retentive asshole every workplace seems to have.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    6. Re:Let people code how they like by halo_2_rocks · · Score: 1

      Some do, but should they really be working with you or on any kind of real project if you have to specify that they name functions and variables appropriately or that they have a design and create documentation?!? I'd rather not have to state that since it is obvious for being dismissed if you don't.

    7. Re:Let people code how they like by Anonymous Coward · · Score: 0

      That's because you have exactly zero experience of working in a team as a professional developer.

    8. Re:Let people code how they like by Anonymous Coward · · Score: 1

      Absolutely agree. I do a lot of C. I always use {}'s. It irks me when I see code that doesn't; it's a difficult to find bug waiting to happen.
      Sometimes there's a bunch of code that doesn't functionally break out, it can't be helped. Indentation is very important in these cases.

      Not a style per say, but I try to avoid including debugging that destroys the readability of its surrounding code. I like to overdrive my tools.
      I can easily log each and every place a function is called from, its arguments, its return value (needs gcc though), etc. by the addition of
      a few lines at the top of a source file, or a common header file. When I don't need that debug any more, it's rapidly removed without touching/
      breaking the source (if it was in a header) with a simple edit session.

      This was perfect for a large project I inherited with a lot of cloned code. The log file would show the same message for different paths (they
      didn't know how to include line # info :(), so you weren't sure of the real code path (sometimes you ended up debugging dead code!) executed.
      With almost no impact to the source, that technique helped identify the paths and issues.

      Style includes using types that help in this process. If I have a number of related #defines, I'll group them into an enum and typedef that.
      If 'X' is of that type, when I print it's value in the debugger, I won't get 1, 6, or whatever its numerical value is, I get its name.

      How many have used -E (gcc)? It's a lifesaver when you need it.

      So I think style is a much broader application than how something is formatted, TABs or SPACEs (it's always SPACEs, BTW). It's how
      the language and its supporting tools are applied to solve the problem, IMHO.

      CAPTCHA = pedagogy

    9. Re:Let people code how they like by AuMatar · · Score: 4, Insightful

      No, really he's not. I am quite capable of reading code with different indent styles, brace styles, etc. I do so on a regular basis, even when working with language approved styles as I regularly program in multiple languages. I have no trouble with it mixing program to program, file to file, or even function to function.
      In fact, most code bases I've worked on looked like that. And there was no noticable speedup in places that did enforce a style vs those that didn't.

      In fact, he actually tends to harm code quality. Why? Because he bogs down code reviews. Rather than looking for serious maintenance or correctness problems, we focus on his half dozen style complaints. This wastes our time and causes people to hate code reviews, or take them less seriously. The places I've worked with style guidelines all had shitty code review processes, and this was the reason.

      So no, that anal retentive asshole made everyone's job far worse. There are code style issues that matter, like naming variables well and commenting sufficiently. Formatting is not one of them, and being particularly picky about it is a BIG red flag about both a person and a company.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    10. Re:Let people code how they like by SuperKendall · · Score: 1

      The purpose of a coding standard is to make the code more readable and thus, more understandable.

      That is EXACTLY why you should let people code the way they like, as long as the way they code is consistent.

      Developers have a natural coding style they find more readable, letting them work on code they find more readable is beneficial in development.

      When you are done, yes you will find modules where code differs in look. But that does not really matter; generally code is understandable by those coming along later. It's not like someone is going to explode because they find a bracing style between two files to be different.

      Most of the time as a programmer is not spent on producing code but on skimming through other people's code and trying to figure out how something works

      And a common coding style doesn't help you at all with this, because any coding style deviating from the natural coding style of the developer is equally hard to read. As long as each module is generally consistent it will not be difficult for any developer to follow.

      A coding style/code standard should also include conventions for code patterns, comments and how to choose reasonable variable names

      Trying to mandate common sense by rulebook is often fruitless.

      these things can not be changed by a "pretty printer".

      But they can be fixed through refactoring if you were truly silly enough to have someone on a team who cannot write reasonable variable names. If you have someone who can't write good variable names a coding standard will not protect you from what follows naturally.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    11. Re:Let people code how they like by SuperKendall · · Score: 1

      Note to self, don't hire this one.

      Note to self; don't work for people who don't have a real account on Slashdot.

      The reason we enforce code style is the same that we enforce requirements traceability. We must have maintainable, auditable code.

      What I have stated in no way prevents code from being readable nor auditable. Just because modules have slightly different conventions, does not mean each is not readable and I can't imagine how any coding standard will really help auditability.

      I am not at all against auditing code; I am all for it. I am saying, don't make the initial creation of code harder than it has to be with arbitrary rules.

      Is writing code this way slower and more expensive?

      Why not reduce the overall cost by not imposing coding standards on creation of code, thus allowing more time for audits?

      I mean, are you REALLY for code quality, or just control... Because I have been under way too many managers in love of rules, not truly caring about why rules exist.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    12. Re:Let people code how they like by Anonymous Coward · · Score: 0

      Note to self, you are a moron.

    13. Re:Let people code how they like by OrangeTide · · Score: 1

      I tend to agree with you. Most of the coding style mandates are busy work, pushed down by managers who were informed by developers who insist that style is vitally important to code quality. But offer no data to demonstrate how it matters.

      I comply with my company's coding conventions for the same reason I comply with HR's annual requests for sexual harassment training. I consider it a pointless waste of time, but it's easier for me to go along with it than to resist.

      For my personal projects, I get to format the code however I want. I've had reactions from "madness!" to "this is really readable". This kind of feedback doesn't influence me much, as I feel code style is pretty subjective.

      --
      “Common sense is not so common.” — Voltaire
    14. Re:Let people code how they like by rgbrenner · · Score: 3, Insightful

      Note to self; don't work for people who don't have a real account on Slashdot.

      Seriously? How is having a slashdot account a positive personality attribute? Were you too busy reading the articles to notice what gets posted here?

    15. Re:Let people code how they like by arkane1234 · · Score: 1

      Coding standards allow a consistency across the board that will allow multiple people to work by the same standards.
      If you don't like it, tough shit. It's how the real-world operates. If you work at a place that doesn't, I pity you in the future...

      --
      -- This space for lease, low setup fee, inquire within!
    16. Re:Let people code how they like by Volanin · · Score: 1

      I got really curious now! I work mostly with C and GCC, and I would really like to know your technique to log the function calls, arguments and return value! I really can't think of a way of doing this without using a lot of macros, that would make the code unreadable... Would you mind giving me an insight? Thanks!

      --
      If I clone myself, can I call it a thread?
      If a girl winks to us, can I call it a race condition?
    17. Re:Let people code how they like by SuperKendall · · Score: 1

      Coding standards allow a consistency across the board that will allow multiple people to work by the same standards.

      Self-referrential statement is self-referrential.

      It does not produce better code to make a lot of people code in ways they would prefer not to.

      If you don't like it, tough shit.

      Hardly, you are always free to quit. I have.

      It's how the real-world operates.

      It's how anal-rentive subsets of the real world operate.

      If you work at a place that doesn't, I pity you in the future...

      Translation: Freedom Sucks

      Not that I've found, but you are free to live in your own personal jail (chances are you enjoy it as you are the jailer).

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    18. Re:Let people code how they like by SuperKendall · · Score: 1

      Seriously? How is having a slashdot account a positive personality attribute?

      Why would you like to work for anyone who is afraid that something they said on the internet be traced back to them?

      Lack of conviction and an inability to stick to a position are in fact personality traits I like to avoid in managers. They are the same people who promise you one thing in private conversation but do quite another when it counts.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    19. Re:Let people code how they like by Anonymous Coward · · Score: 0

      But a holy war of tabs v. spaces is such fun...

    20. Re:Let people code how they like by Anonymous Coward · · Score: 0

      If you think that a "style guide" is just the number of tab stops, you're dead wrong. However, if hitting the tab bar instead of the space bar slows you down, then you're still on the "don't hire this one" list. However, if knowing what requirement you're working on slows you down, that's probably a good thing, and discipline you need to learn. If documenting a memory allocation slows you down, it's probably good to take a moment and decide whether or not you should be writing your code that way. If selecting the right input validation is slowing you down, then you really ought not write any code that faces an ethernet port or modem. If declaring variables in the right system level is a pain in your ass, think about growing up.

      Yes, it's cumbersome. Yes, it's time consuming. Yes, it's the difference between engineered software and outsourced to India.

    21. Re:Let people code how they like by gutnor · · Score: 1

      There is a strong correlation between developers that cannot follow a style standard and divas. I want to believe you are a good developer, but in my experience, I have yet to work with a developer that would not comply with a style standard but would follow the rest of the code standards like patterns or framework. Especially since there is a lot of grey area: like defining the common vocabulary (like the expected behaviour of getX, createX, findX, selectX, process, run, execute, ...) which can be seen as a style but is nevertheless very important for the consistency of your apis.

      Also, most recent projects have a team working on the same codebase. Free code style, in practice, would only mean that you are working most of the time with code in a different coding style. If you work on a java project or similar, that means that you would always have several files in different style opened at the same time. That is just messy. Again, I don't think the kind of developer that find that situation desirable is the kind that strive for code consistency.

    22. Re:Let people code how they like by Anonymous Coward · · Score: 0

      Why would you like to work for anyone who is afraid that something they said on the internet be traced back to them?

      Coming from the guy hiding behind a fucking user name.

    23. Re:Let people code how they like by Anonymous Coward · · Score: 0

      Sorry, but I agree with the GP. For the following reasons:

      One: Note to self; don't work for people who don't have a real account on Slashdot. This comment comes across as petulant, and I don't have time for people who are immature.

      Two:Just because modules have slightly different conventions, does not mean each is not readable and I can't imagine how any coding standard will really help auditability. Research shows that standard format helps in readability and, more importantly, understanding. The research for this goes back to the 60s and 70s. You may not realize that it impacts your ability to read and understand, but research shows you are wrong. (Research also shows it is almost impossible for someone to accurately rate their own performance.) Also, odds are YOU won't be the one maintaining your code over its entire lifetime, and they are the ones you need to be thinking of while you write your code.

      Three: Why not reduce the overall cost by not imposing coding standards on creation of code, thus allowing more time for audits? There is so much wrong with this statement, I'm not sure where to begin... First, coding standards increase the ability of people to understand the code in the first place - reducing the number of bugs introduced. Second, creation of the code is a small portion of the overall development time and saving a small percentage of time by dumping coding standards here will hurt you far more down the road. Three, it costs far more to fix problems discovered during an audit than finding it during original development.

      Four: I mean, are you REALLY for code quality, or just control... Because I have been under way too many managers in love of rules, not truly caring about why rules exist. This shows you are not over your bad experiences and will probably bring negative baggage to a new organization. Some rules exist, and no one knows why - until you ignore them and rediscover why the rule was implemented. This isn't to say that there are bad rules out there, or that they don't always apply. However, it can take a knowledgeable, experienced person to know when they don't apply. In this case, there is a pile of research over the last several decades, to show coding standards are beneficial. I also don't of any experienced manager who has ever said, "I wish we hadn't used coding standards - it would have made life so much easier."

      Bottom line: The goal of development is not to maximize YOUR productivity - it's to maximize the productivity of the entire team, over the entire life of the project. So, if something is shown to have a net benefit across a team, everyone else needs to suck it up and realize they aren't the center of the Universe.

    24. Re:Let people code how they like by Anonymous Coward · · Score: 0

      Note to self; don't work for people who don't have a real account on Slashdot.

      It's possible he has a slashdot account but had already moderated and didn't want to undo that. So he checked the "Post Anonymously" box - just like this.

    25. Re:Let people code how they like by DutchUncle · · Score: 1

      I used to be all for total freedom. Then I started working with groups of people where the variables associated with the same thing had names like
      on_delay_time
      on_dly_timr
      OnDlyTime
      ondelay_time
      delayontimer
      feature_37_count (yes, that's the on delay timer option when it was added in relay logic 20 years ago)
      and let's not forget the transliterated French and Russian words from some other people.

      Nothing commonly searchable, nothing commonly GREPpable, never sure which things are related and which aren't. I'm not the most organized or consistent person in the world, but words have meaning and names have power, dammit. Maybe it's easier for me to type longer names because I actually had a typing class in high school, back when dinosaurs ruled the earth.

      Don't waste time reinventing the wheel. We don't need better wheels, we're not a racing team building a concept car. Don't write a brand new buffer algorithm when there are already five different ones in the code and a sixth in the language library. Don't implement a queue from scratch ESPECIALLY if you're going to get it wrong.

      If those sound controlling to you . . . too bad. I get paid to ship reliable products.

    26. Re:Let people code how they like by VortexCortex · · Score: 1

      code style is very important. Yes, we audit code. Yes, it works. We have yet to have gotten hit with a real-world exploit, critical bug or unexpected behavior from garbled input.

      Is writing code this way slower and more expensive? Hell yes,

      You can still audit code and use a code formatter. You don't write a bullshit script to run a regex on the files, instead you use software that understands the full syntax of the code and can not only reformat the text, but also catch typos as you type them. That way you don't run a compile that's doomed to error out at on syntactical error, like a missing semicolon, or misspelled type name.

      Is it faster to write code this way, thus cheaper, and just as capable of being tested and audited? Hell Yes, if you believe in using the right tool for the right job to get more work done in less time, under budget and end up with bigger bonuses and longer vacations. If "code style is very important" then why the fuck aren't you using Automatic formatting? It helps keep the code maintainable, uniform, and more easily auditable. I would agree standardizing on a style guide is a good idea; However, if the coders can save in your project's style, and audit code in their preferred style they'll actually catch more bugs... esp. if they're just getting started with your company.

      That you would pass over an applicant that understands it's syntax not spaces that matters, and there are tools to manage the spaces for your syntax, then it's a damn good thing you don't actually sign the checks or higher the applicants.

    27. Re:Let people code how they like by DutchUncle · · Score: 1

      Sometimes the coding standards *do* indicate a subtle problem.

      I started at one place writing device drivers on a processor and assembler new to me. Got some demo code working and asked my boss to take a look. One glance, and the first comment was, "Oh, this is all wrong. It's in the wrong column." I had put the op codes in column 10, like on every other assembler I'd ever used, because names could be 8 characters long, and I explained this. "Oh, we never use 8 character names; we only use 6 so it's consistent with Fortran."

      I found another job 6 weeks later.

    28. Re:Let people code how they like by darkfeline · · Score: 1

      Also, sometimes people are too lazy to log in. (I know I do that sometimes on my phone), and /. even GIVES users an option to post AC. Just because he's AC doesn't mean he doesn't have an account, and even if he doesn't how does that negatively impact him?

    29. Re:Let people code how they like by R3d+M3rcury · · Score: 1

      Also if I am making a SMALL change in someone else's code, I try to mimick the style of code around it.

      Actually, I'm just the opposite--I use my style even if it looks funny next to someone else's.

      One reason I give for not caring about coding styles is that as I get to know developers, I can easily determine who wrote a piece of code without wading through a stack of comments about Fred changed this, Bob changed that, etc. I just look at the style: I don't put spaces after parentheses. Bob does. So if I spaces in the parentheses, I know Bob was in this code for some reason and I can ask him what was going on.

    30. Re:Let people code how they like by SuperKendall · · Score: 1

      This comment comes across as petulant, and I don't have time for people who are immature.

      Nor do I; Yet I feel the topic is important enough for others to understand properly I will read your post anyway.

      It's hardly petulant to note that someone has no credibility on display, especially in a topic where knowing someone has a lot of experience is key. Over decades I have been coding; and posting to Slashdot about coding. From the AC what do you know at all? Nothing except he's some kind a manager, and one of the more annoying kinds at that.

      What do we know of you? Even less, except that you need correction.

      Research shows that standard format helps in readability and, more importantly, understanding.

      Which doesn't matter for auditing, because I stated it was important to be consistent in a module.

      First, coding standards increase the ability of people to understand the code in the first place

      Not if your coders had any degree of skill whatsoever. Coders can read code. Try it sometime.

      Second, creation of the code is a small portion of the overall development time

      That is true...

      saving a small percentage of time by dumping coding standards here will hurt you far more down the road

      The proofs; you have none. Just assertions with no weight AC poster. I have decades of coding experience and I can tell you going into an old code base that has had coding standards applied, vs one that has not means NOTHING. You think those coding standards will stay the same for five years? For ten? Neophyte. They change and so in the end the code looks different in different places ANYWAY and what you have left is the same issue only the people not bothering with coding standards got more work done with a better quality code base.

      The readability does't matter because coders can read code.

      This shows you are not over your bad experiences and will probably bring negative baggage to a new organization.

      It means I pick my managers more carefully, something younger coders should be aware is possible.

      I bring no negativity into anything I do, only wisdom. I don't even mind working in projects that have coding standards; a company is free to waste time in any way they see fit. I am just letting you know what works better, again from a far deeper base of experience than you present.

      there is a pile of research over the last several decades,

      There is a pile of something for sure. Boy do I love totally invalid research that proves a preconception is true. You guys have the circle jerk down to kabuki level mastery.

      I also don't of any experienced manager who has ever said, "I wish we hadn't used coding standards - it would have made life so much easier."

      A) Now you do.
      B) You have not ever asked.
      C) Managers all know the "proper" answer to give and give it even if they disagree.

      The goal of development is not to maximize YOUR productivity - it's to maximize the productivity of the entire team

      Correct - and that is shy dropping coding standards is better, because it improves productivity for the entire team, along with not wasting hundreds on man-hours on the definition that everyone will grow to be annoyed by.

      What you do not realize in all this is that I am the ultimate egoless programmer, I have in all my jobs striven to make the TEAM work better, be more productive and also to help every member of the team grow as much as possible. That is not helped by the shackles you would impose, but the conformity you would try to mold them into. That is how you kill things, not make them stronger.

      Enjoy your process of slowly damaging programmers; I will continue to make them better than they were.

      I will let you have the last response Ghost; but I cannot justify spending further time reading your IT manager 101 regurgitated nonsense.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    31. Re:Let people code how they like by SuperKendall · · Score: 1

      It's possible he has a slashdot account but had already moderated and didn't want to undo that. So he checked the "Post Anonymously" box - just like this.

      I respect why you are posting AC.

      But he has entered into the discussion in a serious enough way, he must remove the mask or else face the loss of credibility that is inevitable. Other moderators will come along to do that work.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    32. Re:Let people code how they like by Anonymous Coward · · Score: 0

      > I am quite capable of reading code with different indent styles

      No you are not. You just have not yet seen bad code. Imagine 4000 lines in a single function with indentation errors. Or rather than errors, mix of different styles, created by dozens of developers. Format the same code to use a single style and it becomes much more readable (but obviously still needs a lot of refactoring).

      > we focus on his half dozen style complaints

      By style you obviously mean formatting here. You should just automate formatting and forget it. Use e.g. astyle if you have nothing better. Only comment in code review about formatting should be that you did not do code formatting. Then it takes no time. Obviously you can configure your version control to reject commits where formatting has been forgotten, so you don't even need to talk about it in code reviews at all, if you don't want to.

    33. Re:Let people code how they like by AuMatar · · Score: 1

      >No you are not. You just have not yet seen bad code. Imagine 4000 lines in a single function with indentation errors. Or rather than errors, mix of different styles, created by dozens of developers. Format the same code to use a single style and it becomes much more readable (but obviously still needs a lot of refactoring).

      I've seen 10K. The fact it was 10K was pretty bad. The fact it had indentation changes didn't slow me down at all. I'd agree if we were talking no indentation at all, but mixing lengths doesn't matter one bit.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    34. Re:Let people code how they like by chrismcb · · Score: 1

      I do not see any point in coding styles whatsoever. All they do is slow down coding for all but the two guys that actually like the coding style as defined; for the rest it's needless busy-work to comply.

      You don't maintain anyone else's code do you? One of the reasons to a consistent coding style is to make it easier to read someone else's code. If everyone uses a consistent style, it is much easier to read code, than if the style constantly changes.
      For the most part, it shouldn't take too much time to pick up a new coding style. Yeah it might be frustrating, and a bit annoying for a while. But the short term pain for you to learn a new style, is far outweighed by the ease of code maintenance, by you and everyone else in the future.

    35. Re:Let people code how they like by chrismcb · · Score: 1

      Why? Because he bogs down code reviews. Rather than looking for serious maintenance or correctness problems, we focus on his half dozen style complaints. This wastes our time and causes people to hate code reviews, or take them less seriously.

      The formal code review process is NOT where you focus on style issues, unless they are glaringly incorrect, or potential bug farms. The point of a code review is to find bugs, not fix the style.
      That is your problem. Not the adherence or lack of to a style.

    36. Re:Let people code how they like by chrismcb · · Score: 1

      The fact it had indentation changes didn't slow me down at all.

      Good for you. But can you say the same about the junior programmers that come in behind you? Will they be able to process random code as fast as you?
      Stlye isn't just about indentation either. It is about naming consistency, so you can easily tell what sort of object a variable is, without having to tract it. It is about passing arguments correctly to make code more resuable, and so on.
      It is way more than about whether to use tabs or spaces, or 4 character indents versus 8.

    37. Re:Let people code how they like by AuMatar · · Score: 1

      Maybe you should actually read my posts. I say outright that some style things are important and some aren't. Meaningful variable names fall into the are category. Indentation doesn't.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    38. Re:Let people code how they like by AuMatar · · Score: 1

      I don't disagree with you on what a code review *should* be for. And when done right (there are various ways to do it right), they're very helpful. But my experience is that they always devolve into pointless style nitpicking when you throw style guides and That Anal Retentive Guy into the code review.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    39. Re:Let people code how they like by SuperKendall · · Score: 1

      You don't maintain anyone else's code do you?

      Over the years I have, many times. Even now I still do occasionally.

      One of the reasons to a consistent coding style is to make it easier to read someone else's code.

      And my experience is exactly why I can say with 100% certainly that your claim is UTTER BULLSHIT.

      This the you and so many other people appear to not understand is what it's like to maintain code that has lived for a decade or more. It doesn't matter what coding standards you apple now; over years those standards WILL CHANGE. So why are you spending work now for "consistency" that in teh end will no longer be consistent?

      Part of maintaining older code is in fact being able to read a number of different approaches and formats and still being able to understand what is happening. If you cannot do that the band-aid of coding standards will not help you one bit.

      For the most part, it shouldn't take too much time to pick up a new coding style.

      Of course not. But the time to create it matters. The time to learn it matters. The fact that programmers have a coding style they WILL revert to if they can means that they are wasting internal mental energy on translation. All of that matters. All of that is a waste. That is what I'm saying - why waste energy on things that do not really matter or help you?

      I have repeatedly mentioned I have worked under other coding standards before. I don't necessarily mind; I can do that without problem. But I also understand now after decades how foolish and pointless it is to do so, and am simply trying to help other avoid the same trap if they can.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    40. Re:Let people code how they like by Anonymous Coward · · Score: 0

      Note - SlashDot made this paste very messy (it doesn't like white space) even with code tags.
      You should be able to copy/paste and build using the example command line.
      Please consider -->
      /* gcc -g -Wall -DDBG_EXTRA example.c -o example \
                                                && ./example A BB 'the end' Not_Printed 2>extra_log.txt */
      #include "stdio.h"
      #include "string.h"

      static int a_func(int);
      static int b_func(int, char const *);

      #ifdef DBG_EXTRA
      #define a_func(a) ({ /* Imagine trying to put this at each call... */ \
          int const arg_ = (a);\
          int const rc_ = (a_func)(arg_); \
          fprintf(stderr, "[%d] %2d = a_func('%s' = %d);\n", __LINE__, rc_, #a, arg_); \
          rc_; /* Make sure the block returns the value we're interested in */ \
      })
      #define b_func(a, b) ({ /* We ignore the possibility of 'b' may have */ \
          int const arg_ = (a); /* side effects, but they can be managed, too. */ \
          int const rc_ = (b_func)(arg_, (b)); \
          fprintf(stderr, "[%d] %2d = b_func('%s' = %d, '%s' = \"%.12s\");\n", __LINE__, rc_, #a, arg_, #b, b);
          rc_; \
      })
      #endif /* DBG_EXTRA */ /* You have to imagine this on a much larger scale... */
      int main(int argc, char *argv[])
      {
            int argx = 0;
            int rc = -1;

            if ( a_func(argc) > 0 ) {
                  while ( argx++, --argc ) {
                        fprintf(stdout, "arg :: %.2d = ", argx);
                        rc = b_func(argx, argv[ argx ]);
                        if ( 0 == rc ) {
                              break;
                        }
                  }
            }

            return ( rc );
      }
      #undef b_func
      static int b_func(int const argx, char const *arg)
      {
            int rc = -1;

            if ( a_func(argx) > 0 ) { /* It's just an example, not real logic */
                  if ( 0 == strcmp("the end", arg) ) {
                        rc = 0;
                  }
                  fprintf(stdout, "\"%s\"%s\n", arg, (0 == rc) ? "." : ",");
            }

            return ( rc );
      }

      #undef a_func /* The only caveat is that we have to #undef (and possibly re-
                                        define if after if the function is called later) it here. */
      static int a_func(int const argc)
      {
            return ( argc > 0 );
      }

    41. Re:Let people code how they like by MadKeithV · · Score: 1

      Coding style is not just be about making code look pretty (according to someone's personal definition of pretty). The purpose of a coding standard is to make the code more readable and thus, more understandable. Having the code look consistent helps in that regard.

      No, it doesn't. Making the code more consistent just makes it more consistent in whatever readability state it started, which might be total batshit insanity if you actually think applying a coding standard is going to make your life noticeably easier (but hey, now at least it's consistently shit!).
      I'll take a stylistic mix of well-written but readable code over hundreds of pages of unenforcible coding standard (note: coming from a C++ background, where automatic beautifiers can do a better job fucking up your code than an ex-Java programmer that hasn't been told about manual memory management).
      I can read Shakespeare, Tolkien, Edgar Allan Poe, HP Lovecraft, M.R. James and Robert E. Howard just fine, and they don't have the same style at all. Okay, it took some getting used to Shakespeare, but then the style actually added to what was being expressed. Learn to read each-other's code, dammit. It's already more than structured enough - it's a PROGRAMMING LANGUAGE. That anal retentive thing called a "compiler" does more than enough. Decent developers always have a perfectly acceptable coding style of their own, and will make small adaptations to the common implicit standard where appropriate.

    42. Re:Let people code how they like by Anonymous Coward · · Score: 0

      It means that they comply with the laws defined by that individual's monkey-sphere.

  9. WTF per minute is the real code quality metric by Anonymous Coward · · Score: 1

    clearly readable code is the first step toward getting it accepted.

    1. Re:WTF per minute is the real code quality metric by multicoregeneral · · Score: 1

      Nonsense. The real code metric is whether the final product performs as the client expects it to. Your code could have been written by pygmies and have no formatting at all. If it does the job, you've succeeded. Sure, maintainability is nice. But good practice is often a luxury that slows down the process. At least in the world of consulting, nobody cares if you've written a gem or a turd, as long as you've made your deadline.

      Outside the world of consulting, maybe in R&D where things like scalability matter, I could see some kind of guided standard of best practices coming into play. But even then, your code is still subject to the whim of people who may determine their best practices based on personal bad habits.

      At the end of the day, the best you can hope for is that the next guy who picks the project up understands the basics of the job. In my experience, this is incredibly rare. I've seen volumes of perfectly good code just thrown away and replaced with buggy semi-functional shit because the next guy on the project refuses to understand the basics of the language you're working with. This is very common on PHP and Asp.Net projects in my experience.

      --
      This signature intentionally left blank.
  10. It doesn't matter by halo_2_rocks · · Score: 1

    Get a program to refactor the code into whatever style you want. I'm amazed people still have make this an issue.

    1. Re:It doesn't matter by ShanghaiBill · · Score: 1

      Get a program to refactor the code into whatever style you want.

      Because when you check-in your refactored code to the {git/svn/whatever} repository it shows nearly every line as a change, and makes it difficult to see the one or two lines that actually changed. The repository quickly because bloated with meaningless changes as dueling Aspies engage in coding style wars.

    2. Re:It doesn't matter by czth · · Score: 1

      Sounds like a recipe for source code churn and messy revision control diffs, not to mention the difficulty of automatically reformatting any style guidelines beyond simple layout. Take the example in TFA, even - how do you "reformat" the requirement to have a throw/break/return/fall through comment at the end of every switch case? Not every coding convention can be reduced to the level of a GNU indent tool parameter.

    3. Re:It doesn't matter by Anonymous Coward · · Score: 0

      The answer to this is that checked-in code must conform to one coding style. While everybody codes in their own style, a tool reformats the code on its way out of and into the repository. Wouldn't it be great if that worked?

    4. Re:It doesn't matter by halo_2_rocks · · Score: 1

      Wow. You are a smart one. You do realize you can have a "style" that is used for check-in and one that you refactor to into when you check-out?!? But, I'm sure you never thought about it and so you make a non-issue an issue.

    5. Re:It doesn't matter by halo_2_rocks · · Score: 1

      Not really, as I've pointed out - if you use a refactoring program - you can have it refactor into a style for check-in and one that you use (and like) when you check-out. It isn't that hard. Most people aren't very bright when dealing with this and impose archaic rules when it isn't necessary.

    6. Re:It doesn't matter by halo_2_rocks · · Score: 1

      If that is what you mean and you have to specify that, exactly why would you hire this person in the first place and why are they programming exactly?!? I don't think you need to state obvious things to people. It makes both you and them feel stupid and it is talking down to people. It should just be assumed.

    7. Re:It doesn't matter by slashping · · Score: 1

      So, what if your check-out style doesn't have a // fall through comment when you intend to fall through, and you check the code back in. Somebody else checks the code out, but has a check-out style with // fall through comments. Does the refactoring program put the comments in automatically ?

    8. Re:It doesn't matter by ZombieBraintrust · · Score: 1
      No that may still produce changes. Style changes might not be reversible.

      styleA(styleB(document)) != styleB(styleA(document))

    9. Re:It doesn't matter by czth · · Score: 1

      Have you ever actually done this?

      How does it work for higher-order rules like the example I mentioned (where the program would have to determine programmer intent)? How about naming conventions, some of which may even be lossy in conversion or impossible to synthesize mechanically?

      You may be able to use a "refactoring program" for brace placement and spacing, but coding styles are much more than that.

      I'm not advocating for a rigid enforced coding style (at all), but it doesn't make sense to defend not having one by claiming that a "refactoring program" can (right after it solves the halting problem) convert any style into any other style.

    10. Re:It doesn't matter by halo_2_rocks · · Score: 1

      If you are concerned about where a comment is refactored, you have bigger problems than refactoring. Comments don't do anything.

    11. Re:It doesn't matter by halo_2_rocks · · Score: 1

      That doesn't make the least bit of sense. Please tell me how code could be refactored and not refactored into another style and checked-in? Granted, an irregular comment might be moved on a rare occasion, but that isn't code so who cares?!?

    12. Re:It doesn't matter by halo_2_rocks · · Score: 2

      If you have to enforce a standard for using proper names of variables, functions, and classes and documenting your code - YOU ARE HIRING the wrong people to start with. I'd fire anyone that you have to actually state that to or even if I was forced to point that out to.

    13. Re:It doesn't matter by ZombieBraintrust · · Score: 1

      If you replace spaces with tabs then the number of spaces that existed prior to the replace is gone. If the commit style does not have strict rules about spacing then your going to have changes on every line.

    14. Re:It doesn't matter by dfghjk · · Score: 1

      You have a poor understanding of what refactoring is.

    15. Re:It doesn't matter by dfghjk · · Score: 1

      I would like an example of a "refactoring program". Beautifiers are not refactoring programs.

      "refactor" is a term that doesn't need to exist at all, much less be a term for re-"pretty print".

      Coding style guidelines go beyond what any beautifier can achieve.

    16. Re:It doesn't matter by real-modo · · Score: 1

      Comments don't do anything.

      In golf, there is a term for golfers that aim to get around the course in three (lost balls) and don't replace divots properly. They're called coarse golfers. "Comments don't matter" is the attitude of a coarse programmer.

      Any fool can make a computer do what he wants. Professional programmers are communicating with other programmers via the code. Good comments aid that immeasurably, but because your attitude is prevalent they are also rare.

    17. Re:It doesn't matter by halo_2_rocks · · Score: 1

      Clearly, you don't understand that state of art in this field. Refactoring programs go far beyond beautifiers. Intelli-sense is such a program. They actually understand the syntax of the underlying programming language and can move text, highlight it, bold it, add italics, add syntax, add whitespace (tabs, etc) and so on depending the requirements. This is essential if you are going to do identify where functions, parameters, blocks and other parts of a programming language start and end when stylizing an output. In addition, if you must specify in your coding style guidelines that the programmer must use descriptive names for things - you are hiring idiots to begin with.

    18. Re:It doesn't matter by halo_2_rocks · · Score: 1

      If you don't realize comments don't impact the functionality of a program what-so-ever, then you aren't qualified to hire programmers. Your response is complete non-sense and ridiculous.

    19. Re:It doesn't matter by FalseModesty · · Score: 1

      If it's so easy, what's stopping you from refactoring your code to fit the common style? I'm amazed you still have to make this an issue.

    20. Re:It doesn't matter by multicoregeneral · · Score: 1

      Depends. I think you would be shocked to find out how common it is to find shops that use no repository system at all. Unless they've really thought it out, and come to understand that you need a repository system, even when you have only one developer because you don't want to lose your work -- They often just don't implement one. Which leaves new developers in the dark on the history of a project when they come into it. Even in shops where they have multiple developers, you don't always have one.

      --
      This signature intentionally left blank.
  11. Let people code how they like and by Anonymous Coward · · Score: 0

    Let the company use a code formatter on the final code. Or just code in assembler, only one way with it.

    1. Re:Let people code how they like and by Anonymous Coward · · Score: 0

      It does matter. Here's why.

      I recently took over a project from another contractor who thought that ONE line of comment per 500 lines of code was more than enough.

      There was about 10k lines of code which I've had to virtually re-write to make:-
      1) it maintainable
      2) have some semblance of decent error handling (there was none before)
      3) make it production quailty. There were so many holes in his so called production quality code, you wouldn't believe it.

      He also used deeply nested if...ifthenelse rather than a case structure and obviously didn't know about functions and procedures.

      Yes coding style matters. It matters a lot. If you had been coding for as long as I have (40+ years) then it is a question you don't need to even ask.

  12. Style has always mattered by Anonymous Coward · · Score: 2, Insightful

    Mine is best, yours sucks to the extent that it isn't mine and most editor/IDE authors are too lazy to make mediating style a critical feature; but they seem to be slowly getting there. Now get those goddam spaces out of my indents so I don't have to get carpal tunnel, or else make me an editor smart enough to automaticly import them as tabs and export them as spaces so that we can just. stop. talking. about it.

    1. Re:Style has always mattered by dfghjk · · Score: 1

      Editors have done this tab/space importing stuff for 30 years and that's just as far back as my memory goes of them. The problem is that you use and editor that doesn't understand this and that explains why you care about something you shouldn't.

      Incidentally, editors that understand and fix space/tab issues with identation are frequently the ones broken by these stupid variable tab "rules" that so many here seem to think are the right answer. For an editor to get space/tab interpretation right, it has to know what a tab is and that meaning cannot vary from file to file. That's why it's 8.

    2. Re:Style has always mattered by FalseModesty · · Score: 1

      What, your editor is too dumb to insert the right number of spaces when you hit enter? Ouch.

    3. Re:Style has always mattered by multicoregeneral · · Score: 1

      I strongly disagree. Seeing as it's my professional obligation to let you know that your code sucked, and I've replaced it with something superior, because you're a know nothing blowhard. Sure is a good thing that I'm a pragmatic genius who knows everything there is to know about anything. All these edits I made to your program without really understanding the basics of the system could have been hell to iron out otherwise.

      --
      This signature intentionally left blank.
  13. It depends on whatcha mean when you say style by WaffleMonster · · Score: 1

    There are no shortage of automated systems perfectically capable of (re)formatting code. For this reason personal choices with regards to tabstops, bracing, spacing and general layout simply does not matter.

    As far as non-decorative conventions and comments..consistency obviously generally helpful.

    I do believe there is diminishing returns on overdoing it with added danger of folks not being able to function effectivly in environments where code is produced by other groups outside your administrative control using different conventions.

    In short try to be consistent but never make a decision which presums either yourself or others have been consistent.

    1. Re:It depends on whatcha mean when you say style by clodney · · Score: 1

      There are no shortage of automated systems perfectically capable of (re)formatting code. For this reason personal choices with regards to tabstops, bracing, spacing and general layout simply does not matter.

      Until source control systems work on semantics and not textual diffs, it is not as simple as that. If I get your code, reformat it to my style, change 2 lines and check it back in, I have completely polluted it as far as a diff goes.

      If you want to have a rule that says all code gets run through a formatter prior to check-in, that would work, but it would mean that everyone would spend lots of time converting to and from the approved check in style.

    2. Re:It depends on whatcha mean when you say style by Fwipp · · Score: 1

      I'm not advocating this, but it's simple enough to do this with, say, automatic git hooks (pre commit, reformat the code, on checkout, format it back how you like it). No extra work on the developer's part.

    3. Re:It depends on whatcha mean when you say style by AuMatar · · Score: 1

      Unless you use a version control method which can autoformat on checkin and checkout

      --
      I still have more fans than freaks. WTF is wrong with you people?
    4. Re:It depends on whatcha mean when you say style by ZombieBraintrust · · Score: 1

      Your assuming that reformatting the code is reversible. Semantic information can be lost in the first change that can not be recreated on commit from the source document. There would still be plenty of risk for fake difs.

    5. Re:It depends on whatcha mean when you say style by mysidia · · Score: 1

      Until source control systems work on semantics and not textual diffs, it is not as simple as that. If I get your code, reformat it to my style, change 2 lines and check it back in, I have completely polluted it as far as a diff goes.

      Don't do that. Have a policy, that auto formatter may not be run, after a cvs/svn update, except against code that contains no other changes, and it has to be committed as a revision for just the formatting changes.

      So:

      cvs update && sh formatter.sh && cvs commit -m 'ran code autoformatter' # ALWAYS run formatter and commit any changes by the formatter immediately after a cvs update

      (Execute your code edit)

      sh formatter.sh

      cvs commit -m 'revision comment'

    6. Re:It depends on whatcha mean when you say style by FalseModesty · · Score: 1

      Seriously? You are reading the code, fixing bugs, and you find formatting problems. So you back out your half-complete changes, fix the formatting, commit that change, then re-apply your fix-in-progress? You actually do that? Of course you don't.

      The better policy is that code must be formatted correctly when it is committed the first time. Which is why we have style guidelines in the first place.

      Coders should spend their time looking at the code, not getting distracted by style variations.

    7. Re:It depends on whatcha mean when you say style by mysidia · · Score: 2

      Seriously? You are reading the code, fixing bugs, and you find formatting problems. So you back out your half-complete changes, fix the formatting, commit that change, then re-apply your fix-in-progress?

      NO. What part of dedicated commit for formatting changes do you not understand?

      You never leave changes from a previous session uncommitted; always commit all changes before leaving the desk.

      Before you start working on any code, you update your working directory from the repository. You correct any formatting problems and commit, after update from the repository, and you do this when you have not yet made any changes to the code, and 'svn diff' is empty.

      If you discover any formatting issues, you ignore any formatting issues you see, DO NOT CHANGE THE FORMATTING, while you are coding, finish your code changes, commit that.

      Then, only after your code changes are fully committed, you run the formatting script, and commit any formatting changes.

      Your diffs will then not be polluted.

  14. Instant Code Style fix by ravenknight · · Score: 1

    Ctrl+K, Ctrl+F

    Presto, you've got your coding style for code that you didn't write.

    1. Re:Instant Code Style fix by ShanghaiBill · · Score: 4, Funny

      Ctrl+K, Ctrl+F

      Presto, you've got your coding style for code that you didn't write.

      Doesn't work for me. Ctrl+K deletes the current line, and Ctrl+F moves the cursor forward one character. What version of emacs are you using?

    2. Re:Instant Code Style fix by ravenknight · · Score: 1

      we've got a heretic here that doesn't reconfigure his hotkeys to match the one true editor :P

      However, I left out pointing out that that that combination was for visual studio simply because I was waiting for an emacs reference.

    3. Re:Instant Code Style fix by multicoregeneral · · Score: 1

      Cute. I see you're a Pico fan.

      --
      This signature intentionally left blank.
    4. Re:Instant Code Style fix by maxwell+demon · · Score: 1

      What version of Emacs are you using? For me, Ctrl+K only deletes the part of the line following the cursor. Unless the cursor is at the end of the line, in which case it appends the next line to it.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    5. Re:Instant Code Style fix by Anonymous Coward · · Score: 0

      Hmm, In my emacs ^K moves the point up one line.

  15. Stay tuned for tomorrow's blog by Anonymous Coward · · Score: 0

    Does chewing food with your mouth closed matter?

  16. Depends by gnomff · · Score: 1

    It totally depends on your audience. Is this code something that must be read by one person or a hundred? If its one other person, it probably doesn't matter unless they have strong feelings. If its 100 people then you should have a standard template so people don't waste time arguing. Personally, I know that my code will be read during a code review of about 5 people. I need to make sure that all of those 5 people are comfortable reading it. For example, I happen to be working in C# and some of my co-workers hate the var type declaration, so I don't use it. Some of them have strong feelings about always using braces, so I do. At the end of the day, as long as your code is easily understandable the minutia of style guides are just to keep other people from getting their knickers in a twist. That can be far more important than whatever code you are working on.

  17. Do not invent a coding style by Anonymous Coward · · Score: 1

    Dont invent your own style guide, use one from a book. Like Clean Code.
    This prevents discussion and new team members might already know the rules when they join in.

  18. What's important is consistancy by Anonymous Coward · · Score: 0

    Little differences -- like whether you put your bracket on a separate line from your condition, or how many blank lines you put in -- are not really important. What's the most important is that, when you modify existing code, you match the style of that code. Nothing's worse than a block of code that follows a different style than the code around it.

  19. A consistent style can be very useful by Anonymous Coward · · Score: 0

    I've worked at a company that had a product that was open source (GPL & LGPL). We licensed the source code to other companies under non-GPL terms. One of the things that made our large project useful to them was the consistent coding style we used throughout. None of us loved the style, but it wasn't terrible and having 20+ developers all write the code the same way with the same conventions made it much easier for us to work together and with our OEM customers.

  20. Exception to Betteridges? by Anonymous Coward · · Score: 0

    This is the first headline question I've seen that should probably be answered with yes.

    Though the rest of the law applies, in that it is a completely useless question.

    Next week's headline: "Do code comments matter?"

  21. Python Indentation: Style is the language by theodp · · Score: 1

    Python Reference Manual: 2.1.8 Indentation: Leading whitespace (spaces and tabs) at the beginning of a logical line is used to compute the indentation level of the line, which in turn is used to determine the grouping of statements. First, tabs are replaced (from left to right) by one to eight spaces such that the total number of characters up to and including the replacement is a multiple of eight (this is intended to be the same rule as used by Unix). The total number of spaces preceding the first non-blank character then determines the line's indentation. Indentation cannot be split over multiple physical lines using backslashes; the whitespace up to the first backslash determines the indentation.

    1. Re:Python Indentation: Style is the language by mrbester · · Score: 1

      Which is all fine and dandy if your company primarily writes code in Python where the whitespace is a fundamental part of the language. For everybody else who has to switch between C++ / Java / C# / CSS / HTML / SQL / JavaScript / Perl / PHP etc. and doesn't use Python *at all* there are "best practices" for coding style in each, most contradicting each other.

      --
      "Wait. Something's happening. It's opening up! My God, it's full of apricots!"
    2. Re:Python Indentation: Style is the language by Anonymous Coward · · Score: 0

      I hate grouping by whitespace, to easy to screw up when moving/copying code. I want parentheses or at least begin/end constructs.

    3. Re:Python Indentation: Style is the language by AuMatar · · Score: 1

      And that's why I've wasted weeks of my life fixing Python bugs due to developers using different amounts of spacing. Python took the worst possible path- requiring whitespace to have meaning, but not requiring a specific type/amount of whitespace. Had they made n spaces the requirement for an indent and anything other than n an error, it would have been fine. As it is, it's completely broken and a large cause of errors on every python programmer with more than 1 dev I've ever worked on. It's to the point that when I work on python, I copy the spacing from the line above and paste it to make sure it works.

      Also, the choice makes it damn near impossible to use google as a resource. You can't copy paste from the web and get it to compile without worrying about the spacing on every line. Where any other language just works, and you can make it look pretty once you've tested it.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    4. Re:Python Indentation: Style is the language by mysidia · · Score: 1

      This is why I used to think Python was cute, but have since switched to Ruby.

      Python is such a PITA with regards to its sometimes inconsistent indentation and code block delineation rules.

    5. Re:Python Indentation: Style is the language by Clueless+Moron · · Score: 2

      Well maybe that's going to be fixed. Let's see:

      >>> from __future__ import braces
      File "", line 1
      SyntaxError: not a chance
      >>>

      Nope.

      PS: That's real, try it yourself

    6. Re:Python Indentation: Style is the language by darkfeline · · Score: 1

      Learn to use the tool before blaming it: http://www.python.org/dev/peps/pep-0008/ The best way to describe Python is that it is a real tool. Quoting http://cristal.inria.fr/~weis/info/commandline.html, it is not a "homeowner's toy" like Java which holds your hand with type-checking, etc. but a drill that does the job you tell it to. If you want to shoot yourself in the foot, Python's not going to lock itself and say to you in a calm, reassuring voice, "Hey, are you all right? I'm sure you didn't mean to do that." It's going to f*cking blow away your feet, because that's what it was designed to do and that's what you used it to do. Python doesn't tell you what you should do, it does what you tell it to do. If you decide to mix tabs and 2-spaces and 4-spaces and 2-space-tab-3space, Python lets you do that. Don't come crying to mommy if it blows up on you tough. Another thing is to use a proper IDE/text editor. Any competent IDE can easily replace tabs with spaces or vice versa, as well as highlight syntax errors. The fact that you have so much trouble with it suggest that you are not using such an IDE. I would suggest Vim with some of very good Python plugins and syntax highlighting, as well as Syntastic for syntax errors. I have had no problems copy pasting code from sites I've found with google. Perhaps the problem is that you don't know how your web browser/OS's copy pasting works? Or that the code wasn't properly formatted properly in the first place, in which case I wouldn't copy paste without reformatting it anyway, no matter the language.

    7. Re:Python Indentation: Style is the language by darkfeline · · Score: 1

      Ugh, I keep forgetting that /. doesn't display newlines and there's no edit button. Here it is again in a more readable format.

      Learn to use the tool before blaming it: http://www.python.org/dev/peps/pep-0008/ [python.org]

      The best way to describe Python is that it is a real tool. Quoting http://cristal.inria.fr/~weis/info/commandline.html [inria.fr], it is not a "homeowner's toy" like Java which holds your hand with type-checking, etc. but a drill that does the job you tell it to. If you want to shoot yourself in the foot, Python's not going to lock itself and say to you in a calm, reassuring voice, "Hey, are you all right? I'm sure you didn't mean to do that." It's going to f*cking blow away your feet, because that's what it was designed to do and that's what you used it to do. Python doesn't tell you what you should do, it does what you tell it to do. If you decide to mix tabs and 2-spaces and 4-spaces and 2-space-tab-3space, Python lets you do that. Don't come crying to mommy if it blows up on you though.

      Another thing is to use a proper IDE/text editor. Any competent IDE can easily replace tabs with spaces or vice versa, as well as highlight syntax errors. The fact that you have so much trouble with it suggest that you are not using such an IDE. I would suggest Vim with some of the very good available Python plugins and syntax highlighting, as well as Syntastic for syntax errors.

      I have had no problems copy pasting code from sites I've found with google. Perhaps the problem is that you don't know how your web browser/OS's copy pasting works? Or that the code wasn't properly formatted properly in the first place, in which case I wouldn't copy paste without reformatting it anyway, no matter the language.

    8. Re:Python Indentation: Style is the language by AuMatar · · Score: 1

      Hey, I have a jackhammer with a very fragile glass tube filled with poison gas. Want to use it? Why not? It's not safe? Don't blame the tool, learn to use it! ....Or just don't use shitty tools.

      Your argument would have some merit if the tool gave you the freedom to do something powerful that could be misused. C/C++ pointer arithmetic, for example. Or manual memory management. But indenting? Nope, that argument doesn't remotely pass the smell test, because the feature doesn't allow you to do anything new with the language. It was a design mistake because Guido didn't think things all the way through. And now he's stuck with it, unless he wants to break backwards compatibility. Given that there's plenty of other options out there that are just as good as Python, it's easier just to avoid Python and use less flawed tools.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    9. Re:Python Indentation: Style is the language by Anonymous Coward · · Score: 0

      Great. Now, do I write

      foo = (bar, baz, quux,
          quuux, quuuux)

      or

      foo = (
          bar, baz, quux, quux,
          quuuux
      )

      or any of the other many and varied indentation styles Python will accept in practice?

      You can't get away from this. Even Python allows a whole load of variation.

    10. Re:Python Indentation: Style is the language by marcosdumay · · Score: 1

      Those kind of things are not even the reason I love Python, but would be enough to make me like it if I didn't love it already.

      Yeah, giving meaning to blank space is bad. Yet, the rest of the language is good enough to compensate for that. (And, for the GP, you shouldn't just be pasting code from an example and not reviewing it anyway, it not compiling is a feature.)

  22. Java rulez by Anonymous Coward · · Score: 0

    Yes it matters. And one should not have one coding style, but follow each language naming conventions. Java, with its firm naming conventions and no legacy issues, is the far most readable code in real life, because most of the devs are told to follow the naming conventions early on. C#, on the other hand, is made to be just as readable, but due to large number of C/C++ devs coding in it, it is usually a mess, overflowing with underscores and other convention breaking stuff useless in the object oriented world.

    As always, convention over configuration. Readable code is usually a good code. Can't stress this enough.. there is nothing worse, than having a team member, coding only in "his" style.

  23. Depends... by WhackAttack · · Score: 1

    In my opinion, it depends. For a single person coding and making some program (doesn't even have to be in a company) and not planning on putting on sourceforge or something, it probably doesn't matter. In a company where code is shared and debugged between lots of people, yes it does. So all in all, formatting probably does matter in the long run.

  24. Expertise Boosting Article by ohnocitizen · · Score: 1

    This isn't the sort of thing anyone really disagrees with. It is more of a learning article, or a "I have expertise in this field and here is proof" article, than anything really worth discussing on its own merits. Even the inevitable tabs vs spaces, same line vs next line bracket discussions have little merit: In a large organization/community - its best to stick to published guidelines for a given language.

  25. Code style, not formatting style by gman003 · · Score: 4, Insightful

    I don't really care how you *format* your code. Do you put the brackets on the same line as the beginning statement? Do you put a space between the function name and parentheses? Do you double-space your code? I don't give a fuck. That's all syntax. It's easy to figure out.

    Coding style is more important to me, how the actual *code* works. Do you initialize your variables as soon as possible? Do you properly use for loops and while loops? If you use recursion, does it make sense? Do you give your variables meaningful names like $activityType, or useless ones like $_a? How do you decide when to break something out into a function?

    I work on a project with several other people. We all have our unique styles, both for format and for code. I, for instance, have been told I code with a "LISP accent", rarely storing the return values of a function in a variable, rather using the return value as an argument to another function. Another puts a blank line between nearly any two statements. Another assiduously follows some code formatting standard nobody else in the company has read.

    Although it can make it harder to work on each other's code, it has one benefit - you can easily tell who wrote the code. "Putting the braces on a new line? This must be Pete's code!" or "There's an underscore at the front of every variable name? This must be Jimmy's code!" or "There's a for loop that starts ''for (;;){''? This must be Kevin's code!".

    And if I do go in to "someone else's code" and change or fix things, I follow their style, more or less. Unless I'm completely rewriting a section, or making enough of a change that it should be considered a rewrite.

    1. Re:Code style, not formatting style by AuMatar · · Score: 2

      I like you. There are style things that are important, but it's not how the code is laid out in the editor. Concentrate on the important things, not the things everyone has to deal with.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    2. Re:Code style, not formatting style by Anonymous Coward · · Score: 0

      You really shouldn't be relying on code formating to figure out who wrote something. Developers should be in the habit of signing their name in the comments when they new new functions or make adjustments. This takes out the guess work and makes the code changes much easier to follow.

    3. Re:Code style, not formatting style by Rakshasa-sensei · · Score: 1

      As said, coding style on that level is something everyone who writes code professionally can adapt to.

      When learning at university I was very focused on writing the cleanest, best coding style possible and that kind of focus has paid off. You end up rewriting code many times but at the end you just get it, your code feels right and people tell you your code is good.

      If you haven't spent every day of writing code back in university trying to figure out how to write clean code then you're more than likely one of the people I curse daily today.

    4. Re:Code style, not formatting style by Anonymous Coward · · Score: 0

      Just for reference, underscores in front of functions is a common style to indicate private helper functions that are for internal use of the class/module. Can be handy as an at-a-glance distinction as to what is private and public over and above language method to enforce it.

      The same technique can be used for variables but is generally overkill as exposed or global variables should be relatively rare.

    5. Re:Code style, not formatting style by Anonymous Coward · · Score: 0

      On the other hand, when the project strives on and there's turnover, all that's left of Jimmy and Pete and Kevin is "who the fuck wrote all of this?" - that's one drawback.

    6. Re:Code style, not formatting style by gman003 · · Score: 2

      Well, there's the full SVN history if we want to be sure, and some comments get tagged with an initial (eg. /* @@@@K: this will break if we ever get over 4 million users */ for Kevin saying that we might want to make that a 64-bit int, not 32-bit, at some point). And we use Javadoc (or similar) whenever possible, so we know who's worked on a file.

      The code formatting is more of making it *convenient* to know, intuitively, who wrote the code. I can even tell whether it was 2011 Kevin or 2012 Kevin writing the code, because by 2012 Kevin had finally gotten used to the weirder functions of the framework, using the active record classes instead of hand-written SQL.

    7. Re:Code style, not formatting style by gman003 · · Score: 1

      Actually, the framework we're using (CodeIgniter) makes that an explicit feature. If a function begins with an underscore, it cannot be called directly from a URL. So if you have a class "Foo" with two functions "bar()" and "_baz()", you can access bar via [hostname]/foo/bar/[arguments], but you can't do the same for [hostname]/foo/_baz/[arguments].

      But it's more that he used it for nearly every variable, even function parameters or globals. And that the names were not descriptive. I don't care if you call it $_temp_fh for a temporary filehandle, but don't call it $_t.

    8. Re:Code style, not formatting style by dfghjk · · Score: 2

      "Although it can make it harder to work on each other's code, it has one benefit - you can easily tell who wrote the code."

      and that's SO worth the price of admission since it's so hard to achieve that otherwise.

      "And if I do go in to "someone else's code" and change or fix things, I follow their style, more or less."

      Which really helps everyone tell who wrote the code. ;)

      It's amazing how hard people are trying to justify their own prejudices here.

    9. Re:Code style, not formatting style by Anonymous Coward · · Score: 0

      I don't really care how you *format* your code. Do you put the brackets on the same line as the beginning statement? Do you put a space between the function name and parentheses? Do you double-space your code? I don't give a fuck. That's all syntax. It's easy to figure out.

      Let me guess. Perl coder?

  26. You need rules. Does not matter what by archshade · · Score: 1

    When working with code written by more than one person you need rules. It helps with code review and helps new people intergrate into the project more easily. The larger the program and the more people involved the more stringent they have to be.

    Of course many of the rules can be applied by the IDE/editor or post processed this is fine as long as submitted code is up to speck. It's genrally better to do it right from the beginning though.

    The precise rules themselves don't make much diffrence as long as they are sensible. Consitency is key.

    --
    Most Damage is done by people who are AWAKE
  27. My two point coding style by matunos · · Score: 1

    1. Use spaces instead of tabs.
    2. Make your code readable by humans.

    1. Re:My two point coding style by jader3rd · · Score: 1

      1. Use spaces instead of tabs. 2. Make your code readable by humans.

      I find those two points to be in conflict with each other.

    2. Re:My two point coding style by matunos · · Score: 1

      I don't know what humans can't read spaces, but I'm glad they work with you and not me.

  28. Comment that code!!! by Nyder · · Score: 1

    Consistency is nice, but comments are way better. I could care less if someone uses spaces or tabs between shit, as long as it has comments about what the code is doing or trying to do, I'm happy. Well, was happy, I don't really code anymore.

    --
    Be seeing you...
  29. Style is Substance by afgam28 · · Score: 4, Informative

    The best article that I've ever read on coding style is Style is Substance by Ken Arnold.

    I won't repeat what he has to say here, because he explains it better than I could. But I wish that more programming languages would follow what he is advocating, because we waste way too much time arguing about braces and tabs.

    1. Re:Style is Substance by SuurMyy · · Score: 1

      Right. What of us who program in several languages very often? Your idea would make it very hard to write different languages and would work as a road block in learning a new language. So it's not a perfect plan, unless you really think that the corporations are right when they force people to use languages that are ill suited for a given programming purpose. So, no thanks.

      --
      The lyf so short, the craft so long to lerne
    2. Re:Style is Substance by dfghjk · · Score: 1

      "The best article that I've ever read on coding style is Style is Substance [artima.com] by Ken Arnold."

      I can't think of any article being more diametrically opposed to reason than that one. It is absolutely terrible.

      K&R is the ugliest style ever concieved, and the reason for NOT enforcing style as syntax is because better approached can, and have, evolved over time. The author doesn't realize that because he dismisses the very possibility of value up front. He is an idiot.

    3. Re:Style is Substance by dkf · · Score: 1

      K&R is the ugliest style ever concieved, and the reason for NOT enforcing style as syntax is because better approached can, and have, evolved over time. The author doesn't realize that because he dismisses the very possibility of value up front. He is an idiot.

      You've missed the point, which is that fighting over styles (where you can use software to enforce them instead) is stupid. The details of the style don't matter too much and different languages have definitely evolved in different directions, but throughout it is consistency, and tools to help you keep consistent, are the key.

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    4. Re:Style is Substance by Anonymous Coward · · Score: 0

      Are you seriously implying that there are other C styles that empirically look more beautiful than K&R? I would greatly love to see some citation on this.

  30. Cha-no-yu by starfishsystems · · Score: 1

    Nice to be reminded of these ideas. While they come up most prominently in our early years as software developers, we tend after a decade or two either to take them for granted (should we be so fortunate as to work in a place where everyone writes clean code as a matter of course) or perhaps to give up on them in despair (when working in a code maintenance regime that puts a priority on generating minimal diffs where the code base is - and must perpetually remain - an ugly steaming mess.)

    The practice of software development entails in the same undertaking aspects of style, design, engineering, and science. On that spectrum, the stylistic element can seem relatively trivial, subsumed into the others. Okay, fine. What that really means is that when we encounter stylistic failings and inconsistencies, we're bound to wonder what else is wrong with the code. Style, in other words, communicates something about care and attention in general.

    As a form of communication, it's interesting to consider the Japanese tea ceremony. Few human activities are so completely formalized. Its essential form is pure simplicity, where every action in every detail of movement can be given full attention. Every tea practitioner knows this form intimately. What's interesting is that this form, while aesthetically pleasing, is seldom followed exactly. It functions sort of like a carrier wave. How a tea practitioner departs from form encodes the signal, superimposed on the carrier. In feudal days, the encoded aspect was critical. It provided a way for people to communicate on subjects that were politically dangerous.

    In writing software, we're probably not concerning ourselves with political intrigue. But still, how we express an idea in code provides important information. Consistency of form is reassuring, whereas departures from form draw our attention. We're bound to ask "why did he do it this way over here but this other way over there?" In good code, the reason should be evident. We should feel a small kick of satisfaction that we're inside the mind of the programmer, that we're on the same groove.

    It's the kind of code we should all aspire to write. Style is not mere decorative flourish. If it is, something is wrong, because form follows function, and this would be form without function.

    --
    Parity: What to do when the weekend comes.
  31. RULE 1 !! NO TABS !! by Anonymous Coward · · Score: 0

    You stupid lazy idiot !! Yes, you !!

  32. Run everything through a formatter by Animats · · Score: 3, Informative

    Just use Artistic Style for C and its derivatives C++, C#, and Java. I usually set it for "--style=ansi", but that's a project preference. External code is run through Artistic Style before use. This way, everyone knows the indentation is consistent.

    For Python, of course, there are few formatting options, so this isn't an issue. Dreamweaver will indent HTML. Javascript remains a problem.

    1. Re:Run everything through a formatter by Anonymous Coward · · Score: 0

      Even better, why are we still slaves to the presentation syntax of the program? Why not let everybody have their own "CSS" definitions for code and store the abstract syntax tree in source code control. Then, everybody will see the code with their favorite indentation, spacing, width etc.

    2. Re:Run everything through a formatter by dfghjk · · Score: 1

      Maybe if you tried writing that you'd understand why. Remember that your solution needs to work with plain text files in any editor a programmer might want to use.

    3. Re:Run everything through a formatter by Anonymous Coward · · Score: 0

      That's a seriously limited tool. For example, let's say I want to have spaces around operators; astyle does not seem to care. It just keeps both "a = b" and "a=b" unchanged. For C code, using GNU indent (indent --k-and-r-style --line-length 80 --no-tabs --swallow-optional-blank-lines) produces better results for me.

  33. Style != formatting by redfood · · Score: 2

    Almost all the posted comments are talking about formatting (tabs vs spaces, indentation, line breaks, etc).

    While its good to be consistent with these. Style is so much more.
        Consistant naming schemes for variables/functions/classes/methods etc.
        Useful and meaningful comments.
        Handling non-expected input and states gracefully
        Catching and handling of exceptions
        meaningful feedback to the user if there is a problem.

    I would call all these things and more "style." These are the things that make it easy to maintain code after it is written. They also help to reduce the incidence of bugs.

    1. Re:Style != formatting by ZombieBraintrust · · Score: 2

      Max number of lines in method.
      Max number of lines in file.
      Cyclomatic complexity.
      Use of standard design patterns. (factory, singleton, adapter, and iterator)
      What subset of the languages commands are not allowed.

    2. Re:Style != formatting by petervandervos · · Score: 1

      Indeed, plus keep your code simple. Don't try to do 'smart' things, cut corners. This will always bite you in the ass. The person who has to change your code in 5 years is probably you. You should instantly (or fast) understand your own code. If you can't how could anybody else understand it. One thing I do when working on code, if I try to find a routine/variable and find the name is different than what I was looking for, I change the name. This way I can find it faster in the future.

  34. Oh yes: it is a good proxy measure of quality by Jorgensen · · Score: 1

    In my experience, "messy code" is a good indicator of "messy development". I strongly believe that the structure and appearance of the code is a insight into the developer's brain. And messy code: Usually means trouble ahead.

    And yes: IDEs can help with automatically formatting code: It's good since it allows developers to spot obvious mistakes, and it's bad because it allows bad developers to hide structural errors. But probably good overall.

    There's more to coding style than simply indentation: The really most important concept is clarity.

    If a developer cannot explain (in one sentence) what a given function does, what a given class does or what a application does: be worried. If the developers thinks they know and still cannot explain: Be very worried.

  35. Formatting is the IDE's job by Call+Me+Black+Cloud · · Score: 1

    There are best practices and rules a programmer should follow and those should be set at the team level...call that "style" if you want. But formatting? Who cares? The IDE takes care of that. If the diff engine on your IDE or repository can't tell the difference between code changes and whitespace changes then something's wrong. I was on a (Java) project where half the team liked braces on a new line and half didn't. When I worked on code written by someone else, the first thing I'd do is hit alt-shift-F (Netbeans) to reformat the code. I'd do the same if I pasted some code...reformat the file to get the new code formatted the right way.

    Our SVN repository wasn't glutted with meaningless diffs and I didn't face hundreds of conflicts when updating code. In this modern age (despite the lack of flying cars) it's silly to have to conform to one standard to make the software happy. Software works for us, not the other way around. I use software to format code the way I'm most comfortable with...why should everyone compromise so no one is happy? Just set up your tools properly and stop worrying about formatting.

    1. Re:Formatting is the IDE's job by dfghjk · · Score: 1

      "... it's silly to have to conform to one standard to make the software happy."

      You mean like forcing everyone to use the same IDE so you can have your flexibility?

      Not every project requires each team member to use exactly the same tools. Doing what you say becomes much harder when tools are mixed.

    2. Re:Formatting is the IDE's job by FalseModesty · · Score: 1

      So nobody at your shop puts comments on the same line as code? Why? Was it forbidden by the style?

  36. Use a language that enforces style by Anonymous Coward · · Score: 0

    COBOL is a good example - it forces you to indent properly with A and B columns!

  37. KR by SpaghettiPattern · · Score: 4, Informative
    Kernighan and Ritchie stands for an exemplary coding style. It's spirit can be transferred to more modern languages. It was thought of with readability and screen economy in mind.

    My does:
    • Never omit braces for conditions and loops.
    • Spaces instead of tabs. This is a holy war which I have fought with myself. Stated with tabs but after years of persevering I realised spaces had less issues.
    • In related projects, choose one style and stick with it.
    • Let the IDE do the code formatting for you.
    • At any cost, avoid the order of members to be significant.
    • If you need fancy formatted comment then your design may need a review.
    • Design your software to be a set of modules and develop each module as pure as you can. Solving one problem well reflects in the code you produce.
    • Divide your compilation units in units containing data structure definitions and units containing processing code. That also makes your code more readable.
    • Learn from better programmers and become a better programmer every day.
    • Avoid the pitfall of cryptic programs. The more people can read you code the better it can be maintained.

    My don'ts list is getting shorter and shorter. Most programmers have reasons why they produce the code the way they do. Lack of experience should be met with understanding and appreciation for improvements.

    --

    I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
    1. Re:KR by multicoregeneral · · Score: 1

      So far, the best insight in this thread. Wish app architecture was in scope for this discussion.

      --
      This signature intentionally left blank.
  38. Wow - Doesn't get it by jamej · · Score: 1

    I promise if your team is kicking around coding style conventions you might not be doing important work. Be careful. This might be a clue you're replaceable. If your doing creative work nobody asks about coding style. They only ask, is it new, cool, and ready to ship. Respectfully, Jim

    1. Re:Wow - Doesn't get it by FalseModesty · · Score: 1

      By that reasoning, you shouldn't be concerned with getting dressed before going to work. Clothing does not produce cool code, does it?

    2. Re:Wow - Doesn't get it by multicoregeneral · · Score: 1

      He probably works in consulting, where time matters. When you attempt to implement hard coding standards in consulting projects, they bleed money, and it's perceived to be the fault of the person coding, even though it rarely is. It's even worse when you're in the middle of building a hard standard, and you're not able to "stop the train" as it were. Good code takes longer to write. Client projects are often quoted in flat figures. In other words, your job is to get them out the door quickly. Not to make them scalable and maintainable. Working with frameworks helps, but they can be a drain on resources as well.

      Product development on the other hand is a totally different animal, but I suspect that the majority of programmers don't actually work there.

      --
      This signature intentionally left blank.
  39. It does matter by TheCount22 · · Score: 2

    When writing code everything matters.

    Forcing people to follow a style I think is counter productive. It prevents the styles from evolving. In recent years for example people have been moving towards using better naming rather than commenting.

    Strict rules prevent creativity and for that reason I disagree with the conclusions of the article to require one. Requiring anything more than just to follow a style no matter what that style may be and to try to maintain the existing code in the style that it was in is about as much as you can do.

    "The best way to predict the future is to invent it." - Alan Kay

    1. Re:It does matter by ZombieBraintrust · · Score: 1

      Style guides are good for novice programmers who have no experience. It can be used to find many of the common mistakes novices make style wise.

  40. Yes, it's important, and if you think it's not... by Anonymous Coward · · Score: 0

    ...get your ass on the unemployment line because that's where you belong! It's simply part of being a professional. You think chefs that constantly have sloppy as hell workstations keep their jobs? Even if they cook really well at some point they tend to if not be unemployed than certainly be less well-regarded than their otherwise would be. Same thing is true of a sloppy coder.

    Note that I'm not saying *WHAT* style is important...I personally prefer spaces over tabs and braces at the end of a line but other people feel just the opposite. Neither of these options is important. What *IS* important is that there is a well-defined and well-known style guideline and that all developers on a given team adhere to it, whatever the actual rules are, whether they like the rules or not (although I *AM* a big fan of having everyone contribute to the rules and re-evaluate them as time goes on... no point having developers that feel like they have to follow some stupid, rigid rules they hate if it's at all possible to avoid that, and just having everyone have a say in the rules goes a long way to ensuring that's the case).

    Someone else pointed it out, but consistency is the key concept here. I can't tell you how frustrating it is as a project lead to have to review code from five different developers who ALL use a slightly different style, or, worse still, where each developer DOESN'T EVEN FOLLOW THEIR OWN RULES ALL THE TIME!! I've been becoming more and more anal about this sort of stuff as I've moved up the ranks because I've witnessed first-hand the detriment to maintainability such a seemingly innocuous thing like how you format your code can be.

    But, the bottom line is it really CAN be a big deal. If for no other reason than a fix we should be able to turn around for a client in two hours takes four because they have to parse some ridiculous-looking code... and yeah, it definitely CAN get in the way of understanding. Of course, this assumes that rules around commenting are part of your style guidelines, which they very much are on my teams now.

    And don't give me the "let the IDE do it" line... that shows a core problem in you. Writing good, clean code, format-wise *AND* content-wise should be a deep-seeded need in you, something you do automatically whether you have the tools or not. Too many developers I've seen over the years skate by because they have tools that cover their shortcomings... but the shortcomings are still very much there and they are just flat-out not as good of a developer as the people that have attention to detail and logical thought and a desire to make everything neat and clean embedded in them at a deep level. You can almost without fail tell who's been programming since they were young and who started with programming as a passion versus those that went to school for it and/or came to it late in life. They may *TECHNICALLY* be decent enough programmers, but there's always something missing, something very valuable, something that makes them not as good as others... and how you format code has proven to be a *VERY* good indicator of this in my experience.

    So yeah, it's important, quite important actually. And if you don't think so, enjoy whatever job you can get, but I promise you, *I* won't be hiring you.

  41. Have worked on MANY large teams by SuperKendall · · Score: 2

    then you have never worked on a free software collaborative project; you have never submitted patches to free software projects; you have never worked for a large software engineering firm with ISO9001 (Software TickIT) practices in place;

    I have worked with large engineering firms; I have not have submitted small patches to OS projects long ago but as I noted, for small changes I mimic existing coding style.

    I have worked with dozens of teams ranging in size from two to thirty or so.

    in fact you have probably never worked with revision control tools ever in your life.

    I have worked with many such tools starting with RCS, then CVS, then git.

    running a code formatter and then creating a patch automatically includes your modifications in amongst a bunch of whitespace modifications,

    You may have not noticed where I said small changes I mimic existing coding style. I am talking about new code, where someone who is submitting the code is also the guy who has been writing it for a while. As long as the people working on that block of code are consistent, there is no SCM issue with them coding as they like. I am not saying to re-format a whole file and check that in; just to make it more readable as needed.

    bottom line is: i'm not impressed.
    And I am sad you cannot read, nor understand the point I am making.

    Hopefully for the good of future teams you can eventually lodge the stick out of your ass that companies have made you push in so far you don't even know you have it any longer.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  42. +1 for yes by Horshu · · Score: 1

    I'm a stickler for consistent styling as well as formatting. It's one of the reasons I like .Net so much - they have a nice code analysis engine built into their build system as well as a decent style engine that can be added on. There's a bit of adjustment when the source control system rejects non-compliant code, but once you start learning what the guidelines are, it gets easier to write it properly the first time. The base framework itself is reasonly conformant to those guidelines, so more effort can be placed towards effectively interfacing with the libraries. And it's interesting that almost every place I have worked *wants* to use MS formatting/style guidelines; it's just rare for the boss actually pulls the trigger on enforcing it (inevitably, the argument goes towards "yeah, but how much of an effort will it be to make all of our existing code conform?"). Fortunately, I am currently on a .0 product version that entails a rewrite, the question of making existing code compliant is a non-starter.

  43. point by shentino · · Score: 1

    Format your code so that the coders can read it.

    If your'e on your own, format how you like.

    If you're on someone else's project, format how they like.

    The compiler truly does not give a rat's behind about it, so approach it as a people issue.

    And that means being prepared to capitulate if someone else in charge wants things done their way.

  44. style by shentino · · Score: 1

    The compiler doesn't care how you format the code.

    Your boss, however, might.

    1. Re:style by veg_all · · Score: 2

      Your coworkers, however, might.

      ftfy

      --
      grammar-lesson free since 1999. (rescinded - 2005)
  45. There is only one coding style and its K&R by Anonymous Coward · · Score: 0

    There just haven't been any significant improvements to the K&R coding style. Just follow it exactly.

    The best part of K&R is it appreciates the importance of vertical space. Don't waste vertical space with stupid conventions like "standalone braces" or placing every HTML attribute on a separate line. When vertical spacing is abused, then other programmers can't see a particular line of code in context. To display context you need to display as many lines of code within a limited space, while still having space available to break code segments into related groups. Otherwise, you force other programmers into having to endlessly scroll backwards and forwards to "see the forest for the tree".

    1. Re:There is only one coding style and its K&R by SpaghettiPattern · · Score: 1

      Who modded the parent down?! To me the parent actually was insightful. Anyone have positive mod points to spare for the AC?

      --

      I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
  46. Re:Yes, it's important, and if you think it's not. by Anonymous Coward · · Score: 0

    should be a deep-seeded need

    <GrammarNazi>It's "deep-seated".</> I understand why "deep-seeded" may seem reasonable; but it's wrong.

  47. Code Style is not about then indents by ZombieBraintrust · · Score: 1

    When I think of coding style I think of the following: Methods shall not be over 40 lines long. Files may not over 1000 lines long. If blocks must not be nested more than twice in same method. Do not use the else command. Do not use Ternary operator "?:" Do not nest loops more than twice in the same method.

    1. Re:Code Style is not about then indents by Psychotria · · Score: 1

      Not sure if serious or meant to be sarcastic, or...? You're not allowed to use ?: and you're not allowed to use else? How do you specify an "else" if you cannot use the else keyword nor the ?: operator? The other styles you suggest are pretty crazy as well, but not as crazy as not using else in any way shape or form. Why should a function not be over 40 lines long? That's like saying a paragraph must never exceed three sentences. I can think of plenty of examples where a function would appropriately be over 40 lines long.

    2. Re:Code Style is not about then indents by ZombieBraintrust · · Score: 1

      How do you specify an "else" if you cannot use the else keyword nor the ?: operator?

      By keeping methods small and using the return statement. We don't actually have a rule for ?: but no one uses it. I just personally hate ?: because it is terrible syntax. There are exceptions for the length rules but in general 40 lines long is a very very long method.

    3. Re:Code Style is not about then indents by VortexCortex · · Score: 1

      Enjoy your stack thrashing inefficient code. Learn ASM, and compare the code generated by your stated style and the style you're saying not to do.

      Sure a compiler is supposed to do all sorts of optimizations to make your preference irrelevant, however, in practice they take a lot more hints from your code than you think.

    4. Re:Code Style is not about then indents by ZombieBraintrust · · Score: 1

      ok, will look into it.

  48. Yes by Anonymous Coward · · Score: 0

    And Plan 9 style is the only acceptable style.

  49. Well it always helps... by Anonymous Coward · · Score: 0

    ...if the coding style is built into the language itself. See: Python :)

    1. Re:Well it always helps... by arkane1234 · · Score: 1

      Python is a fever-dream...

      --
      -- This space for lease, low setup fee, inquire within!
  50. Yes by arkane1234 · · Score: 1

    Yes, next question?

    --
    -- This space for lease, low setup fee, inquire within!
  51. Re:Yes, it's important, and if you think it's not. by arkane1234 · · Score: 1

    Or perhaps he really meant deep-seeded since the words describe something.
    This is also a forum, and you wasted moments of your life trying to correct someone on something other than improper spelling and grammar. You've corrected their meanings....

    --
    -- This space for lease, low setup fee, inquire within!
  52. yes by localhost8080 · · Score: 0

    it does

  53. Consistency creates patterns by SuperKendall · · Score: 1

    That "anal retentive asshole" is making everyone's job easier - including yours.

    I have never found the anal-rentiive to make anything easier overall.

    Because human minds see patterns, and they decipher familiar patterns quicker and more accurately.

    Exactly why letting people code as they wish is not a problem, as long as each coder is consistent. When you open any given module, it's all consistent and your brain latches on to the patterns in use quickly.

    So when everybody's code looks the same, it's much easier for other coders to maintain

    I'm confused: Does the human mind see patterns or not?

    Of course, you probably didn't bother to think about that, now did you?

    Far more than you will ever know.

    Letting people code in a style closer to what they prefer reduces errors going in. Perhaps you love finding errors later; I do not. I'd rather they never go in. But perhaps you did not think about that... now did you?

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  54. Don't invent your own style by iJed · · Score: 1

    More important than using your own code style is using the language code style if there is one. For example in C# you should code in the same style as the .NET, in Java like the Java SDK and in Objective-C (on OS X/iOS) like the Cocoa APIs. Don't invent your own style if there is already one existing.

  55. simple reality by shentino · · Score: 1

    When someone other than you controls what code gets published, you buckle down and do what the fuck he tells you.

    And that includes kowtowing to their preferences on coding style.

    So if you're coding on someone else's turf, do what the fuck you are told.

  56. For idiots, yes, yes it is. by Anonymous Coward · · Score: 0

    And by idiots, I mean the generic morons that colleges spit out every year left, right and center.
    For those who are smart, even spaghetti GOTO'd to hell code can be easy to read, if a little annoying.

    However, ideally there should be at least some sense of common style.
    The simplest way I can think of it is this: describe your basic layout to a child in your head.
    Write it down. Does it sound right? Could it be better? Is the kid annoying you yet? Did you tell him to sit on the naughty step or did you listen to him?
    Are your coworkers looking at you funny for talking to your trashcan? You finished yet?

    Main first-run code at top. All the stuff needed for a successful use of a project, such as entering a number in a spreadsheet, saving, closing.
    Order these in what you'd consider the default / popular use-cases of that code by the program and user.
    Sequence diagram is the most important in this. USE it for order. Sequence Diagram is the most important next to actually testing the thing to make sure it works.
    But if you done a good and thorough enough sequence diagram, these problems tend to evaporate.
    Make everyone analyse why they did the code that way. If they can't explain it to child-self, it is likely poor already.
    Write sectioned code.

    After that, syntax, personal bracing style, none of it matters.
    All that matters is code that is legible and doesn't require the persons brain to actually interpret the damn thing.
    That variable Count could mean anything, Count what?! Explain your secrets variable! TALK!
    Putting stupid restrictions on freedom of style just inhibits development.
    You just need people to explain things clearly in a basic line and the actual code itself and everything is peachy.

    If that fails? The people you are working with are not developers. Period. They are workers.

  57. 30 years later and people are still arguing by Anonymous Coward · · Score: 1

    Arguing over coding style just seems to be part of the software development mentality. It was going on 30 years ago when I first started in computers, and it will no doubt outlive me easily. In management, when you are looking for something to do, you call a meeting. In software development, idle time can always be easily eaten up by starting a discussion/debate/argument over where to put the lousy curly brace or parenthesis.

    Yes, yes, coding styles are more than just indentation and such, but in the end it has always seemed to me to be about a few things:

    1) Is the code readable?
    2) Is the code consistent?
    3) If the code is not how I would have written it, are items #1 and #2 above being observed?

    If a piece of code passes all three tests, then I suggest that there is nothing wrong with the coding style. This opinion may not be the latest rage on the software lecturing circuit...but it has proven to work just fine across 30 years of development, countless problem domains, and project teams ranging in size from 2 people to 500+ people.

  58. No it doesn't by Murdoch5 · · Score: 1

    I personally hate coding styles, a coding style gets in the way of producing code. If someone wants my code formatted in a certain way then they should format it when they get it. Almost all commercial IDE's and Text Editors can format code at the click of a button so if someone really wants my code formatted they should set up the rules and do it themselves, after all if the argument is they can't click a button then it's not my fault.

    1. Re:No it doesn't by Todd+Knarr · · Score: 2

      Poor or inconsistent coding style, OTOH, gets in the way of producing correct, working code. If you have to constantly stop to figure out how the current statement's nested or which block it's in, that takes time and attention away from concentrating on what the code's supposed to do. That means more errors, more bugs, more time debugging and a greater likelihood of missing bugs or a deadline or both. If I look at code and find no consistent coding style in it, that tells me that either the programmer didn't take too much care writing the code or there were several programmers working on it who didn't take any care to mesh their work. Either way it makes me wary of the code.

      And while mostly the exact style doesn't matter, only that there's a consistent style, some styles do have their drawbacks. Forinstanceomissionofwhitespacetends tomakecertainerrorslike=vs==harder tostopandmorelikelytolinger. Now, how long did it take you to find the typo in the previous sentence? I rest my case.

    2. Re:No it doesn't by Murdoch5 · · Score: 1

      You didn't rest any case, all you demonstrated was that you can write garbage. If you make a typo in your code then you made a typo, the best code style in the world doesn't prevent mistakes. If I wrote a module for a program you were working on and you wanted my module to look a certain way then you can have your IDE or Text Editor format it with one click. Regardless of how it's formatted mistakes will exist, if you make it hard to read on purpose then your just an ass. Out of all honestly can you read that? If your formatting code in such a way you can't read it then the problem isn't the coding style, it's maturity. In the same right I'm not going to complain to someone if I don't like how the code is formatted, I'll format the code myself by pressing the format button.

      I'm not bashing your belief in coding styles but I'm pointing out how I personally don't like them, after all there is a reason code formatting is built into modern IDE's and Text Editors, we should make use of them rather then rely on the programmer to work on style.

    3. Re:No it doesn't by FalseModesty · · Score: 2

      Seemingly you are the one who can't click a button. And that is your fault.

    4. Re:No it doesn't by Todd+Knarr · · Score: 2

      If you make a typo in your code then you made a typo, the best code style in the world doesn't prevent mistakes.

      Code style can, however, make it easier to spot typos when you make them, easier to scan for them. Eg. the regexp "if .* = " to spot use of an assignment inside an if condition, which is normally a bug. If you consistently use whitespace between tokens, it's easy to write that regexp and have it reliably catch all occurrences while also reliably not catching anything else. If you omit the whitespace, it's harder to come up with a check that's resistant to false positives (and a test that throws up a lot of non-matching lines isn't helpful, the errors get lost in the noise). It can be done, but this is about easy not merely possible. You can make pigs fly with a big enough rocket strapped to them, but if you want a flying animal it's easier to just start with a pigeon instead. And anyone who wants to use techniques that make it easier to make errors and harder to spot them when you do make them... is not a professional.

    5. Re:No it doesn't by Murdoch5 · · Score: 1

      If your writing code you can't read then it doesn't matter if your following a style or not. If you have a block of code that fails because you make a typo because of slop then you've proven you don't test your code, which again isn't a coding style issue.

      Well white space I believe can help the majority of programmers, white spaces wont help every programmer. I think it's far smarter to develop a style which works for your self, that allows you to read code quickly, that keeps your work clean and arranges your logic then it is for you to submit to a 3rd party style. What I find nice and easy to work with wont always be what you want to work with. I can get more and better coding done coding comfortably my way and you can get more and better code done coding your way.

      Maybe ( and this isn't true ) I prefer no white space in an if statement, if(x==y){x++}else{y--} or maybe I prefer to use x==y?x++:y--; If that is what I like to program with then I should be allowed to write my code my way. If I make a typo or a mistake because I didn't A) test my code and B) write slop I can't read then I've only show I need to grow up and pull my head of out my ass. On the exact other side of the coin I might have the worlds most beautiful coding format setup, but it wont stop me from doing if( x = y ) which is a clear typo, I can surf on by it for weeks, after all I believe an exact bug like this caused AT&T to crash.

      Over all I believe that every programmer should use there own style, use what works for them.

    6. Re:No it doesn't by Murdoch5 · · Score: 1

      Coders should spend their time looking at the code, not getting distracted by style variations.

      I just saw that line, I agree, a developer shouldn't waste his time being distracted by style variations. A developer should program the way they want and how they want and commit the code. If coding style is GD important to certain people then they can write a code format script and give it to me, I'll follow what the IDE wants me to and never look back.

    7. Re:No it doesn't by maxwell+demon · · Score: 1

      Even with such a coding style, your regexp will miss some occurrences because a coding style doesn't magically prevent typos violating it. First, I'd *never* use a regex to catch assignments in ifs. The compiler can do it much more accurately than any regex I could think of. But if I'd use regexes for catching assignments in ifs, I'd use if *(.*=[^=]. That's far more reliable and doesn't depend on the amount of whitespace you might put on your if. And yes, I do put a single whitespace between the if and the opening parenthesis. But I would never want to depend on it, because it is more easily omitted that the second "=" of "==".

      --
      The Tao of math: The numbers you can count are not the real numbers.
    8. Re:No it doesn't by Todd+Knarr · · Score: 1

      If your writing code you can't read then it doesn't matter if your following a style or not. If you have a block of code that fails because you make a typo because of slop then you've proven you don't test your code, which again isn't a coding style issue.

      Yes, testing will catch those errors. But as I said, it's about easy, not merely possible. Long experience has taught me that it's faster and less aggravating to catch errors like this before you get to the testing phase. Once in testing, every one of these errors increases the number of tests you have to run, slows down testing for the fundamental logic errors that code examination won't catch (the kind where the code's correct and does what you intended it to do, but what you intended isn't what the requirements call for) and generally causes more aggravation and frustration than you need at that stage. Especially when you're working to a deadline. Better to catch all of them in one scan and get them fixed before you start testing than to find them one at a time after you've started testing.

      And unless it's a personal project you are not the only person who'll have to work on that code. The code has to not only be readable by you, it has to be readable by everyone who'll have to maintain that code after you. And that'll be a lot of people, production code has a ridiculously long lifespan (I'm dealing with code at work that's been there for 10-12 years and isn't going away any time soon). This is one of the reasons why I said that mostly the exact style isn't so critical (beyond avoiding those styles that make it easier to make mistakes and not spot them) as is having a consistent style throughout the code. It's easier to maintain code that's not a mish-mash of several different coding styles, and better if programmers adapt to the style of the existing code than ignore it and use whatever they want with no regard to whether it fits into it's surroundings.

      Note that the above applies more generally than to just coding style. It's better and less likely to cause nasty bugs if you work within the existing architecture and design of a code-base than if you try to force something in that runs counter to that architecture. At work (again) I'm dealing with just that: a component has a basic design, a way of doing things, and business wants to do something that completely contradicts that basic design. Considering that that component's got better than a decade's worth of accumulated code, enhancements and special cases built up around that basic design, it makes what business wants akin to trying to reposition the structural members of just the first floor of the Sears Tower. And as usual most of what they want can be accomplished within the existing design, and another engineering change elsewhere will probably render the remainder moot.

    9. Re:No it doesn't by Murdoch5 · · Score: 1

      I completely understand what your saying, I just personally don't like being tied into a defined style. Well your right that you can find some errors with ease when you format your code in a more appropriate style, it's wrong to force that style on to everyone. In the case when you working with old code I think the worst thing to find is a lack of comments. I will gladly take poorly formatted code then no comments.

    10. Re:No it doesn't by tempest69 · · Score: 1

      Good coding style can catch those mistakes.
      A normal function
      if (state=1) {do stuff;}
      has some issues, but with a consistent style
      if (1 = state) {do stuff;}
      GCC will throw a compile time error that it obvious, rather than strange behavior that has to be hunted down.
      Style is far more than tabs and spaces. When and how variables are initialized, do you populate them with error flags, do you have some byzantine check for correctness states. Or do you have a big pile of intermediate variables to determine the state. Do you have a assume true with a disprove, or assume false with a prove X as true.
      style matters

  59. Slashdot delivers by Anonymous Coward · · Score: 1

    I came here expecting endless threads of coding style religious wars. I was not disappointed.

  60. style is everything by spirit_fingers · · Score: 1

    I like to wear a black Versace cocktail dress accessorized with fire engine red Prada fuck-me pumps when I code. It makes the occasion special.

  61. Vertical space by girlinatrainingbra · · Score: 1

    Vertical space is very important. I agree that breaking submodules out with v-spacing is as important as using braces to collect a group of actions together. The braces tell the compiler that the group may be viewn as a single object. The spacing/vertical spacing of lines tell the coder that the segment is a disctinct sub-object or module inside a group of code items.

  62. creativity vs. interoperability by girlinatrainingbra · · Score: 1
    Creativity matters when you've got a single producer and no-one else to ever work on or look at the code. Style matters when you've got a single producer and others who will look at, maintain, and update that code. Style matters when you've got multiple producers of code who need to be able to look at each others' code and code fragments and be able to grok it without having to search through hundreds/thousands of other header files (or in the case of C++ and overloading of operators, through all of the ways and environments that a function may be called, with overloading replacing just about anything with anything else.)

    .

    When you've got to be able to de-cipher and re-jigger someone elses code to get the job done, a stable and well-defined coding style means that the job really can get done in a finite amount of time.

  63. Religion by EmperorOfCanada · · Score: 1

    Code formatting can be a religious issue (I have my favorite style) and just like this article says probably often stems back to trying to please some forgotten professor. Often there is a logic behind each style rule. But mostly I agree that there should be one true style at any given company. In a weird way it might be good to have a company style that would offend any fresh CS major in that they could be shown the style and told that style is not negotiable. This would show if they are a team player or not. A genuinely good programmer would know that after a week of programming the new style that they would be fine with it.

    But my main complaints about other people's styles is that they do often come from the small assignment to be marked school of needs combined with 50-60 year old professors who learned their stuff in the 80s. This results in rules like: no line longer than 80 characters. //Comment the crap out of everything. This comment crap also ends up with huge comment headers at the top of every page. The worst comment style is when people break up the parameters to a function onto separate lines; ah la C code from 1982.

    Then there are the document hounds. This comes from the corporate school where managers need yards of documentation. So they insist upon strange comments that proceed every comment with the goal of generating huge documents that nobody will ever read and are probably wrong since they don't generate runtime errors if they get out of sync with the code. This is a case of mission creep where the programmers are also supposed to generate documentation to make the manager able to show he is worth something.

    The key is that the style should come from the goal of creating a product quickly, that is bug free, and can be maintained with reasonable ease. Once rules creep in that don't concern these three reasons then they are stupid rules.

    1. Re:Religion by maxwell+demon · · Score: 1

      There are reasons for no more than 80 characters per line beyond terminal sizes. Those are the same reasons why newspapers divide their pages in columns instead of making the text go from the left to the right of their page. It is that humans are not good at parsing too long lines.

      --
      The Tao of math: The numbers you can count are not the real numbers.
  64. Indentation matters by Anonymous Coward · · Score: 0

    The one code rule I wish all coders would follow, even if they followed no other rule, is that of indentation. I've seen so many times code commented to denote that a certain curly brace was the end of this-or-that code block. What lame code that is! With proper indentation, no such comment is needed. In fact, with proper indentation, very few comments are needed, which is just how I like my code.

  65. nOPE by Anonymous Coward · · Score: 0
    cODING aNd wr it i ng Styles maKE no
    diFFERencE at all. If

    THEre is A WAY yOu LIkE

    tO wrITE theN jusT dO
    it .TRUE proFESSionals CAN hanDLE it
    SMOOThlY

  66. I will never understand it by Anonymous Coward · · Score: 0

    Every freaking time I had to work under someone else style, I wind up writing code that has to be bug fixed or optimized somewhere along the line. Whenever I write code in my own style however I rarely have to revisit a function to fix bugs in it, not bragging just saying it's incredibly frustrating.

    I don't want to paint pictures with text. I don't want to write code that makes auditing happy. I'm not trying to blend in with other coders. I write code that works in the most efficient way possible with as few bugs as possible. That is the only thing that matters to me. 90% of the bugs I have to fix in someone else code would never have happened if they just dropped their bullshit style and thought out all the edge cases ahead of time. An hour of planning for a function can save weeks of debugging if you stop trying to be an artist and start trying to be an engineer.

  67. alignment can matter by FalseModesty · · Score: 1

    I wonder how long you have been writing code, if you don't yet realize that sometimes aligning things vertically across several lines can increase clarity. If everybody gets to set their own indentation amounts (by changing tab width), then this benefit is lost. Tables were invented for a reason, and sometimes code is tabular. And if you think a tab character is how you get a table, you are sadly mistaken.

    For example, having same-line comments start at column 60 (when possible) makes code easier to read. If you go changing the tab character to 4 spaces, that alignment is ruined.

    Also a reason for not using proportional fonts.

  68. naive by FalseModesty · · Score: 1

    If you think the only way anybody will ever view your code is in a "sane IDE", you are mistaken. Just because your current IDE can compensate for your bad formatting, that doesn't make your bad formatting a good practice.

  69. not "so called" by FalseModesty · · Score: 1

    It's a standard, whether you like it, or know about it, or not.

    1. Re:not "so called" by multicoregeneral · · Score: 1

      It's a standard, whether you like it, or know about it, or not.

      A standard is pointless unless it's put into practice. Which standard is it part of?

      --
      This signature intentionally left blank.
  70. Whatever you chose, make it automatable by FalseModesty · · Score: 1

    Whatever style you choose, make sure that it can be generated with whatever automatic formatting tools you have available. This allows you to cut-n-paste code from other sources, and not waste precious time hand-formatting it (or leaving it in the wrong style). It also avoids the problem of lazy programmers feeling butt-hurt when somebody points out that their code does not follow the style. They can simply run their sloppy code through the pretty-printer before committing it.

  71. And what about parentheticals, hm? by multicoregeneral · · Score: 1

    Only on Slashdot would there be a debate about what constitutes a tab. Half the reason I love this site. Although, why not bring up when it's appropriate to add a space before or after a parenthetical. Using spaces or tabs, you're going to get basically the same result in your code. The real variance is in parentheticals and curly brackets. Those are all over the board.

    --
    This signature intentionally left blank.
  72. Aspergers [sic] by FalseModesty · · Score: 1

    Sounds like somebody lost his job to a better coder, but doesn't want to admit it.

    1. Re:Aspergers [sic] by gbjbaanb · · Score: 1

      sounds to me like a professional who is interested in doing the work, not arguing the toss over the latest trivial fasions to hit the coding industry.

      You can work with code written in many different styles. Lots of people do it all the time. Think it cripples your ability to do good stuff?

      Then think - what happens if you are exposed to code a different team wrote, using a different style guide. We've all worked with sample code on the web, tutorial code, library code written by someone else. Strangely enough they don't all follow your coding style, and you can read them all perfectly well.

      So by mandating a single style, all you're doing is stopping you from maintaining your flexibility to work. Like I can no longer really get anywhere without my satnav, a rigorously enforced holy-style-guide will just kill off that part of your mind that used to deal with code written in all kinds of styles without problem.

      The best thing to do is just scrap them entirely and rely on the team's code reviews to deal with anything nasty that someone puts in. The rest - working and no problems.

      Of course, it does rely on everyone cooperatively working together, which kind of excludes those asperger's weenies who insist everyone else must work like they want.

    2. Re:Aspergers [sic] by ios+and+web+coder · · Score: 1

      I'm an aspie, and I can work with dozens of styles.

      However, I do have to fight urges to reformat the code...

      I prefer Whitesmiths indenting. In over 30 years of coding, I've never gotten used to K&R indenting.

      I have gotten used to long, descriptive method, class and data member names, although I don't believe that a lot of "self documenting" code actually is.

      It is important to have consistency; not just for others, but also for ourselves. Come back to your code in six months, and try and make heads or tails of it.

      Drupal won't let me add my plugins to their repository because it doesn't use the same coding conventions they prescribe, even though my style basically far exceeds theirs.

      <shrug />

      Their loss (but they won't roll up the project from it)

      --

      "For every complex problem there is an answer that is clear, simple, and wrong."

      -H. L. Mencken

    3. Re:Aspergers [sic] by gbjbaanb · · Score: 1

      ok, and you're right about self documenting... I'm sure that fad is just an excuse for people who don't want to do a professional job...

      However, there is no "good style", they're all as good as each other - I mean some people like K&R braces because they use the indentation for block scope, and putting the first bracket on the same line reduces the amount of extraneous lines that clutter the ease of viewing the indentation. So its not a bad style at all, even if you don't like it.. it is quite a lot like Whitesmith's style though, and has the advantage of being more commonly found in the wild.

      So you should modify your code to fit with Drupal's style, simply because you're wrong to say they're not as good - the only bad style is one that doesn't fit in with the rest of the codebase, and that makes (in this instance) your style a bad one. So embrace their style for your Drupal plugins and keep your style for your other projects.

    4. Re:Aspergers [sic] by ios+and+web+coder · · Score: 1

      Actually, I never said their format is bad; just that mine is better; in many ways, mostly for my own purposes. It has virtually nothing to do with K&R indenting, which was actually invented in the early days of C, when file size was a much bigger issue than it is now.

      You see, I write plugins for all three of the "big" CMSes (Drupal, WordPress, and Joomla).

      I use a common base class, and about 90% of the code is completely cross-coded. It's a sort of "M-V/C" pattern, with the C and V being mixed up a lot. It's an outstanding way to generate extremely robust and high-quality UX across systems. I've been doing it for a long time, and in many different languages.

      I won't rewrite all the code used in the other plugins, just to please one set of folks. They have every right to enforce a common style, and I have every right to release mine on GitHub. The Drupal folks are geekier than most, so fetching the plugin from elsewhere isn't a big deal. It would be more of a big deal for the WordPress crowd or the Joomla crowd.

      As I said, it really is all about personal style. However, in all my years of coding, one thing that I have learned, is that geeks LOVE to say "you were wrong", so I'm glad I was able to provide that service for you.

      Cheers!

      --

      "For every complex problem there is an answer that is clear, simple, and wrong."

      -H. L. Mencken

    5. Re:Aspergers [sic] by gbjbaanb · · Score: 1

      for the smile at the end; to you sir, I owe a beer.

      cheers!

    6. Re:Aspergers [sic] by Anonymous Coward · · Score: 0

      If you willingly use PHP your opinions can be safely ignored.

  73. I said multiple times I follow other standards by SuperKendall · · Score: 1

    There is a strong correlation between developers that cannot follow a style standard and divas.

    That may be. I am not one of them.

    I CAN follow other standards. I already said for example I do so when editing other people's code, right from the outset.

    I also CAN follow other coding standards as teh job requires, and have done so a lot.

    But what follows from that is experience, and in my decades of experience across multiple languages, coding for both client and server backends coding standards are in fact a total waste of time. That is what I am telling all of you. Yes lots of people can follow a coding standard, but it is wasteful to craft one and to spend the time trying to get coders to follow it.

    Especially since there is a lot of grey area: like defining the common vocabulary (like the expected behaviour of getX, createX, findX, selectX, process, run, execute, ...)

    What language is most of that gray for? I would also say definitions for how code should behave is actually more API conventions than "coding standards". It is more a design matter.

    Free code style, in practice, would only mean that you are working most of the time with code in a different coding style.

    Not at all. Read what I said again. Code you are writing from scratch you write how you like. Code from other people you try to keep the given style. So over time you spend only a little time coding in other styles, most of the time in a module that you have been working and and debugging. There might be some small negotiation if one or two other people are in the exact same code as you at the same time to not write something in a way they really dislike, but it doesn't need to be an edict from oh high to work out.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  74. Out in the open AC by SuperKendall · · Score: 1

    That's what you don't understand - people can look back through history and realize that I consistently advocate a position, not that I'm some loser AC yanking chains like yourself. My posts are serious; AC posts on a topic like this are pretty much meaningless garbage because you can't tell anything about the level of experience the person posting has.

    Hell, even my UID alone tells people I have 10000x more believability than yourself.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  75. The trouble with coding standards by SuperKendall · · Score: 1

    What you have laid out is way better than the end result of most coding standards, where all of them would have been named "feature_37_count". You know it's true.

    Also variants of naming are easily cleaned up later by refactoring tools if the situation gets to be as dire as you have presented. If there's a good reason to help make the code more consistent in that way one should do so; it's not the same as re-formatting a file...

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:The trouble with coding standards by Anonymous Coward · · Score: 0

      I apologize. You're ranting about code formatting standards, which are hardly related to coding standards.

      Have you ever seen a company survive refactoring a major code base? I've bought out a few that failed.

  76. FreeBSD solved this, at least for the kernel bits by Anonymous Coward · · Score: 0

    See style(9). Kernel code is expected to follow this format; whether the programmer likes it or not has no bearing. The same is not actively enforced for userland programs and their source, but is highly encouraged.

    As an author of a 3rd-party FreeBSD program, I chose to follow this document as well, just to keep everything consistent.

    Makefiles have similar requirements; see style.Makefile(5).

  77. Higher Level Rules Matter Even More by Anonymous Coward · · Score: 0

    Yes, proper Coding styles are somewhat important. What I feel is even more important is to properly name variables, classes, functions, members and so on. I am German, my english is good enough to write this text, as you can see. But I am working on Code which has been developed by someone whose English skills are rather limited. But this guy thought it would be a good idea to use English names for the things listed above.

    So for "Durchschnitt" (engl. Average) he used "Intersection". For "Werkstatt" (engl Auto Repair Shop) he used "Workstation".

    I asked him why he did this and his answer was that he used an English-language framework (MFC) and it would "not be looking nice" to have German-language variable names and English-language methods (e.g. werkstaetten.GetCount()). Which is of course a big-time bullshit argument, as the most important thing with source code is the Ability To Understand The Intent Of The Programmer, and not "lyrical considerations".

    So, I use German names, because

    + Programming is a highly complex intellectual activity

    + I can express myself best in my mother tongue

    + I want to reduce the possibilities for mistakes to a minimum

    + I give a rat's ass about aesthetics if that compromises the Communication Of Intent

    The same is for documentation - don't use English "because it is cool and a sign of modern business". Use English if that is your mother tongue or if many of your essential team members can't properly read your mother tongue.

    This advice also comes from Software Engineering "gurus" ( I can't recall a specific name right now), I am not the inventor of the "use your mother tongue in programming" maxime.

    Certainly, whatever human language you use, try to

    1.) use Proper names. Don't invent your own silly terminology if there already exist commonly accepted terms. Check with wikipedia.

    2.) ask other people for feedback about your naming conventions.

    3.) focus on the business side of variable names. "ulPrivCR" is not as relevant as "cashRetained". People can easily look up variable definitions and there is no need to encode the type into the variable name.

    4.) Try to balance brevity with expressiveness and "ease of reading". It is not always easy, I admit. E.g. use "NumErrorsFiltered" insted of "NEF".

  78. kernel, libraries, and apps will differ in style by Anonymous Coward · · Score: 0

    In an embedded project, you may have inherited several different styles in the kernel code, specific drivers, and special libraries. What I do is adopt the style that matches the context, especially when moding existing code. Sure, if you build a project completely from the ground up, you can strive for consistency. But face it, these days your going to pull in something that has been coded elsewhere. Just use good taste. If not, get a code beautifier.

  79. A Shitty Little Perl Script by Anonymous Coward · · Score: 0

    ..plus some discipline might do the trick: Just search for the method definition headers (something like \w+\:\:\w+) and then for a "{" in the next line and then just insert the logging code/macro. I know it will not work 100% of time, but it would save a ton of editing time.

    I did something like this to get a makeshift mem leak detector (just look for new and delete) and it works reasonably. I found real leaks. But yeah, a kludge I have to use because MFC thinks they need to overload the new operator so I cannot do that.

  80. Ken Arnold Is a Fucking Nazi by Anonymous Coward · · Score: 0

    A Computer Language Formatting Nazi. There are tons of reasons why code must be formatted in different ways and the "let's standardize" crowd with their two nerve cells can interbreed to produce more MBA "talent". They also love "standardizing". They want to think of software engineers as "standardized slaves" that can be "uniformly exploited".

    I will in the meantime set up rules which I an everybody else can break when it makes sense in a specific situation. I don't need Nazis to hold the hands of programmers with two years of real experience.

    Go fuck yourself Nazis and let great people design great stuff in their bedrooms. And no, I don't mean this ironically. Linux was conceived in a student's bedroom, not in the Corporate Nazi Space.

  81. I Am A Free German by Anonymous Coward · · Score: 0

    ..and my code is as nasty as the words I will lob at you if I have an issue. NowGoFuckYourselfAndreformatthiscodeforme.

  82. Whatabout "Sanity" and "Common Sense" ? by Anonymous Coward · · Score: 0

    All your bean-counting might give your words a scientific appearance, but it does not at all address the real issue of software engineering. Neither do I think that bean-counting does address many other engineering issues.

    If you cannot formulate problems with code in prosa language, you are intellectually retarded. Do you need to hide behind all your beans ?

  83. Good Example Of a BAD Coding Style by Anonymous Coward · · Score: 0

    Your "coding style" focuses on the irrelevant things and gets them wrong, too. With IDEs that can easily navigate code, the size of files becomes more or less irrelevant and there are many situations where you need methods longer than 40 lines. Apply common sense and review extremely long methods - sometimes they can indeed be shortened. But don't set up stupid rules "that must be obeyed".

  84. OMFG by Anonymous Coward · · Score: 0

    If you don't have revision control, you can safely ignore all and any issues about code formatting, because you will have much, much bigger issues at hand than code readability. Quit That Company Today.

  85. And it should never matter today! by GeekDork · · Score: 3, Insightful

    Code editors (at least most of them) are still stuck in a dark age where everything comes down to hand-crafted ASCII-art, which is complete and utter bullshit. Editors could and should work much closer, if not directly on, the AST of the language in question, and completely abstract away all those pesky details like indenting scopes or formatting comment blocks "properly". That stuff should be left to user preference and style sheets.

    But I guess that would put an immediate end to the religious zeal displayed in tabs-vs-spaces (it's of course ts=8 sw=4 noexpandtab, noobs!), would not mask syntax errors in gobs of meticulously crafted gunk, and take all the "fun" out of programming.

    --

    Fight hunger. Filet a politician and send him to a 3rd world country of your choice.

  86. For Java: Checkstyle by tsager · · Score: 1

    For Java project a must. Agree on coding standards and then enforce/check them using Checkstyle.

  87. Bad coders write bad code by SuperKendall · · Score: 1

    Style guides force people to be sensible.

    The thing is - no, no they do not. I've seen plenty of nearly unreadable code that complied (roughly) with local style guides.

    If you've encountered rational looking C++ it's because they knew what the hell they were doing, not because the labored under some all-powerful style guide.

    That's the trouble with coding standard guys, they claim coding standards work while all the while it is the people who can code clearly without them are the reason they think it is so.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  88. Style = Religion by God+of+Lemmings · · Score: 1

    All I am hearing from everyone is philosophy and opinion, but in all of it there are kernels of truth. It is exactly like religion, there is no difference. With regards to what I use, the bulk of it centers around reducing the amount of time it takes to read a code block. If you can't read a code block in a couple seconds that you haven't seen for years then you're probably doing something wrong.

    --
    Non sequitur: Your facts are uncoordinated.
    1. Re:Style = Religion by Euler · · Score: 1

      The article had some good kernels of truth, besides the more pedantic text formatting questions. For instance, adding comment hints where program flow is less obvious in a case statement.

      For the most part, style choices are personal. Unfortunately, people have opinions on everything and are poor judges to recognize when they are simply promoting one arbitrary choice over another without a provable reason.

      Consider this example. In C, I get annoyed by code that uses conditionals without braces when there is a single statement in the condition. That works for the first line, but makes it hard to catch errors when a second line is added that falls outside of the conditional.
      i.e.
      if(foo==bar)
          doSomething();
      I think this is very obviously bad, but I run across code like this, and people who are unapologetic about it. Am I unfairly judging this from my perspective, or is there merit to re-writing this style choice?

  89. Very few people focus on what's truly important by Anonymous Coward · · Score: 0

    I've noticed that when people talk about "coding style", they often mean things like indentation and such.

    For me "coding style" should be about things that really, truly matter in the grand scheme of things:

    * Are the .cpp and .h files designed for reuse? Can you take the .h file and #include it somewhere else and have it JUST WORK GUARANTEED? If you link in the .cpp file into another program, do you have to add a bunch of unnecessary .o files to make it link?

    * Does low-level code make calls into high-level code? For example, does the code that packs and unpacks serial protocol strings make direct calls into the UI to report if it encounters a protocol error?

    * Does low-level code call printf directly for tracing? Did the writer of that code have any idea how that's going to work if you need the UI to collect and organize the tracing for 20 different subsystems and display it all in a special GUI window?

    * Does the code use platform-specific features when it could just as easily have been written to use an equivalent portable feature?

    You'd be amazed how many people obsess about exactly where to put the left curly bracket, but then you realize their code has no master organization plan, poor modularity, little provision for reuse of code, total ignorance of portability, poor definition of what a particular module is for, a poor concept of code groups and code hierarchy, poor division into service-providers and service-consumers, etc, etc.

  90. yes it's better, but..... by SuperDre · · Score: 1

    yes it's better to have a consistent codingstyle, BUT what codingstyle is the bigger problem, as what is great to one person might look awfull to another, good codingstyle is all in the eye of the beholder. for instance, comments, one thinks let the code speak for itself, and others think comment on what you intend the code should do.. another example is lambda expressions, some swear by them and use them everywhere to the extreme, others use them only if it doesn't make the code harder to understand (since lambda expressions are 'just' functions/procedures with no name).. As I said, good codingstyle is all in the eye of the beholder, but a team should have at least one global codingstyle...

  91. FlexeLint catches lack of /*FALLSTHROUGH*/ by tlambert · · Score: 1

    For 10 concurrent developers it will set you back about $10,000. BattleMap (now called McCabe IQ) will set you back about $30,000 a seat, and can generate test cases for unit tests which will test every branch path, and correlate them back to line items in your requirements documentation.

    Probably overkill, if you are not working on a life support system of some kind, but the tools exist.

  92. Borland by shiftless · · Score: 1

    I love the Borland color scheme. I run that in my code editor. I wish I could find a good TrueType "VGA" font to make it even better.

  93. but by Anonymous Coward · · Score: 0

    doesn't that get in the way of preserving your job by becoming the only guy who can work on your code?

  94. Formatting is not that important overall by Anonymous Coward · · Score: 0

    Coding style is important, but if formatting differences make a huge difference in readability, it's probably because the code is poorly designed. Code that has small functions, well-designed classes, well-partitioned modules, etc, is easier to understand even when the formatting is not all that great or consistent.

  95. Playing well with others by dmoonfire · · Score: 1

    I'm one of those people who is obsessed with coding style, but I'm not in love with any one style (well, I have my personal style but it changes over time). The main reason I like a style is to "play well with others".

    In my job, we have (relatively) brisk turnover as people are brought into the project and moved out. The team size has gone from 2 to 30 and down to 8. People come and people go, but someone has to maintain the code for 20+ years. Having everything consistent makes it easier to bring people in and to keep things flowing easily.

    During code reviews (we have them for every check-in), I consider deviating from the coding standard with justification to be wrong. Yes, it is nit-picky that the formatting is off or there is a missing space after the "if" and before the "(", but the simple fact we're working on a codebase that will be maintained by dozens of people over decades. A little work now significantly reduces the effort to maintain it later.

    Now, that isn't to say that some standards drive me nuts. We use "m_" in front of our local variables at my current job. I *hate* it, but it is better than nothing. I'd rather go through the regular change process to get consensus instead of abandoning it because of a personal reason. Likewise, I've submitted patches to Mono previous, though I find their coding standards to be... uncomfortable to work with.

    In the end, I only care that a standard is in place, not the specifics of it.

  96. go by voltorb · · Score: 1

    Not in Go programming language.

  97. I've come to find... by Anonymous Coward · · Score: 0

    Programmers are plagued with too many decisions:

    What do I name it; how should I implement it; where do I put it? What should it look like?

    I personally think the strongest advantage to adopting style/standards is to get everyone to shut up about the formatting and focus on the code.
    The more I can get my developers (myself included) off of the 'gee should I do this?' bandwagon with clear-cut expectations/guidelines you can focus on the logic.

  98. Camel_THIS by Anonymous Coward · · Score: 0

    ClearlyAsLongAsTheCodeWorks,
    and_someone_can_still_read_it...