Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Spaces for Tabs in non-Java editors?
Spaces for Tabs in non-Java editors? [message #119429] Fri, 29 August 2003 19:39 Go to next message
Eclipse UserFriend
Originally posted by: matty.cloverworxs.com

Is there any reason why the spaces for tabs option seems to be limited to
the Java editor only? I cannot understand why that isn't a basic option of
all the text editors. It certainly causes us some pain, as our standard is
spaces for tabs in all files (or is that a bad standard?).

Matty.
Re: Spaces for Tabs in non-Java editors? [message #119517 is a reply to message #119429] Fri, 29 August 2003 20:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eric.rizzo.jibeinc.com

Matthew Cooper wrote:

> Is there any reason why the spaces for tabs option seems to be limited to
> the Java editor only? I cannot understand why that isn't a basic option of
> all the text editors. It certainly causes us some pain, as our standard is
> spaces for tabs in all files (or is that a bad standard?).

I don't know why it's not a general editor preference, but I have an
opinion as to why spaces-for-tabs is a bad standard. Here's why:

A tab in this context represents a unit of indentation. I happen to set
all my editors to render that unit as equivalent to 4 spaces on the
screen (even though the file only knows there is one unit of
indentation, the tab character), but you may set your editor to render
it as 2, 4, 8, or 100 spaces - whatever floats your boat. Point is, I
don't care how big you want the indentation unit to be, and you
shouldn't have to care how big I want(ed) it either. Any decent editor
will let you control how tabs are rendered, and should preserve them in
the file regardless of how they were rendered on the screen.
By always using tabs, my code always looks consistent when I write it
and you can always make it *look* however indented you want it. What is
important to the notion of a "unit of indentation" is the position of
statements relative to each other, not how many visual spaces there are
on the screen. Using tabs all the time preserves that property, but
using spaces unnecessarily merges the notion of your or my particular
visual choice with the notion of relative positioning.

By always using tabs, we have abstracted out the "unit of indentation"
and each implement it with whatever number of "simulated" spaces we
prefer. Later, if I decide my indentation unit rendering is not the
right size for me, I don't have to go change a bunch of existing code to
be consistent nor do you have to even know I changed my mind.

Now, isn't that beautiful? I wish everyone would see this and quit using
spaces to indent code and, more generally, trying to make coding
standards that specify such a "personal preference" kind of thing.

Eric
--
Eric Rizzo
Software Architect
Jibe, Inc.
http://www.jibeinc.com
Re: Spaces for Tabs in non-Java editors? [message #119649 is a reply to message #119517] Sat, 30 August 2003 03:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

Well, yeah, it would be better if everyone used tabs and a tab character was
always equivalent to the unit of indentation, but they don't and it isn't.
Spaces for tabs will be in the next version of XMLBuddy (even though I don't
use it) because lots of people asked for it. Particularly people who work on
open source projects, where, they say, the variety of platforms from which
submissions come make using spaces for indentation the only possible common
denominator.

Bob Foster

"Eric Rizzo" <eric.rizzo@jibeinc.com> wrote in message
news:biodng$ikn$1@eclipse.org...
> Matthew Cooper wrote:
>
> > Is there any reason why the spaces for tabs option seems to be limited
to
> > the Java editor only? I cannot understand why that isn't a basic option
of
> > all the text editors. It certainly causes us some pain, as our standard
is
> > spaces for tabs in all files (or is that a bad standard?).
>
> I don't know why it's not a general editor preference, but I have an
> opinion as to why spaces-for-tabs is a bad standard. Here's why:
>
> A tab in this context represents a unit of indentation. I happen to set
> all my editors to render that unit as equivalent to 4 spaces on the
> screen (even though the file only knows there is one unit of
> indentation, the tab character), but you may set your editor to render
> it as 2, 4, 8, or 100 spaces - whatever floats your boat. Point is, I
> don't care how big you want the indentation unit to be, and you
> shouldn't have to care how big I want(ed) it either. Any decent editor
> will let you control how tabs are rendered, and should preserve them in
> the file regardless of how they were rendered on the screen.
> By always using tabs, my code always looks consistent when I write it
> and you can always make it *look* however indented you want it. What is
> important to the notion of a "unit of indentation" is the position of
> statements relative to each other, not how many visual spaces there are
> on the screen. Using tabs all the time preserves that property, but
> using spaces unnecessarily merges the notion of your or my particular
> visual choice with the notion of relative positioning.
>
> By always using tabs, we have abstracted out the "unit of indentation"
> and each implement it with whatever number of "simulated" spaces we
> prefer. Later, if I decide my indentation unit rendering is not the
> right size for me, I don't have to go change a bunch of existing code to
> be consistent nor do you have to even know I changed my mind.
>
> Now, isn't that beautiful? I wish everyone would see this and quit using
> spaces to indent code and, more generally, trying to make coding
> standards that specify such a "personal preference" kind of thing.
>
> Eric
> --
> Eric Rizzo
> Software Architect
> Jibe, Inc.
> http://www.jibeinc.com
>
Re: Spaces for Tabs in non-Java editors? [message #120039 is a reply to message #119517] Mon, 01 September 2003 14:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Adalbert.Homa.metavante.com

Eric Rizzo wrote:

> A tab in this context represents a unit of indentation.
This is incorrect. A tab is the same as the unit of indentation only in
simplistic editors, where indenting is done manually and each press of the
tab key inserts a tab character into the file.

All editors used for programming separate indentation required by a
specific language and the tab character in a file which is translated as
jump to the next position of the tab. Just to give one example, Emacs has
one setup for tab size, and a completely another setup for indenting which
is dependent on the language of the buffer/mode.

In Eclipse there is one place which says how the tabs are expanded (See:
Preferences | Java | Editor | Appereance | Displayed tab width). There is
a second place where you specify the indentation level (See: Preferences |
Java | Code Formatter | Style | Number of spaces representing an
indentation level).
When people share they code, the tabs are causing the most havoc. The Sun
Coding guidelines are quite clear, tabs are 8 characters not more not
less. Try to work in an environment where different editors are used, each
with different tab settings (8 or 4). The best is to not use tabs in
source files, and when they are used, the tab size has to be 8.

Once again tab size is not the same as indentation.
Re: Spaces for Tabs in non-Java editors? [message #120557 is a reply to message #120039] Tue, 02 September 2003 18:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eric.rizzo.jibeinc.com

AH wrote:

> Eric Rizzo wrote:
>
>
>>A tab in this context represents a unit of indentation.
>
> This is incorrect. A tab is the same as the unit of indentation only in
> simplistic editors, where indenting is done manually and each press of the
> tab key inserts a tab character into the file.
[snip]
> Once again tab size is not the same as indentation.

Of course not - I think my point did not get across. I am arguing
precisely that indentation and what editors call "tab size" *should* be
thought of as separate notions. Tab characters embedded in files are
useful for indentation because it is easy to say and get everyone to
agree: "one tab character represents one level of indentation." What is
*not* easy to agree upon is how a tab character should appear on the
screen. So the appearance of a tab (that is, how many visual spaces)
should be configurable (any decent editor provides this), but the use of
tab characters in the code file should be mandated. Not the other way
around, which is what people/organizations that use spaces for
indentation have to resort to - because they allow spaces, it is
difficult to get everyone to be consistent in their usage of them
(nobody in his right mind tries to use more than one tab for one level
of indentation, but people do use different number of hard spaces if
given that choice - often the same person is not even consistent in the
number of spaces he uses, much less being consistent with the rest of
the team).
For example: a common type of code standard is: "All indentation MUST be
4 spaces." But if instead they mandated: "Each level of indentation MUST
be a single tab character" then each editor could be configured however
the user wanted. The indentation will still look consistent and
organized because the relative amount of indentation has not changed,
only the appearance of it. It is analogous to the text color settings -
just because I like my code text to be purple on yellow doesn't mean I
can't see the organization of the code someone else wrote.

Hope this makes my position more clear,
Eric
--
Eric Rizzo
Software Architect
Jibe, Inc.
http://www.jibeinc.com
Re: Spaces for Tabs in non-Java editors? [message #120568 is a reply to message #119649] Tue, 02 September 2003 18:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eric.rizzo.jibeinc.com

Bob Foster wrote:

> Well, yeah, it would be better if everyone used tabs and a tab character was
> always equivalent to the unit of indentation, but they don't and it isn't.
> Spaces for tabs will be in the next version of XMLBuddy (even though I don't
> use it) because lots of people asked for it. Particularly people who work on
> open source projects, where, they say, the variety of platforms from which
> submissions come make using spaces for indentation the only possible common
> denominator.

Well it's your product and you are, of course, free to answer your
users' demands as you see fit.
But the claim that using spaces is the "only possible common
denominator" is bogus IMO - if they understood my whole argument about
separating logical unit of indentation and its representation on screen,
it should be evident that insisting on tabs is the most logical
denominator. Platform variety need not enter into the picture at all, as
I understand it.

Oh well, the world is too lazy, I guess, to do what I consider "the
right thing."

Eric
--
Eric Rizzo
Software Architect
Jibe, Inc.
http://www.jibeinc.com
Re: Spaces for Tabs in non-Java editors? [message #121578 is a reply to message #120568] Wed, 03 September 2003 01:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

"Eric Rizzo" <eric.rizzo@jibeinc.com> wrote in message
news:bj2mv1$f4g$1@eclipse.org...
> Well it's your product and you are, of course, free to answer your
> users' demands as you see fit.

Well, I try not to tell users they're wrong to want something.

> ...Oh well, the world is too lazy, I guess, to do what I consider "the
> right thing."

Yeah, I have a problem getting the world to obey me, too. ;-}

Bob Foster
http://www.xmlbuddy.com/
Re: Spaces for Tabs in non-Java editors? [message #122252 is a reply to message #120557] Wed, 03 September 2003 16:59 Go to previous messageGo to next message
Colin Sampaleanu is currently offline Colin SampaleanuFriend
Messages: 22
Registered: July 2009
Junior Member
Eric Rizzo wrote:
> AH wrote:
>
>> Eric Rizzo wrote:
>>
>>
>>> A tab in this context represents a unit of indentation.
>>
>>
>> This is incorrect. A tab is the same as the unit of indentation only in
>> simplistic editors, where indenting is done manually and each press of
>> the
>> tab key inserts a tab character into the file.
>
> [snip]
>
>> Once again tab size is not the same as indentation.
>
>
> Of course not - I think my point did not get across. I am arguing
> precisely that indentation and what editors call "tab size" *should* be
> thought of as separate notions. Tab characters embedded in files are
> useful for indentation because it is easy to say and get everyone to
> agree: "one tab character represents one level of indentation." What is
> *not* easy to agree upon is how a tab character should appear on the
> screen. So the appearance of a tab (that is, how many visual spaces)
> should be configurable (any decent editor provides this), but the use of
> tab characters in the code file should be mandated. Not the other way
> around, which is what people/organizations that use spaces for
> indentation have to resort to - because they allow spaces, it is
> difficult to get everyone to be consistent in their usage of them
> (nobody in his right mind tries to use more than one tab for one level
> of indentation, but people do use different number of hard spaces if
> given that choice - often the same person is not even consistent in the
> number of spaces he uses, much less being consistent with the rest of
> the team).
> For example: a common type of code standard is: "All indentation MUST be
> 4 spaces." But if instead they mandated: "Each level of indentation MUST
> be a single tab character" then each editor could be configured however
> the user wanted. The indentation will still look consistent and
> organized because the relative amount of indentation has not changed,
> only the appearance of it. It is analogous to the text color settings -
> just because I like my code text to be purple on yellow doesn't mean I
> can't see the organization of the code someone else wrote.
>
> Hope this makes my position more clear,
> Eric

Your perfect case simply never happens. Sure, if you had a java file
where _every_ element was positioned by using tabs and tabs alone, it
would work as you described. However, source files touched by multiple
people never get left like this. Somebody comes along with a tab
setting of '8' for example (that he's not able or unwilling to change
for editing java files), but wants to space something at an inbetween
value, and it blows away the whole setup. Now it's a big mess, anybody
else not also using a tab setting of 8 doesn't see things line up
properly. In practice, every single project I've seen which used hard
tabs, and was edited by a number of people ended up having mixed tabs
and spaces in it. Much much simpler to just mandate no tabs, and 2 or
4 spaces per level, and be done with it...
Re: Spaces for Tabs in non-Java editors? [message #122708 is a reply to message #122252] Thu, 04 September 2003 15:26 Go to previous message
Eclipse UserFriend
Originally posted by: eric.rizzo.jibeinc.com

Colin Sampaleanu wrote:
> In practice, every single project I've seen which used hard
> tabs, and was edited by a number of people ended up having mixed tabs
> and spaces in it. Much much simpler to just mandate no tabs, and 2 or
> 4 spaces per level, and be done with it...

That is an enforcement problem, not a problem with using tabs per se.
Mandating spaces does not solve that problem either, because the same
people who will not consistently follow an all-tabs mandate are just as
likely to not consistently follow a "set number of spaces" mandate (for
the same reasons you described).
I feel strongly about this in general, but the original post to which I
responded asked specifically if mandating spaces instead of tabs was a
good idea - IM<HO it is not. I guess I'm saying that if you're going to
mandate something, make it the right thing, the thing that is at the
same time flexible for editors *and* enforces consistent indentation
relationships. Mandating a fixed number of spaces loses the flexibility
part; spaces is worse than tabs in that respect and is no better than
tabs in any other respects.

Eric
--
Eric Rizzo
Software Architect
Jibe, Inc.
http://www.jibeinc.com
Previous Topic:Eclipse Taks View Action
Next Topic:Sudden Loss of CVS / Team Functionality
Goto Forum:
  


Current Time: Sun Oct 06 10:24:03 GMT 2024

Powered by FUDForum. Page generated in 0.04399 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top