Formatting of bootscripts

Ian Molton spyro at f2s.com
Tue Jan 4 17:03:17 PST 2005


Bruce Dubbs wrote:

> In basic research on program readability, indentation of 2-4 characters 
> has been found to be optimal.  Eight space indenting was evaluated to be 
> as bad as no indenting at all.

which is interesting, or perhaps misleading, I cant tell based on my own 
experiences.

I started off like most programmers of my age on BASIC, and used no 
indentation whatsoever (by the way, that would be Acorn BASIC, not the 
crappy basics available on the PCs of the era).

later I moved to one, then 2 spaces for indentation.

when I started learning other languages (including, but not limited to, 
C) I moved to 4 spaces, but of my own volition as I was teaching myself, 
and had NO net conectivity at that time. I wrote my own windowing 
library for RISC OS at about this time, and it was the only library I 
used in my applications (beyond C-lib), so my choice was, truely my own.

later, I got on the net and found that 8 character indents were common, 
yet I found them nearly unreadable. however I persevered, hooked by the 
diversity of code available, and nowadays find 8 character indentation 
100% natural and anything else (7 even) to be uncomfortable.

of course, there are a number of variables I coudlnt control here, not 
least of which my age, which may very well have impacted my preferences, 
and my growing exposure to other peoples code since I got 'online'.

> I teach students NOT to use tabs by inserting the following in .vimrc:
> 
> Sometimes a conscientious programmer puts some effort into making their 
> code readable.  Changing the tabstops can ruin that when a tab inserts 
> the equivalent of (say) 6 spaces for a 8 character tabstop.

My take on this is that its easier to teach students to use spaces 
universally because then alignment AND indentation is easy - simply 
add/remove spaces to taste.

My take, however, is that this is doing them as much a disservice as 
teaching them to use tabs universally.

if one uses tabs for indentation (indicating depth of nesting) then 
spaces may be used for the distinct task of aligning related information 
on the same indentation level. (see my eg. in my other post)

I urge you to reconsider the way you teach this to your students. Using 
spaces may be the quick (easy) fix, but it teaches no discopline 
regarding keeping track of the indentation / nesting. I find that people 
who understand this early on tend to become the better programmers.



More information about the lfs-dev mailing list