Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I had one (Linux only) and I lost it. I'd like another, either Windows or Linux will do.

Please don't turn this into a "such estimates are useless" discussion. I need ... something, anything ... to show that s/w development is not free.

Even a wild guess is better than nothing. The last one I used said something like X lines of code - the average US programmer would take Y months to do that at a salary of $Z.

Again, please don't tell me why I don't want it - because I do.

Apologies for trying to fend off the noise before it even starts. Thanks in advance for any help.

share|improve this question

closed as off-topic by gnat, GlenH7, MichaelT, Bart van Ingen Schenau, Simon Dec 16 '13 at 13:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – gnat, GlenH7, MichaelT, Bart van Ingen Schenau, Simon
If this question can be reworded to fit the rules in the help center, please edit the question.

I need ... something, anything ... to show that s/w development is not free. I suggest that you try asking this question as well. (In another post, of course.) In other words, look at what you're trying to achieve and ask for suggestions on how that may be achieved. –  George Marian May 3 '11 at 7:50

5 Answers 5

up vote 6 down vote accepted

I am 99.9% sure the tool you previously used was SLOCCount. You can download it from the site or on Ubuntu/Debian you can just install it with:

  sudo apt-get install sloccount

Using it as simple as running on the directory containing your source code. Then it gives output like:

SLOC    Directory   SLOC-by-Language (Sorted)
5793    jsim            cpp=5689,ansic=104
841     ksim            cpp=841
0       matlab          (none)

Totals grouped by language (dominant language first):
cpp:           6530 (98.43%)
ansic:          104 (1.57%)

Total Physical Source Lines of Code (SLOC)                = 6,634
Development Effort Estimate, Person-Years (Person-Months) = 1.46 (17.50)
 (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
Schedule Estimate, Years (Months)                         = 0.62 (7.42)
 (Basic COCOMO model, Months = 2.5 * (person-months**0.38))
Estimated Average Number of Developers (Effort/Schedule)  = 2.36
Total Estimated Cost to Develop                           = $ 197,018
 (average salary = $56,286/year, overhead = 2.40).
share|improve this answer
Do take it with a large pinch of salt. It claims that my last two months' work should have taken over three years. –  Mike Seymour May 3 '11 at 12:35
+1 and the answer. Thanks, Joe. yes, that was it. –  Mawg May 5 '11 at 0:46
mike, you get +1 too. I will take with a very large pinch of salt, but anything is better than nothing (and 2 weeks is a rather small sample time) –  Mawg May 5 '11 at 0:47
If you this answers your question please accept it :) –  Joe May 5 '11 at 19:47

For rough stats I find "grep" and "wc" to be suitable tools to estimate line counts. Something like:

egrep "[;}]" $(find -name "*.cpp" -or -name "*.hpp") | wc

Obviously it's not perfect, but it generally gets a good idea of the number of statements in the program.

BTW, you shouldn't ignore the fact that LOC is a terrible stat. All LOC measures is how much work it is to maintain the code. It has zero relation to the number of features and implementation time.

share|improve this answer
and +1 to you too. Thanks –  Mawg May 5 '11 at 0:49

Hit Amazon for Software Engineering Economics and Software Cost Estimation with COCOMO II, both by Barry Boehm. Read both of them. The first book is obsolete today: programs have gotten a lot bigger, and so have the computers that run them, but you still need to understand the concepts.

Then Google around for cloc. It is a straightforward SLOC counter.

Then hit Amazon again, for Calibration and Validation of the COCOMO II.1997.0 Cost/Schedule Estimating Model to the Space and Missile Systems Center Database, by Wayne A. Bernheisel. This shows you how to calibrate the COCOMO II estimator to your company.

For extra reading, pick up a copy of Controlling Software Projects: Management, Measurement, and Estimates, by Tom DeMarco.

share|improve this answer

You might be looking for USC CodeCount

Main Features:

  • Unified counting and differencing capabilities
  • Supporting multiple languages in a single tool
  • Counting and differencing directories
  • Detecting duplicate source files
  • Supporting both plain text and CSV output formats

Languages supported: Ada, ASP, ASP.NET, C#, C/C++, ColdFusion, CSS, HTML, Java, JavaScript, JSP, Perl, PhP, SQL, VB, VbScript, XML, and newly supported languages Bash Script, ColdFusion, C Shell Script, Fortran, NeXtMidas, Python, and XMidas.

share|improve this answer
+1 I'll try it, although that "would code $X to develop feature is very useful to me" –  Mawg May 5 '11 at 0:49

Suggestion: Use the unix/linux/cygwin wc command to count total lines.

By using some careful grepping you can eliminate comments (if that floats your boat - personally I don't because decent comments take TIME to write as well).

If you really want to you can count semi-colons - which gives a rough count of "statements" for languages like C and Pascal/Delphi/Ada. For C#, Java its a bit imprecise.

You can then use the COCOMO model to estimate effort and then use a rule of thumb (eg about 60% productivity/day) to turn that in actual hours and thus via average labor rates into $.

Be aware that COCOMO tends to be a bit on the high side, so if you know what you are doing and have a small team, the COCOMO estimates will be significantly higher than what it really takes, and you can multiply them by a fiddle factor somewhere in the region 0.5 to 0.8. (But if your team is more than 3 people be wary of doing this.)

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.