Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

60%
+1 −0
Q&A What is the most accurate CLOC (count lines of code) program?

Objectively, the most accurate way would be to actually count the lines. So you would do wc on each file and add them up. This ends up being not a very useful statistic, because it is sensitive to...

posted 3mo ago by matthewsnyder‭

Answer
#1: Initial revision by user avatar matthewsnyder‭ · 2024-08-19T18:29:57Z (3 months ago)
Objectively, the most accurate way would be to actually count the lines. So you would do `wc` on each file and add them up.

This ends up being not a very useful statistic, because it is sensitive to many trivial things that people who talk about LoC would rather disregard: Blank lines, lines broken for readability, commented lines, duplicated code, dummy files, non-code files.

Usually, what people want to know is something like "how many instructions in this codebase?" because they are trying to understand its complexity, not how many times you pressed the return key. This is probably why `tcount` claims it's more accurate.

There's another tool called [SLOCCount](https://dwheeler.com/sloccount/) which is made by a researcher who is an expert on measuring code base complexity. There are many others as well if you search for line counters online.