[Shootout-list] LOC
Brent Fulgham
bfulg@pacbell.net
Sat, 30 Apr 2005 20:53:59 -0700
On Apr 30, 2005, at 5:43 PM, Jon Harrop wrote:
>
> I'm just perusing the shootout and am noticing lots of dubious LOC
> counts.
>
> For example, spectralnorm in D is 52 LOC but is counted as 30 LOC:
>
> http://shootout.alioth.debian.org/sandbox/benchmark.php?
> test=spectralnorm&lang=dlang&id=0&sort=fullcpu
>
> I only get 30 LOC if I ignore braces. I appreciate that (assuming this
> is
> deliberate) there is a valid debate here but, personally, I'd like say
> that I
> believe coding efficiency is a strong function of the amount of code
> you can
> see on the screen at any one time and, consequently, the verbosity of
> unnecesary braces in such languages is a major hindrance.
>
It used to be the other way; I stopped counting brace-only lines due to
popular vote.
> For example, instead of writing:
>
> if (i == 0)
> {
> j += 1;
> }
>
> I'd write:
>
> if (i == 0) ++j;
>
> which is shorter than the above even if braces are ignored.
Ugh. I hate it when people do this. It becomes hard (when debugging)
to tell if the test succeeded or not -- you can't see if the ++j is
executed (unless you compare before/after values). Obviously it's not
a big deal in this case, but I had one developer who coded things like
this:
if ( i = function2( y ) ) function1(y) else function2(y);
Bad bad bad.
-Brent