I always used to use K&R style and I think it teaches bad habits: I used to obsess about compressing code. I remember when I started trying to help people with learning Python. A friend, and arguably better (python) programmer, commented: Go Tom, great stuff. Now all we've got to do convince is teach you to space it all out so I can read it I switched to Allman after that: much to the relief of many people ;)
This is about bracing styles and your comment is about Python. That is almost a non sequitur ;)
The Facts Behind the Code Indention Style War
11–20 of 29 posts
Re: The Facts Behind the Code Indention Style War
#12Re: The Facts Behind the Code Indention Style War
#13I've seen code that got confusing with K&R, especially when the programmer forgot to indent the next lines. And I really like the ability to adjust control flow with block commenting you have with braces-stand-alone.
I'm not looking to compress code. My goal is to make code as readable as possible. Anything I can do to make it explicitly clear what's going on I'm going to do. Code should not read like a mystery novel.
Re: The Facts Behind the Code Indention Style War
#14bottomline: because he is used to them. I feel the K&R style is easier to read because that is what I am used to.
Re: The Facts Behind the Code Indention Style War
#15I'm a braces-stand-alone person. I've seen code that got confusing with K&R, especially when the programmer forgot to indent the next lines. And I really like the ability to adjust control flow with block commenting you have with braces-stand-alone. I'm not looking to compress code. My goal is to make code as readable as possible. Anything I can do to make it explicitly clear what's going on I'm going to do. Code sho…
A single bracket on an otherwise empty line carries very little information, so why not reduce the strain on the eyes.
Re: The Facts Behind the Code Indention Style War
#16Earlier quoted context omitted.
This is about bracing styles and your comment is about Python. That is almost a non sequitur ;)
not really - I used K&R in PHP which got me in the poor habit of compressing any code. :)
Re: The Facts Behind the Code Indention Style War
#17"In my opinion, the Allman brace style is easier to read because..." (blablabla) bottomline: because he is used to them. I feel the K&R style is easier to read because that is what I am used to.
Re: The Facts Behind the Code Indention Style War
#18Re: The Facts Behind the Code Indention Style War
#19Every moment you spend cleaning up Windows-style EOL characters or transforming tabs into spaces (or vice versa) - or programming your editor to do so - is a moment of your life that could have been put to a better use.
With a standardized S-expression format (it could even be human-readable, as for example, Lisp source is) all possible source files which result in the same syntax tree would have the same canonical (by definition) representation. Yes, this means that parsers will need to parse comments rather than toss them, but implementing this minor trick is not a challenge for anyone who has read a few chapters of the Dragon Book (or its imitators.)
Your editor can still show you exactly what you want to see. And other people will have the same ability.
If you are using Eclipse (or whatnot) to magically reformat source to your personal tastes every time you edit anything, you have already quit pretending that the original raw human-readable representation is worth much. All I'm suggesting is to take this process to its logical conclusion.
Storing source as ASTs instead of ASCII would, among other things, increase the usefulness of revision control systems. It would eliminate the need for programmers to agree on any formatting style at all.
Re: The Facts Behind the Code Indention Style War
#20"In my opinion, the Allman brace style is easier to read because..." (blablabla) bottomline: because he is used to them. I feel the K&R style is easier to read because that is what I am used to.
Well put. Personally, I get distracted when reading Allman style. When I start scrolling, I start daydreaming about all of the wasted space and how that programmer must have met his/her line quota for the day. Most editors have a brace matching feature that helps.