4 ms·
Ask HN: Why is the number of lines of code a metric which is often cited?
Every now and again I hear '... has written a million lines of code' or '... needed x lines of code' - is that of any use?
Surely the aim should be to do as much as possible with as little code as possible? I guess you could argue that it can be used to show how 'hard' something was but an awful lot of code is copied and pasted with a few variables changed so this metric seems quite irrelevant to me.
Is it bs that just sounds impressive/dramatic or is there some good in it?
- mschuster91 13y agoManagement noobs always need something "quantifiable", and the SLOC count is the nearest thing you get for "quantifying code".
- bjourne 13y agoThe longer time you have practiced something, the better you get. If you have written 1m lines, then you can be expected to know more than someone who has just written 50k. If a musician has played on stage for 500 hours, they can reasonably be expected to be more experienced than someone who has only done it for 2 hours. It's a blunt metric, yes, but most of the time it works.
- Uhhrrr 13y agoI would say there is some good: * a program with 0 lines doesn't do anything. So there's a positive correlation right there. * "Code golf" code is typically hard to read, change, and debug, so this sets a lower bound on how much code you need to do something interesting. * Whether you're doing copy-pasta or not, the amount of functionality usually correlates positively with how many lines you've written. You're right that as one "levels up", the ratio of functionality/LoC goes down - again, not to code golf succinctness, but it will go down. So that's the danger of the metric. It encourages working hard, but discourages working smart.
- davismwfl 13y agoLOC was used extensively in costing models with waterfall development, and even some with iterative dev. But things have changed some. One thing I still use it for is monitoring features to maintainability. In other words, in established products/projects I will monitor my teams LOC checked in and I look for it to stay as small as possible or to decrease with revisions. Obviously this doesn't always happen, but I would rather reward the guy who removes 50 LOC versus the guy that adds 200, assuming they both got the same job done and features were delivered. I feel that LOC should never be used outside of the development team. i.e. No non-technical business mgr should ever see the metric as it is too easy to misunderstand or abuse. Also, LOC as I use it for established teams is almost totally useless in startups as the amount of code is usually pretty rapidly changing and expanding. Thus making LOC deceiving and misleading in my opinion.
- orangethirty 13y agoMusician = songs played. Mechanic = cars fixed. Programmer = lines of code. It relates to practice itself, and not quality.