Free tools Windows power users keep installed
One-click scans. No signup required.
A line of code (LOC) is a unit for measuring source software, but there is no single counting rule that applies everywhere. A physical count follows text line breaks; a logical count tries to count statements or other language-level units. To interpret an LOC figure, check which convention and inclusion rules were used.
What is a line of code?
In physical counting, a line is a segment of source text bounded by the applicable line ending or by the beginning or end of a file. This means a physical LOC count measures text layout, not necessarily the number of instructions a program performs. NIST’s measurement glossary documents multiple plausible definitions, so the acronym alone does not settle what a reported number means.
As an Amazon Associate I earn from qualifying purchases.
Physical LOC and logical LOC are different
Physical lines
Physical LOC follows line boundaries in the source file. A statement split over several lines can count as several physical lines, while a line containing multiple statements can count as one physical line.
Logical lines or statements
Logical LOC (sometimes abbreviated LLOC) aims to count language-level units, often statements, rather than text lines. Its meaning varies: it may mean statements, continuation-joined lines, or noncommented lines. A single statement can span multiple physical lines, and one physical line can contain multiple statements, so physical and logical totals can differ.
#1 Best Overall
The loccount manual describes LLOC as source lines with statement-terminating punctuation, while noting that this approach is suitable only for languages whose syntax supports it. Treat “logical LOC” as a convention that needs its own definition, not as a universally fixed alternative to physical LOC.
Which lines count?
A count depends on whether it includes blank lines, comment-only lines, and lines containing both code and comments. NIST’s glossary uses CLOC for a line containing only comments and whitespace or an empty line, and NCLOC for a LOC that is not a CLOC. Under that terminology, LOC = NCLOC + CLOC. Other frameworks may use “SLOC” for a count that excludes blank and comment lines, another reason to state the counting rules rather than rely on an acronym.
- Blank lines: may be included in a physical count, or excluded from a noncommented count.
- Comment-only lines: may be counted separately or omitted, depending on the measure.
- Mixed code-and-comment lines: may count as code. The CLOC documentation counts these lines as code.
Comment detection is not always exact. CLOC warns that it does not fully parse every target language; comment markers inside strings or here-documents can therefore be mistaken for actual comments. Its results describe that tool’s behavior, not a universal standard.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Why LOC counts are useful—and limited
LOC is a concrete software-size measure that can be collected statically. NASA discusses LOC as a common size measure and an input to software cost estimation. But a count does not directly establish software quality, complexity, productivity, or development effort.
Rank #3
The same algorithm can have very different LOC totals in different implementations, and formatting, language, and counting rules affect the result. The GAO guide to software cost estimating cautions that there is no standard definition of what should count; the same functionality can produce different totals depending on language and programmer. LOC can support a comparison or estimate only when its scope and rules are clear.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How to make an LOC figure interpretable
When publishing or comparing a count, report enough detail for someone else to understand what was measured:
Rank #4
- Whether the figure is physical LOC, logical LOC, NCLOC, or another defined measure.
- The programming languages and files included.
- Whether blank lines, comment-only lines, and mixed code/comment lines count.
- The counter and version, including relevant language or parser limitations.
- For project-size estimates, how generated, copied, and modified code is treated.
These distinctions matter in cost models too. The COCOMO II Model Definition Manual, Version 2.1 uses logical source statements as its standard LOC input and provides a checklist to make counting rules consistent. That is a model-specific convention, not a universal definition of LOC.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




