TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Poll: Allman or K&R Indentation?

7 pointsby pushingbitsalmost 14 years ago
Just wondering what HN prefers.<p>http://en.wikipedia.org/wiki/Indent_style

8 comments

rednumalmost 14 years ago
Something like 1TBS style. I it is quite popular among my friends and different to both K&#38;R and Allman. You could add it to the poll, since there are few votes at the moment and bias won't be too big.
ChuckMcMalmost 14 years ago
I find the 1TBS style maximizes the number of lines I can get on the screen which helps in understanding what the code is doing.<p>I don't miss the opening brace because when I see the closing brace I can go straight up to the controlling statement.<p>A variant that Sun used to use was that for functions you defined them thusly:<p>int function_name(args) { ... }<p>The benefit was that grep '^function_name' *.c would turn up the file with the definition (vs the prototypes which were of the form int function_name(...))
jamalmost 14 years ago
K&#38;R, but technically more like 1TBS (as described on Wikipedia).
Peterisalmost 14 years ago
There are some languages, e.g., javascript, which practically force you to use K&#38;R. In C++ and Java, I always prefer Allman though. Of course it is more readable than K&#38;R, but, I think the choice is driven by the editor. I use Vim, which makes it dead easy to manipulate lines as a whole. I also like to have single statements without braces, so it is much easier for me to to quickly remove stray '{'s or add them as needed when the number of statements changes within a block.
lurch_mojoffalmost 14 years ago
I'm definitely in the K&#38;R camp. I keep alternating between 1TBS and Compact Control Readability, depending on the preferences of the other members of the team working on that particular project. I personally prefer Compact Control Readability.
dfreidinalmost 14 years ago
I personally prefer Allman, but if I'm working with existing code, I'll use whatever style the code already uses.
kienialmost 14 years ago
Depends on the language. For me, Allman is easier (==cleaner) to read.
TNOalmost 14 years ago
A language that avoids the question