[wp-hackers] Coding style
David Chait
davebytes at comcast.net
Tue Jul 4 16:10:29 GMT 2006
I promised myself I wouldn't jump in... But I'm going with the 'use tabs'
contingent.
If you are coding on a multi-person project, break down and use a >code<
editor. Period. Any editor worth its weight will allow you to set tab size
at least globally, if not per project. And we're not talking plain-text
editors, we're talking code editors. When you're getting stuff in email, it
really should be an attachment -- otherwise plaintext email line-wrap
destroys code anyway. In which case, you print from an editor, not your
email. Lastly, printing itself is up to the application these days
(whereas in the old days it might have been up to the printer) -- and since
we're talking code editors, they apply the same tab sizing to printouts that
they do to screen.
We're not talking notepad. Or other 'plain' text editors. We're talking
working on a large scale OS project -- all should be using code editors,
which can understand and set tabbing, and print properly. Using a code
editor should be part of the coding rules. ;)
Yes, in the 'old days' of say dos and linux, where 'text' editors grew to
editing code, tabs were harder to handle across platforms, editors, and
people. But I don't know of that being the case for a very, very long time.
The majority of projects I've worked on in the past say 15 years were using
tabs, 4-spaces as the default. I knew a few people who, for whatever
reason, set their editors to 2-space tabs -- and very infrequently needed a
few lines of indentation cleaned up (and then left alone). :) But in teams
both small and large, together or remote, tabs has always been the
preference of (most) people I've worked with. 4-space-tabs is the best
balance I've worked with, and I've worked with people who liked 2, 3, 4, and
8 space tabbing. 4 is enough to always 'see' the indents clearly, yet not
too much for heavily indented code.
Also, working with tabs allows for quick block-level indent/outdent, which I
find a key editor feature these days. Most code editors that work in tab or
space indent modes should be able to block-shift either one, but I find that
spaces don't always get shifted properly.
The worst project I've worked on was a three-spaces-indent system. Never
worked for me.
It should also be pointed out that tabs reduce the character/byte count in
heavily-indented code... ;)
-d
----- Original Message -----
From: "Elliotte Harold" <elharo at metalab.unc.edu>
To: <wp-hackers at lists.automattic.com>
Sent: Tuesday, July 04, 2006 11:39 AM
Subject: Re: [wp-hackers] Coding style
| ravi wrote:
|
| > the rendering of tabs and print output are performed by an editor and
| > some application (such as 'enscript', or the editor itself) for
| > printing, yes? All that is required, it seems to me, is agreement on
| > what tab width should be.
|
| In practice you don't get that. Different apps, different systems do not
| agree about tab width. I am constantly faced with badly formatted code
| that comes through in e-mail, in printouts, and in raw text files due to
| the use of tabs.
|
| Any decently sophisticated editor should
| > provide a mechanism for specifying the tab width.
|
| Yes, but it's an extra step. On top of that:
|
| 1. Not all editors are that sophisticated. People still use NotePad and
| equivalent for quick work.
|
| 2. Even a more sophisticated program may have problems with different
| projects with different tab width conventions. Most plain text editors
| I've seen do not support different tab widths for different files.
|
| 3. Not everything's an editor. Printers and e-mail programs often do not
| allow you to specify tab widths.
|
| The more different people's code you have to handle the more obvious
| this becomes. Tabs don't scale to multi-person projects.
More information about the wp-hackers
mailing list