Link Details

Link 6122 thumbnail
User 205047 avatar

By lowellheddings
via johnnysthoughts.com
Published: Nov 04 2006 / 23:47

Half of my day at work was spent trying to locate a bug in a 1,996 line source file… which got me thinking… Just how many lines of code are in this application anyway?
  • 10
  • 0
  • 1437
  • 113

Comments

Add your comment
User 111696 avatar

bloid replied ago:

0 votes Vote down Vote up Reply

A nicely written little tutorial that.

But he doesn't take blank lines or comment lines into account, both of which are a good thing.

But I guess spacing and comments push up the LOC -- and as everyone knows, a lower LOC means a better quality product: eg: http://www.dzone.com/links/python_tetris_program_in_just_15_lines.html ;)

User 205047 avatar

Lowell Heddings replied ago:

0 votes Vote down Vote up Reply

Good points... I also found a really interesting article that unfortuneately only works for VS2005:

http://www.dzone.com/links/line_counter_writing_a_visual_studio_2005_addin.html

User 164901 avatar

dagi3d replied ago:

0 votes Vote down Vote up Reply

I think that if you have 2000 lines of code in a single file there is a problem with your code and you should try to refactorize it

User 205047 avatar

Lowell Heddings replied ago:

0 votes Vote down Vote up Reply

No kidding!

User 61820 avatar

atripp replied ago:

-1 votes Vote down Vote up Reply

Holy cow, all that to count the number of lines in a file???
Get yourself a UNIX or Linux machine or cygwin and type "wc ".
I always wonder to myself how Windows-only people get any work done, and posts like these give me an answer: they don't :(

If you want a real line counter (comments, blank lines, etc.) you can use my free servlet at jazillian.com.

User 208905 avatar

Firewheels replied ago:

0 votes Vote down Vote up Reply

Just about my reaction. Need the linecount of a file?
cat file | wc -l
How about the linecount omitting comments?
cat $file | grep -ve "^\/\/|^ \*|^\/\*" | wc -l

Doesn't get much easier than that. YMMV depending on coding style, of course.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (10)



Voters Against This Link (0)