
Lines of Code
Lines of Code is the number of text lines that make up a computer program. The figure is often used as a rough measure of a program's size, but it says little about its quality.
Programs consist of text that humans write and computers execute. This text is arranged line by line, similar to a poem or a recipe. Lines of Code, LOC for short, simply counts these lines. A small practice program might have 50 lines. A computer’s operating system, on the other hand, can comprise many millions of lines. Because the number is easy to measure, it keeps turning up in reports, talks, and news stories.
Why the number is so popular as a size measure
Software is invisible. You can’t touch, weigh, or measure a program. That’s why companies like to reach for a number that can be determined automatically. A counting tool delivers the lines of code in seconds. That makes LOC the simplest piece of information available about a project’s size.
The number helps in gauging orders of magnitude. A project with 2,000 lines can be overseen by a single person. At two million lines, no one understands the whole thing alone anymore. It is exactly at this threshold that working methods, tools, and costs change. Maintenance and security reviews also become more laborious as the line count grows.
It becomes dangerous when LOC is used as a performance measure. Anyone paid by lines written will write convoluted code. The well-known computer scientist Edsger Dijkstra put it pointedly: lines of code should not be counted as units produced, but as money spent. Shorter code that achieves the same result is usually the better one.
What exactly counts as a line
Counting sounds unambiguous, but it isn’t. Program text contains blank lines for better readability. It contains comments, i.e. notes for humans that the computer ignores. Some counts include everything, others only actual instructions. The latter is called Source Lines of Code, abbreviated SLOC. Between the two values there can easily be a 30 percent difference.
The programming language also distorts the result. A task that takes ten lines in one language may need a hundred in another. Comparing two projects therefore only makes sense if both use the same language. Otherwise you’re comparing book pages set in different font sizes.
Experts therefore use supplementary measures. Cyclomatic complexity, for example, counts the branches in a program, i.e. the points with if-then decisions. It says more about how hard a program is to understand. Nevertheless, LOC remains the figure everyone mentions first, because everyone understands it immediately.
LOC in AI news and developer tools
Since AI assistants started suggesting code, the number is being cited more often again. Vendors advertise that a certain share of the code in their tools comes from AI. Google and Microsoft have publicly cited shares ranging from around a quarter to over a third. Such figures are almost always based on counted lines of code.
These percentages should be read with caution. AI assistants often add short, recurring lines. The difficult decisions about a program’s architecture are still made by a human. A high share of lines therefore does not mean that the AI has done a third of the work.
In everyday life, you also encounter LOC outside of AI topics. On platforms like GitHub, where programmers publish their code, every change shows how many lines were added and how many were removed. In security reports, the line count serves as a reference figure, for example in terms of bugs per thousand lines. And when the news talks about a program with a hundred million lines, it is precisely this measure that is meant.