Tabs -vs- Spaces: Tabs should have won.

rantingrick rantingrick at gmail.com
Sun Jul 17 21:49:03 CEST 2011


On Jul 17, 1:22 pm, Tim Chase <python.l... at tim.thechases.com> wrote:

> > Solution: STOP USING BROKEN TOOLS!!!
>
> Unbroken tools that do anything worthwhile are usually
> complicated tools.
>
> Just pointing that out in case you missed the irony...

You make a good point, albeit a very well know point. It's the same
kind of point Newton made when he wrote the laws of physics. Everyone
since cavemen knew that a falling apple would continue to fall until
the ground stopped it from falling. They just did not have the
eloquent phrasing of Newton to express the idea in words.

You've made the exact same well know expression as Newton. However we
do need to explore this subject of "broken tools vs unbroken tools" a
bit more. First let's start by understanding the difference between
broken and unbroken editors in the arena of tab width.

------------------------
 Tabs Explained:
------------------------
But what IS tab width exactly? Is it a simple unit of measurement like
four inches or 22 millimeters, or etc? Well it can be, but for the
most part it is something more. Especially in the arena of source code
editors!

In any plain text editor (i am not speaking of rich text editors or a
plain text editor in rich-text mode) where you have only one global
font choice at any given time a tab width should be the sum of N
glyphs multiplied by the current glyph width.

Here is some python code:

|>>> glyphW = 10.0 # in milimeters
|>>> def set_tab_width(nSpaces):
|	return glyphW * nSpaces
|>>> set_tab_width(1)
|10.0
|>>> set_tab_width(10)
|100.0

We as humans use "numbers of spaces" to define a tab width but
"numbers of spaces" is only an abstraction so we don't have to deal
with absolute measurements.

------------------------
 Fixed Width Fonts:
------------------------
If you are using a fixed-width-font you want the editor to use
relative spacing (relative to a glyph width) when defining tab width
in "spaces".

------------------------
 Non Fixed Width Fonts:
------------------------
On the other hand if you use non-fixed-width-font you want the editor
to use absolute measurements (since glyphs can be different widths)
when defining tab width.

------------------------
 Conclusion
------------------------
If your editor does not support as minimum the fixed width version, it
is broken. There is NOTHING complicated about creating tab width based
on the sum of N glyphs.





More information about the Python-list mailing list