Tabs versus Spaces in Source Code

B

Bill Pursell

Xah said:
Tabs versus Spaces in Source Code

Xah Lee, 2006-05-13

In coding a computer program, there's often the choices of tabs or
spaces for code indentation.
(2) Due to the first reason, they have created and
propagated a massive none-understanding and mis-use, to the degree that
many tools (e.g. vi) does not deal with tabs well

:set ts=<n>

Yeah, that's really tough. vi does just fine handling tabs. vim does
an even better job, with mode-lines, = and :retab.

In my experience, the people who complain about the use
of tabs for indentation are the people who don't know
how to use their editor, and those people tend to use
emacs.
 
A

achates

Jorge Godoy wrote
Emacs guess what's used in the file and allows me to use tabs all the time,
doing the correct thing...

That sounds like useful behaviour.

Maybe this is an area where modern editors might be able to save us
from ourselves. I'll admit I'm suspicious of relying on editor
functionality - I'm happier if I know I can also use the old-school
methods just in case.. Sometimes adding intelligence to an interface
can be a usability disaster if it makes wrong assumptions about what
you want. But if people are hell-bent on converting tabs to spaces,
maybe it's the best way to accommodate them.
 
P

Peter Decker

In my experience, the people who complain about the use
of tabs for indentation are the people who don't know
how to use their editor, and those people tend to use
emacs.

In my experience, whenever there is a 'religious' issue like this, one
side tends to be quick to pronounce the other as 'evil', and insist
that everyone do things their way, while the other tends to feel
comfortable with people having their own preferences. If I ever find
myself on the side of the former, I always wonder if I'm missing
something obvious.
 
A

Andy Sy

Peter said:
I don't seem to understand your point in acting as a dictator.
Therefore, you are a MISfeature and need to be removed.

Is the above an example of how a tab-user exercises 'logic'...?


Besides, I'm not the only dictator here... there are also the:

4-space tabs dictators...
8-space tabs dictators...
etc...
 
R

Roy Smith

Peter Decker said:
In my experience, whenever there is a 'religious' issue like this, one
side tends to be quick to pronounce the other as 'evil', and insist
that everyone do things their way,

I don't think people who use tabs are evil. They may be ignorant and
misguided, but they can still have the potential to be saved though
education and persuasion :)
 
B

Bill Pursell

Peter said:
In my experience, whenever there is a 'religious' issue like this, one
side tends to be quick to pronounce the other as 'evil', and insist
that everyone do things their way, while the other tends to feel
comfortable with people having their own preferences. If I ever find
myself on the side of the former, I always wonder if I'm missing
something obvious.

I think you unfairly snipped context on me. I was directly responding
to the assertion that vi is unable to handle tabs well.

As far as tabs vs. spaces, I don't think the spacers are evil, and in
fact I am one for pragmatic reasons. I would much prefer to use
tabs for indentation, especially since in the last few weeks I've
decided to upgrade from 4 to 8, and now all of my spaced code
requires much more effort than ":ts=8" to fix. But in today's world,
it's easier to go with the flow and use spaces.
 
A

Andy Sy

Peter said:
Spaces look like crap, too, when using proportional fonts.

.... and people who would even think that using proportional
fonts for viewing/editing source code is anywhere remotely
near being a good idea ...

That's an even more advanced version of the i-think-tabs-are-good
disease... LOL!
 
S

Sybren Stuvel

Andy Sy enlightened us with:
Now... if you say you SHOULDN'T mix tabs and spaces (indeed this is
generally regarded as a BAD idea esp. in Python code)

I indeed say so.
then WHAT THE HECK do you need to use tab characters in the source
code for anyway (besides saving a measly few bytes) ??!?

To separate layout (how much indentation is used) from semantics (how
many intentation levels).
Tab characters are EVIL *AND* STUPID.

And someone who needs to resort to all-caps words (which many consider
shouting) needs to relax and use proper arguments.

Sybren
 
P

Peter Decker

Is the above an example of how a tab-user exercises 'logic'...?

Uh, I should know better than to try to educate, but FYI: using the
same argument construction and having it reach an invalid conclusion
suffices to show that the original construction is invalid, and thus
the original conclusion is suspect.
 
P

Peter Decker

I think you unfairly snipped context on me. I was directly responding
to the assertion that vi is unable to handle tabs well.

I was *agreeing* with you. Sorry if that wasn't clear.
 
A

Andy Sy

Peter said:
Uh, I should know better than to try to educate, but FYI: using the
same argument construction and having it reach an invalid conclusion
suffices to show that the original construction is invalid, and thus
the original conclusion is suspect.


I guess this *REALLY* is how a misguided tab user exercises his 'logic':
Syntax replication (e.g. so-called 'argument construction') is enough,
semantics don't matter.

ROTFLMAO!
 
P

Peter Decker

I guess this *REALLY* is how a misguided tab user exercises his 'logic':
Syntax replication (e.g. so-called 'argument construction') is enough,
semantics don't matter.

ROTFLMAO!

My instincts were correct: it is foolhardy to attempt to educate closed minds.

<twitfilter status="on">
 
A

achates

Andy Sy
I guess this *REALLY* is how a misguided tab user exercises his 'logic':
Syntax replication (e.g. so-called 'argument construction') is enough,
semantics don't matter.

That's quite amusing.. you've unwittingly stumbled on a pretty concise
statement of Hilbert's first postulate of formal logic, proved by Godel
in 1930..
ROTFLMAO!

Indeed.
 
A

Andy Sy

achates said:
Andy Sy


That's quite amusing.. you've unwittingly stumbled on a pretty concise
statement of Hilbert's first postulate of formal logic, proved by Godel
in 1930..


Indeed.

Too bad that only applies to /statements phrased in formal
logic/, not to everyday statements expressed in a human language.

Only someone who has run out of sensible arguments or a disingenuous
sophist would try to extend this so-called postulate the way Peter
and you did.

Really... if you *actually* believed that Peter's argument had merit
and he was not merely being facetious, I guess I rest my case
regarding tab users and their 'logical prowess'.


LMAO again.
 
A

Andy Sy

Sybren said:
To separate layout (how much indentation is used) from semantics (how
many intentation levels).

Like I said, you'll *NEVER* get that fancy shmancy 'semantic indentation'
idea to work properly in the most basic utilities which have the 8-space tabs
assumption hardcoded in them.

Code with anything other than 8-space tabs will *NEVER* display
properly using everyday unix utilities such as less and cat. But then,
8-space tabs are just too wide to be practical, thus the simple
conclusion I have reached: JUST STOP USING THEM.

Heck, all those who actually believe that make's requirement of an
invisible tab as a 'semantic' marker was a good idea raise their
And someone who needs to resort to all-caps words (which many consider
shouting) needs to relax and use proper arguments.

I know when I'll be able to relax... when I no longer need to waste time
dealing with those stupid tabs in source code!!!

;-)
 
S

Sybren Stuvel

Andy Sy enlightened us with:
Like I said, you'll *NEVER* get that fancy shmancy 'semantic
indentation' idea to work properly in the most basic utilities which
have the 8-space tabs assumption hardcoded in them.

Fair enough. How much code is viewed with less and cat, and how much
is viewed using smart viewers/editors? I think the majority is viewed
using the latter.

Sybren
 
C

Carl J. Van Arsdall

Sybren said:
Andy Sy enlightened us with:


Fair enough. How much code is viewed with less and cat, and how much
is viewed using smart viewers/editors? I think the majority is viewed
using the latter.
Really though, he's got a good point. I'm typically viewing code in
vi. I don't know why so many people have so many issues with tabs, they
really aren't that difficult to work with and I think make life a little
easier when working on code with multiple people. You can setup your
environment to make tabs look like you want your code to look, your team
members can do tabs their way, and in the end the indentation levels all
work out fine.

People want to fight tooth and nail over this debate. But its really
not worth it. Get an editor that doesn't completely suck and you won't
have problems.

..c

--

Carl J. Van Arsdall
(e-mail address removed)
Build and Release
MontaVista Software
 
A

achates

Andy Sy:
Code with anything other than 8-space tabs will *NEVER* display
properly using everyday unix utilities such as less and cat.

less -x<tabstop> does what you want.
 
E

Edward Elliott

Sybren said:
Andy Sy enlightened us with:

Fair enough. How much code is viewed with less and cat, and how much
is viewed using smart viewers/editors? I think the majority is viewed
using the latter.

Just for the sake of completeness:

cat file |sed 's/\t/ /g'
less -x4 file

vim ~/bin.cat
#!/bin/sh
cat "$@" |sed 's/\t/ /g'
:wq
alias less='less -x4'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top