# What Passes For "Lines of Code"?

This topic is 4459 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

When you tell someone you have 10,000 lines of code in your project, what gets counted as a "line"? white space? comments? Or perhaps i should ask: what does NOT get counted? What do you say?

##### Share on other sites
grep -r ''' * | wc -l

I guess you can grep -v '^$' or something to get rid of blank lines, but really, it's a waste of time to worry about that. LOC is relatively unimportant. Why do you want to know? hehe. #### Share this post ##### Link to post ##### Share on other sites Ususally you use a program like sloccount (http://www.dwheeler.com/sloccount/) to count the lines of code. I know that it doesn't count comments, at least. #### Share this post ##### Link to post ##### Share on other sites Quote:  Original post by James TrotterUsusally you use a program like sloccount (http://www.dwheeler.com/sloccount/) to count the lines of code. I know that it doesn't count comments, at least. Cool, i missed that one. There was a Debian package and everything! Thanks. sloccount says my engine project would cost$459,150 to produce.

Look, there goes my ego!

##### Share on other sites
My definition for a "line" of code is a line that does something. Comments, formating, blank lines, { } does not count, it must be code that processes something.

theTroll

##### Share on other sites
I generally assume it means number of lines containing at least one non-whitespace, non-comment character.

But if you want a metric of code complexity that doesn't suck, look up Cyclomatic Complexity. Having said that, line counds and cyclomatic complexity are really useful for different things - code complexity should be minimized, since more complex code contains more bugs, cyclomatic complexity is useful for measuring the complexity of some relatively small section of code (eg, one function, or a few functions). Line counts only make sense on a much larger scale, to give a rough estimate of the scale of an entire project.

Another one that might be reasonable is object-code size, when compiled with optimization. Although it would only make sense to compare the sizes of things compiled with the same compiler and settings.

John B

##### Share on other sites
I say it doesn't matter.
Two people could code the same function and each could have different line counts, speed not line counts matter.

##### Share on other sites
Any company which counts LOCs as a measure of productivity richly deserves the code it ends up with.

##### Share on other sites
A coworker of mine told me that 20-40 years or so ago he had the Lines of code for performance, but it backfired. programmers would code the program with the largest footprint, but with the days of mainframes with limited resoruces the smaller programs were given a higher priority in the thread pool. So lines of code did not help in measure a good programmer from a bad one...

Plus I could write the same logic 2 different ways (and then some)

for (int i = 0; i &lt; len; i++){
cout &lt;&lt; i &lt;&lt; endl;
}

int i;
for (
i = 0;
i &lt; len;
i++)
{
cout &lt;&lt; i
&lt;&lt; endl;
}

Wow... Example 2 is almost 3 times longer... so that programmer should get a raise that is 3x more than the first programmer.

1. 1
Rutin
19
2. 2
3. 3
JoeJ
16
4. 4
5. 5

• 27
• 20
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631700
• Total Posts
3001791
×