4 ms·
I don't like their indent guidelines, 2 spaces just feels incredibly "cramped" to me with Java. I understand it with an 80 or 100 col line limit (I also tend to
by fournm 13y ago
I don't like their indent guidelines, 2 spaces just feels incredibly "cramped" to me with Java. I understand it with an 80 or 100 col line limit (I also tend to 120, but 100's okay), but really, that's the only thing. I personally agree with most of this and we have warnings generated on commit (thanks Sonar!) if people don't follow some of these because they just lead to too many issues down the line that are really easy to accidentally skip over.
I wouldn't imagine it would be too hard to get an IDE auto-formatter to follow all of this (it's more or less what I use with mine, anyways).
- mynameishere 13y agoIf they used tabs instead of spaces, it wouldn't be an issue. People could format code on their machine whatever number of columns they prefer. But no... Spaces. Jesus. If you're looking at someone's HTML and it's got this kind of thing strewn about... ...you know with certainty that you're dealing with either 1) an amateur, or 2) someone constrained by top-down corporate numbnuttery.
- ender7 13y agoThe debate over spaces vs. tabs is as old as time. Associating one side of the argument with "top-down corporate numbnuttery" betrays a lack of familiarity with the issue. The fact is that whatever shop you work at should have an opinion one way or the other, and you should follow it. Programmers will endlessly bikeshed the issue regardless of which style is chosen.
- lostcolony 13y agoHappily, the Tab-letariat can agree with the Space-eoisie that a separation of the whitespace classes is necessary and good, and any commingling of the two is an affront to God.
- frou_dh 13y agoHell, God is an amateur? He should know that tabs indent and spaces align. There's nothing to be confused about.
- fournm 13y agoWe do, in fact, use tabs at work. But I wanted to attempt to avoid starting this war yet again.
- hackinthebochs 13y agoRadical idea: lets move code away from the anachronism of flat files. There have been incredible evolution in some areas of development, and other areas time has completely frozen. We should have modern tools from the top-down. dons flame retardant suit
- aragot 13y agoExplanation? You could put code elsewhere than in flat files? Elsewhere that is neither VBA nor PLSQL ;)? I'm interested. Otoh, if you're going to suggest binary structures, I wont be able to approve you if they're not easy to manage in Git.
- hackinthebochs 13y agoRoughly it would be some sort of structured text, markup that represents the structure of the code rather than having a flat text file which then requires parsing to reconstruct structure. There are a couple of motivations here: structured representation allows editors to much more freely handle custom visual representations. Debates about tabs, spaces, braces, semicolons, parenthesis, etc etc are painfully outdated. These simply become properties of your chosen visual representation. It also allows more meaningful transforms without requiring a compilation pass, as a meaningful intermediate language is already present. This would have a few benefits: semantic text highlighting, straightforward semantic changeset merging, enhanced error highlighting and more semantic error detection (if I insert a line of code somewhere, the error is readily marked as the inserted line as the surrounding code is still semantically valid), sharing the semantic representation between IDE plugins. I'm sure this is just scratching the surface. I'm reminded of the project I recall reading about from steve yeggie regarding a language agnostic IDE framework (whatever happened to that anyways?). A language agnostic, semantically rich file format would allow entire classes of transforms to apply across all languages that could be marked up by the language agnostic file format. There are so many possibilities here, and yet a non-trivial amount of programmers are still anchored by the supposed benefits of editing code from the console! Programmers should be the first to be looking forward rather than being tied down to the past.
- jcampbell1 13y ago is one of those smells except for when it isn't. <th>First Name</th> The above is useful html, but I have had experienced developers "fix" it, thinking it was some copy-paste/dreamweaver accident. Non-Breaking SPaces are useful at times.
- Stratoscope 13y agoYou should see how two-space indents look in a proportional font! It's a sorry sight. That's the real shame of two-space indents. They basically require that all developers use monospaced fonts in their editors. One of my most core principles for coding style is that the code should be equally readable in a proportional font or a monospaced font. Why is that a core principle for me? Because I like proportional fonts. I don't use less-readable monospaced fonts when I write; I don't know why I should have to use them when I code. You can't achieve this with two-space indents. When you view the code in a proportional font, it looks like one-space indentation. For me, a proportional font is so much more readable, and lets me see so much more code at once, that I'm bummed that so many popular coding styles use conventions that only work monospaced. To their credit, this coding standard actively discourages "column alignment". Abandoning column alignment is a wonderful thing: it gets you most of the way there toward having code that's perfectly readable in a proportional font. It's unfortunate that they throw this benefit away by mandating two-space indents.
- seanmcdirmid 13y agoI use 2 space indent with Segoe UI and am pretty happy.
- vinkelhake 13y ago> Why is that a core principle for me? Because I like proportional fonts. I don't use less-readable monospaced fonts when I write; I don't know why I should have to use them when I code. I had a phase like that about 15 years ago. In the end I just felt that it wasn't worth it. Whenever I looked at other peoples code through the lens of a proportional font, it would look awkward. Any attempt on the authors part of lining things up would just make things worse. It turns out that proportional fonts are designed for text, not code.
- Stratoscope 13y agoThat 15-year-ago mark is interesting to me, because that was just about the time when I switched to proportional fonts. I recognize that I'm in a tiny minority: the vast majority of developers code in monospaced fonts. That's one reason why I value an editor that makes it easy to switch between a proportional font and monospaced, so I can code in the font I like or switch to a monospaced font when necessary. One of the few that does this well is Komodo, where each "theme" includes both proportional and monospaced fonts, and you can easily switch between them. (I just wish IntelliJ IDEA did this!) It's also why I wouldn't presume to use a coding standard that worked only in a proportional font but looked bad in monospaced. But to my eyes, a coding standard that works equally well in proportional and monospaced fonts is superior to one that works only in monospaced. I must respectfully disagree that "It turns out that proportional fonts are designed for text, not code." All of the code I've written in the last 10-15 years is just as readable in a proportional font or monospaced. It really makes no difference at all which kind of font you read the code in, if the coding standard was designed to support both.
- userbinator 13y agoIndent size is definitely a personal preference; I started out with 8, then shortly went to 4, moved down to 3 for a very short time followed by 2, and have now settled on one space. One nice side-effect is that I can glance at the column counter and see the indent level immediately, and the closing braces look like a diagonal line which makes a missing/extra one quite easy to spot: } } } The nice thing about C-syntax languages is they can be automatically formatted, so anyone who finds my indents to be too small can increase them, and vice-versa,