Re: On Tabs and Spaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 16 Oct 2007 16:05:34 -0700 (PDT)
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> I do indeed. I don't think it's sensible. And I did think I already 
> answered that issue by talking about how most editors don't even
> support it or show the difference between tabs and spaces.
> 
> For example, the editor I use - microemacs - supports tabs just fine.
> It does auto-indentation etc. But it does it with hard-tabs by
> default, so now you have to have some editor-specific setup for that
> particular project if you ever want to do anything else.
> 
> And that's really what it boils down to. Everybody support
> 8-character hardtabs (and usually by default). They may support other
> things *too*, but any time you move away from that standard
> behaviour, you'll most likely find something that doesn't support the
> alternatives.

Unfortunately most editors are totally confused about the difference
between tab size and indentation level.  Visual Studio, probably the
most commonly used development environment on Windows, by default uses
TAB characters that are 4 spaces wide, and users are recommended
not to change that because of that a lot of existing Windows source code
and examples uses those settings.

Two years ago, when I last looked at it, Eclipse, a very commonly used
development environment, managed to confuse tabs and indentation and
make it almost impossible to write Java or C code with a tab size of 8
with a different indentation level.  The Eclipse 3 betas did see some
improvement there, I think it got possible to do the right thing in
Java at least, but the normal text editor and C editor lagged behind.
But it was still a big mess and it was much too easy for someone to get
a tab size which is not 8.  Hopefully this has been fixed by now, but I
wouldn't bet any significant amount of money on it.

Nedit (which runs on Linux) has a very confusing settings dialog with
terms such as "tab spacing", "emulated tabs".  I guess emulated tabs
means the indentation level, but guess how easy that is to mess up.

gedit can control the tab width, but has no setting at all for
configuring the indentation level.  Guess what people do when they want
a 4 space indentation level?  Yes, right, change the tab size to 4.

A a former colleague who used visual slickedit usually produced code
with tab size 4.  I think I've gotten the same crap from ultra edit 32
users.

And so on...  Mercifully, _all_ of these editors have a setting to use
spaces instead of tabs, and telling people to turn on that setting is
the absolutely easiest way of making things "just work".  Yes, I know,
the correct answer is to tell people to always use tab size 8, and I
frequently and loudly do that.  But at the same time, perfect is the
enemy of good.  It's much easier to explain "tabs will act differently
in different editors, but if you always us spaces it will not be a
problem" than to get into a discussion about the semantic difference
between tab size and indentation.

If you assume that everyone is sane and use a tab size of 8 you will
get bitten, sooner or later.  Or actually, you, Linus, who are lucky
enough to work mostly with Linux source, you might personally not get
bitten all that often.  But us poor suckers that have to work with
other people, often Windows programmers, we do.

  /Christer








-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux