LoC - number Lines of Code
What is SloC and LoC?
In general, it refer to number of lines in the text of the program’s source code of your software. Sometimes it refer as SloC
, LoC
, NLoC
and Ln
. I prefer to use LoC
abbreviation because it shorter and mostly use only by counting programming line and ignore the comments.
Can we use it as metric?
There is a famous quote about LoC
which highlight
“Measuring programming progress by lines of code is like measuring aircraft building progress by weight.” β Bill Gates
From the point of view of the architect, it’s a very good strategy. I guess Bill is talking about the design not building. It close related to efficiency, reliability, robustness, portability, maintainability, readability and optimization (compiling, debugging and runtime).
Now after reading my sentence previously, you may think about getting highest LoC
means your software quality are lowest. That is not true, to measure quality we need evolution and adaptation.
Do you know Margaret Hamilton ? She was director of the Software Engineering Division of the MIT laboratory, which developed on-board flight software for NASAβs Apollo program. She is one of the people credited with coining the term “software engineering”.
That time, she play role as Colossus Programming Leader Apollo Guidance and Navigation
and have a look on the picture I embed on this post. There a piles of book which claimed as printed source code for Apollo 11 guidance computer (AGC).
Lucky enough, there some portion of that code are released under Public Domain Mark 1.0 on Github repository. Go and check if you are interested.
When programmers at the MIT laboratory set out to develop the flight software for the Apollo 11 space program in the mid-1960s, the necessary technology did not exist. They had to invent it by created a special version of the assembly programming language and some stuff they called as “rope memory”.
In this case, chances to get lower LoC
are difficult. That why I said we need evolution and adaptation which means, it depend on situation that you are facing. Don’t just jump in and conclude it.
If you do code and it works but LoC
look higher on eyes of stakeholder and they not approving it then the delivery maybe take much more time. That actually are not not a good idea since there is many coding approach programmer can use to cheat.
Let talk about coding style and standard. Take look on two example below, you will get what I mean before:
- Example A
for (i = 0; i < 100; i++) printf("hello"); /* How many LoC is this? */
- Example B
/* Now how many LoC is this? */
for (i = 0; i < 100; i++)
{
printf("hello");
}
Read the comment I left on the snippet. I hope you get what I means here. Both coding style have same order of magnitude and same output. Which one is better? on what term? Readability or lower LoC
?
As conclusion, don’t use LoC
as mandatory metric to measure progress and evaluate programmer. There is lots of another useful metrics that you can use. Hopefully, you won’t become someone are so strict about getting lowest LoC
all the times because it not so useful, don’t bashing it. Alternatively go deeper by taking a look on coding style, Cyclomatic Complexity, Cognitive Complexity and more. This way will look much smarter by this way. Take look on the design mich deeper and evaluate it.
P/s: Apollo 11’s source code has tons of Easter Eggs. Imagine with just 2MHz, 4KB RAM, 72KB ROM that’s enough to fly to the moon, land, and return. That was crazy π€
Related Posts
Other posts you may be interested in:
IndieWeb Interactions
Below you can find the interactions that this page has had using Indieweb. Which means, you can mentioned this URL on any website that support WebMention. Have you written a response to this post? Let me know the URL:
((Do you use a website that do not set up with WebMention capabilities? You can use Comment Parade.)