Lines of code is still a stupid metric

Lines of code is still a stupid metric

I’m seeing a lot of noise lately about how many lines of code their AI made for them, as if more lines equal better code. I’ve seen this before. LOC as a metric keeps rearing its ugly head, and it’s been around from the beginning. Every decade or so, it pops back up, and the community has to rail against it with the same basic argument: it’s stupid. There is no real correlation between lines of code and code quality. There never has been, and never will be one.

Where it comes from

The whole idea is an artifact of the industrial age. Modern writers have been dealing with it longer than anyone. The idea is simple: a publisher has a sweet spot for space used for content. Newspapers have maximums to save costs. Book publishers often have a minimum to make the book feel heavy enough to sell. School teachers are just looking for a minimum to make sure kids write more than “bad book. The end” for a book report.

Why it doesn’t work

Programming is not writing. The similarity ends shortly after “they both have letters, numbers, punctuation, spaces, and lines” (ok and tabs). Using LOC as a metric for writing has some specific uses, but none of them translate to software. No one has ever said “I need a new module at least 100 lines long but no more than 500.” Ever. At least, no developer has said this unironically.

Code is instructions. Instructions have different rules to measure their quality. Good instructions are clear and complete. Clear meaning they only include what is needed to understand what needs to be done. No extra fluff. This is not just a style thing. Literally, the more code you make, the more areas you expose for error and testing time. Clear code usually has less LOC. Completeness is the other thing. Instructions that don’t include what to do if a step fails are poor instructions. And so there is the reason why code could have more LOC. The whole thing is a balancing act between too few and too many LOC.

Pushing back

When you see someone talking about their AI writing a 100,000 line app, be wary. If anything, my instinct as a senior dev is to ask, “why so many? How big is the feature set?” and “What challenges required this much code?” Measuring AI output in LOC has the same pitfalls as measuring Human output with LOC. It’s still dumb, even when you add the word “AI” to it.