Discussion:
[Xmltv-devel] Indentation analysis: an aside
Nick Morrott
2015-07-12 22:54:20 UTC
Permalink
Whilst tidying trailing whitespace across the core libs/utilities last
night I became aware of the variety of different indentation styles
used in the project. I cleaned up the few files with more esoteric 5,
6 and 8 space indents.

Running the Indent Finder tool
(http://www.freehackers.org/Indent_Finder) against the XMLTV repo
(omitting CVS-specific files and test data) gives me the following
stats as I write this:

$ find xmltv-cvs -type f -name * -print | \
grep -Pv 'CVS|blib|/t/data' | sort | \
xargs python indent_finder.py | \
awk -F ' : ' '{print $2}' | sort | uniq -c

9 mixed tab 8 space 2
62 mixed tab 8 space 4
27 space 2
2 space 3
185 space 4
16 tab 4


I'm of the opinion that, "tabs v spaces" arguments aside, above all
they should be used consistently across the project.

Does anyone else agree?

Cheers,
Nick
Robert Eden
2015-07-13 04:14:22 UTC
Permalink
Post by Nick Morrott
I'm of the opinion that, "tabs v spaces" arguments aside, above all
they should be used consistently across the project.
Does anyone else agree?
I think you recently commuted fixes for it, but I don't think it really
matters... XMLTV isn't really a single consistent project, but a
collection of separate tools. Having different or inconsistent
indention isn't that big a deal, in my opinion. (I don't mind someone
fixing it.. it's just not worth the time to do)

I'm notoriously bad about indents. :) Sometimes I intentionally screw
up indents to make parts of the code easier to read (say a SQL query).
Some of the picker folks I've worked with have complained about my going
for ascetics over consistency :)
Nick Morrott
2015-07-13 10:14:54 UTC
Permalink
Post by Robert Eden
Post by Nick Morrott
I'm of the opinion that, "tabs v spaces" arguments aside, above all
they should be used consistently across the project.
Does anyone else agree?
I think you recently commuted fixes for it, but I don't think it really
matters... XMLTV isn't really a single consistent project, but a
collection of separate tools. Having different or inconsistent
indention isn't that big a deal, in my opinion. (I don't mind someone
fixing it.. it's just not worth the time to do)
My updates over the weekend were mostly to remove trailing whitespace.
I also fixed up the few files that were using "interesting" indents.

I grok that the project is a suite of various tools and utilities, but
it would be beneficial to current and future contributors (IMO) for at
least the core libraries to use consistent formatting.
Post by Robert Eden
I'm notoriously bad about indents. :) Sometimes I intentionally screw
up indents to make parts of the code easier to read (say a SQL query).
Some of the picker folks I've worked with have complained about my going
for ascetics over consistency :)
The one consistent thing the XMLTV project does with indents is use
them inconsistently!

Nick
h***@gmail.com
2015-07-13 10:29:23 UTC
Permalink
Post by Nick Morrott
The one consistent thing the XMLTV project does with indents is use
them inconsistently!
ROFL.
I think (from memory) Perldoc can't handle tab chrs so we'd probably need to standardize on whitespace rather than hard tabs. And for the benefit of people editing in Windoze it might be easiest to decide that tab = 4 spaces (rather than 8) ?
h***@gmail.com
2015-07-13 07:11:30 UTC
Permalink
Post by Nick Morrott
Whilst tidying trailing whitespace across the core libs/utilities last
night I became aware of the variety of different indentation styles
used in the project. I cleaned up the few files with more esoteric 5,
6 and 8 space indents.
[...]
Post by Nick Morrott
I'm of the opinion that, "tabs v spaces" arguments aside, above all
they should be used consistently across the project.
Yes it's a long running debate among programmers isn't it :-)

Personally I prefer to see leading hard tabs rather than spaces. This seems the most flexible way. I can then set my editor/IDE to interpret tab as however many spaces *I* like with no impact on anyone else. I use portrait orientation so rapidly run out of screen real estate if tabs are set at 8! (And I don't think that level of indentation helps readability over the more normal 4). Usually I have tab interpreted as 2 spaces, but with a mix of leading tabs and leading whitespace this doesn't always work (unless the file has emacs-style header).

In the olden days (20th century) we couldn't do this reliably since many editing programs didn't understand chr(9) and could only indent using whitespace (or soft tabs). Surely that's not the case any more.

Most of the Internet arguments against using hard tabs revolve around this lack of backwards compatibility with 1990s editor software! They conspicuously avoid the fact it resolves the problem of *nix using 8 chars for soft tab whereas Windoze uses 4.

Cheers,
Geoff
Nick Morrott
2015-07-13 10:02:34 UTC
Permalink
Post by h***@gmail.com
Post by Nick Morrott
Whilst tidying trailing whitespace across the core libs/utilities last
night I became aware of the variety of different indentation styles
used in the project. I cleaned up the few files with more esoteric 5,
6 and 8 space indents.
[...]
Post by Nick Morrott
I'm of the opinion that, "tabs v spaces" arguments aside, above all
they should be used consistently across the project.
Yes it's a long running debate among programmers isn't it :-)
The next exciting development is programming in proportional fonts and
whining when things don't line up.
Post by h***@gmail.com
Personally I prefer to see leading hard tabs rather than spaces. This seems the most flexible way. I can then set my editor/IDE to interpret tab as however many spaces *I* like with no impact on anyone else.
Because (not just) your code uses leading 4-space indents in addition
to hard tabs, this approach still doesn't work. I must use a tabstop
of 4 spaces otherwise formatting will break.

By contrast, other core XMLTV libs use 8-space tabs and mixed indents,
so their formatting breaks if I set my default tabstop to 4 for this
project...

I'm guessing these issues arise because some editors:

i) don't display tab chars
ii) don't notify you when you are using mixed indents
iii) don't remove trailing whitespace
Post by h***@gmail.com
I use portrait orientation so rapidly run out of screen real estate if tabs are set at 8! (And I don't think that level of indentation helps readability over the more normal 4). Usually I have tab interpreted as 2 spaces, but with a mix of leading tabs and leading whitespace this doesn't always work (unless the file has emacs-style header).
I think Mattias was/is the only contributor who adds an (emacs) editor
hint at the bottom of his authored files. The same can be added for
Vim, etc, but it all boils down to using tabs consistently.
Post by h***@gmail.com
In the olden days (20th century) we couldn't do this reliably since many editing programs didn't understand chr(9) and could only indent using whitespace (or soft tabs). Surely that's not the case any more.
No (serious) editor has that limitation that I am aware of, but if
anyone knows of any, please do tell!

Cheers,
Nick
Loading...