Computer Old Farts Forum
 help / color / mirror / Atom feed
From: steffen at (Steffen Nurpmeso)
Subject: [COFF] Was [TUHS] tabs vs spaces - entab, detab
Date: Thu, 11 Mar 2021 22:18:38 +0100
Message-ID: <> (raw)
In-Reply-To: <>

John P. Linderman wrote in
 <CAC0cEp9GVsYbjYhsYk2Hjjj90FxYFAia2Luy_vg854NTrV3Hww at>:
 |The tab/detab horse was still twitching, so I decided to beat it a little
 |Doug's claim that tabs saving space was an urban legend didn't ring true,
 |but betting again Doug is a good way to get poor quick. So I tossed
 |together a perl script (version run through col -x is at the end of this
 |note) to measure savings. A simpler script just counted tabs,
 |distinguishing leading tabs, which I expected to be very common, from
 |embedded tabs, which I expected to be rare. In retrospect, embedded tabs
 |are common in (my) C code, separating structure types from the element
 |names and trailing comments. As Norman pointed out, genuine tabs often
 |preserve line to line alignment in the presence of small changes. So the
 |fancier script distinguishes between leading tabs and embedded tabs for
 |various possible tab stops. Small tab stops keep heavily indented code
 |lines short, large tab stops can save more space when tabbing past leading
 |blanks. My coding style uses "set-width" of 4, which vi turns into spaces
 |or tabs, with "standard" tabs every 8 columns. My code therefore benefits
 |most with tabstops every 4 columns. A lot of code is indented 4 spaces,
 |which saves 3 bytes when replaced by a tab, but there is no saving with
 |tabstops at 8. Here's the output when run on itself (before it was
 |detabbed) and on a largish C program:
 |  /home/jpl/bin/ /home/jpl/bin/ rsort.c
 |/home/jpl/bin/, size 1876
 |  2: Leading 202, Embedded 3, Total 205
 |  4: Leading 303, Embedded 4, Total 307
 |  8: Leading 238, Embedded 5, Total 243
 |rsort.c, size 209597
 |  2: Leading 13186, Embedded 4219, Total 17405
 |  4: Leading 19776, Embedded 5990, Total 25766
 |  8: Leading 16506, Embedded 6800, Total 23306
 |The bytes saved by using tabs compared to the (detabbed) original size are
 |not chump change, with 2, 4 or 8 column tabstops. On ordinary text, savings
 |are totally unimpressive, usually 0. Your savings may vary. I think the
 |horse is now officially deceased. -- jpl

Not really.  I mean, i do not insist of this, but i looked at the
numbers.  And despite col(1) 2.36.2 giving the wrong line when
failing to dig a LATIN1 in UTF-8 (should be 7, gave 11), when
i sum up the total of 8: in an old project with tests,
documentation etc. here the output is 1044401.  This is without
generated data.  I mean, even today i strip whitespace in shipout
code, of generated data, of documentation parsed through
processors.  This includes mangling of internal interface headers
and removal of their documentation and comments, but copyright.
You know, only this automatized pre-release step of the pretty
small open source MUA i maintain causes this line count change:
  37 files changed, 2441 insertions(+), 10537 deletions(-)

|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

  reply	other threads:[~2021-03-11 21:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 20:02 jpl.jpl
2021-03-11 21:18 ` steffen [this message]
2021-03-11 23:31   ` jpl.jpl
2021-03-12  0:31     ` steffen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \
    --to= \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Computer Old Farts Forum

This inbox may be cloned and mirrored by anyone:

	git clone --mirror

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 coff coff/ \
	public-inbox-index coff

Example config snippet for mirrors.
Newsgroup available over NNTP:

AGPL code for this site: git clone