4 ms·
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
by ErrantX 17y ago
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 ;)
- samlittlewood 17y agoPersonally, I use K&R BUT add space as appropriate to make things readable. Using BSD format, amongst other things, I find the 3 lines between the leaves of an if/else statment really start to chafe. Having used python and small amounts of lisp, I also flirted with rolling up all the close parens/braces on the end of lines with no white space.
- Confusion 17y agoThis is about bracing styles and your comment is about Python. That is almost a non sequitur ;)
- ErrantX 17y agonot really - I used K&R in PHP which got me in the poor habit of compressing any code. :)
- mrinterweb 17y agoI don't know if compressing code is a bad habit. Generally the more code I can see on a screen the faster I can understand what is happening. A good way to add visual space is to supplement the extra lines Allman style would add with comments. I hate scrolling up and down constantly to see what a simple class is trying to do.