[Shootout-list] LOC

Ben Hinkle Ben Hinkle <ben.hinkle@gmail.com>
Sat, 30 Apr 2005 23:23:02 -0400


On 4/30/05, Jon Harrop <jon@ffconsultancy.com> wrote:
>=20
> I'm just perusing the shootout and am noticing lots of dubious LOC counts=
.
>=20
> For example, spectralnorm in D is 52 LOC but is counted as 30 LOC:
>=20
> http://shootout.alioth.debian.org/sandbox/benchmark.php?test=3Dspectralno=
rm&lang=3Ddlang&id=3D0&sort=3Dfullcpu
>=20
> 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 th=
at 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.

Looking at the C++ version of the same benchmark there's the function:

void eval_AtA_times_u(const vector<double> &u, vector<double> &AtAu)
{ vector<double> v(u.size()); eval_A_times_u(u, v); eval_At_times_u(v, AtAu=
); }

which is very unusual C++ coding style. The coding style in the D
example (with one statement per line and braces on the next line) is
common and should be allowed as a "legit" coding style. If we let
benchmarks use any coding style the author wishes then the benchmarks
will quickly end up with 1 line programs for every benchmark.

I don't have any great suggestions for how to measure "verbosity" more
accurately -perhaps the number of non-whitespace characters? It seems
like LOC is too gross a measurement.

-Ben Hinkle