[Israel.pm] Number of Indentation Levels in Ruby and Perl

Shlomi Fish shlomif at iglu.org.il
Sat May 30 09:42:43 PDT 2009


I've been mostly programming in Perl for more than a decade, and for a long 
time (possibly longer) have adopted a 4-whitespace indentation increment. This 
worked pretty well in Perl, and I rarely ran out of indentation. I've also 
successfully used 4-whitespace increments in C, in bash and a little in 
Python. 

Now, I've been studying Ruby in the past few years, and one of the pieces of 
advice I got was that it is customary to use 2-whitespace increments in Ruby 
code instead of 4, because indentation is used to a large number of levels in 
Ruby. Now, I haven't converted to 2-whitespace increments in Ruby yet, but I 
did notice that when I'm writing Ruby code, I tend to run out of indentation 
with 4-ws-increments, and find my code to be too indented to the right.

My question is: can anyone explain why are 4-ws-increments good enough in 
Perl, C, and other languages, but they tend to be insufficient in Ruby code? 
Why are more indentation levels required in Ruby? Or are the lines themselves 
are required to be longer?

Regards,

	Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
What Makes Software Apps High Quality -  http://xrl.us/bkeuk

God gave us two eyes and ten fingers so we will type five times as much as we
read.



More information about the Perl mailing list