On Thu, Jul 12, 2007 at 11:34:55PM +0900, Jan Moli?? wrote:
> 
> I read somewhere that good-style Ruby code is indented by 2 spaces. I'd like 
> to tell you my problem: I'm not disabled, but I have problems with reading 
> code if the indentation is only at 2 spaces. I must indent more. It's all 
> about my dysfunction of reading.
> 
> The main argument for using spaces is that the code looks everywhere same.
> But - who needs it? From my point of view, I don't care if the code looks 
> same on my and on my friend's computer. 

That's the argument for using two spaces all the time rather than
sometimes using three or four spaces, and for choosing to stick with just
spaces or just tabs rather than switching between the two.  It's not
specifically an argument for spaces over tabs.

There are arguments for spaces instead of tabs, but that's not really one
of them.


> 
> Of course, I expect the code to look same on my computer. There is a problem: 
> Unfortunately GNU/TAB is set to 8 characters and if you display code on 
> terminal, for example using diff or grep, it's not well readable and may look 
> different than in your editor. So it breaks what I wrote above about 
> same-looking code within one computer. I don't know if there is any solution 
> for this case or if TAB length is hardcoded in Linux/BSD kernel. 

You can alter tab length in your editor (for at least most editors,
including vi/Vim and Emacs).


> 
> from Linux coding style:
> "In short, 8-char indents make things easier to read, and have the added
> benefit of warning you when you're nesting your functions too deep.
> Heed that warning."

Using two spaces per indent also warns when functions are nested too
deeply.  It requires twice as many keystrokes per indent as using tabs,
which means you'll get tired of keystrokes for indentation twice as
quickly.  It works as a reminder for me, anyway.


> 
> On the other hand, terminal vs. editor difference is not fatal. I still can 
> better read more-indented code than less-idented code. I use vim-diff and 
> when I grep something, the grep output usually looks like a big mess and I 
> really don't care about indentation :-) Moreover, I spend much more time 
> programming than grepping, and that's why...
> 
> That's why I prefer TABs. The main purpose of TABs is - to indent. I don't 
> think it is archaic. Almost all good editors are able to set indentation 
> today, so everyone can set indent him/herself at pleasure. The code will 
> still look consistent on other's computer even if different indentation is 
> used there. If you indent using spaces, you can't set it alternatively (if 
> you don't want to do recoding, which is bad idea). 
> 
> There always be people who will need more indents because of their worse 
> recognition capability and they can do it thanks to TABs.

As mentioned in another response or two to your email, you can use the
expand and unexpand utilities to switch between spaces and tabs in your
source code files.  I would recommend coding in tabs if you must, and
using the expand and unexpand utilities to change code formatting as
needed so that whenever you share code (such as on this list) you present
it in two-space indentation style.


> 
> (Another con of TABs is editing code in editors which aren't able to set 
> indenation (notepad). But. Do you usually use notepad for programming? (Hmm. 
> (...))

Parse error: mismatched parentheses.


> 
> Of course, when I use TABs, I have to follow this rule: Don't use TABs 
> elsewhere just before first non-space character on a line. It means don't mix 
> TABs with spaces. If I format code to "table", use spaces.
> 
> FINAL QUESTIONS:
> 
> 1. Should there be the only one coding style in Ruby? I would prefer this, 
> but...
> 
> 2. Do you think everyone would accept it? No, one group would accept 
> TAB-style, another group would accept space-style. Maybe there could be two 
> styles for each group.
> 
> 3. Would all people accept one of those two styles? I don't think so.
> 
> 4. So should Ruby interpreter allow only those two styles? I don't think so.

Last I checked, leading whitespace is not syntactically significant, and
I'd like to keep it that way.  If I wanted significant whitespace, I'd
use Python.


> 
> 5. Is there any solution for TABs vs. spaces? No, I don't think so ;-)

See above, re expand/unexpand.


> 
> 6. Is this "war" 50:50? Or is it finished? Or... Any ideas?

By far, the majority of programmers these days seem to prefer spaces over
tabs.  There are certain communities that run strongly the other way,
still, but I think they will continue to be increasingly outnumbered at
least until there's a substantial shift in where things are headed in
that regard.


> 
> 
> Thank you for any answer on questions above and/or solution for the terminal 
> TAB length problem, which is the only real con of TABs for me.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
John Kenneth Galbraith: "If all else fails, immortality can always be
assured through spectacular error."