lines of code
**Lines of Code (LOC)** is a **software metric measuring program size by counting source code lines** — used for effort estimation, productivity measurement, and codebase analysis, though controversial as a quality indicator.
**What Is LOC?**
- **Definition**: Count of source code lines in a program.
- **Variants**: SLOC (source), LLOC (logical), CLOC (comment), BLOC (blank).
- **Use**: Size estimation, productivity metrics, complexity indicators.
- **Tools**: cloc, sloccount, tokei, wc -l.
- **Context**: Code AI uses LOC for context window management.
**Why LOC Matters**
- **Estimation**: Correlates with development effort.
- **Comparison**: Benchmark codebase sizes across projects.
- **Complexity Proxy**: Larger code often means more complexity.
- **Code AI**: Determines how much context fits in LLM window.
- **Technical Debt**: Track growth over time.
**LOC Counting Methods**
- **Physical LOC**: Actual lines including blanks.
- **Logical LOC**: Statements (semicolons in C-like languages).
- **Comment Lines**: Documentation density.
- **Blank Lines**: Code formatting style.
**Limitations**
- Language differences (Python vs Java verbosity).
- Quality not measured (bad code can be short or long).
- Incentivizes verbose code if used for productivity.
LOC is **useful for sizing, not quality** — a starting point for codebase understanding.