loading...

How do you count your lines of code?

codelitically_incorrect profile image codelitically_incorrect ・1 min read

As Javascript developers, we have to wield several technologies to get a UI built. How do you go about counting your lines of code on a per screen basis?

Do you factor in css line-count and html line-count or do you look at your line-count as being pure Javascript logic?

Discussion

markdown guide
 

I use sloc when I'm curious about the amount of lines and TODO's are in the project/folder/whatever.

I work on web projects, so npm and thus this package is right at my finger-tips with: npx sloc src

Here's an example output for an old project I did a while back:


---------- Result ------------

            Physical :  2723
              Source :  1935
             Comment :  816
 Single-line comment :  152
       Block comment :  664
               Mixed :  107
 Empty block comment :  0
               Empty :  79
               To Do :  7

Number of files read :  37

----------------------------

I don't believe line-count means that much. I usually abuse formatting for extra lines. Its a "nice-to-know", something to brag to your friends about, but that's about it. I'd consider it like writing a good novel. More pages doesn't mean its a better book, it could be, or it could be not.

 

Question is, why would you even bother to count them in the first place? that number is almost meaningless anyway...

 

Hi Zohar,
LoC is a high-level human benchmark in front-end UI development that tells a story, an important one and it began in the days of 14.4 modems when we just had to deliver highly optimized code.

I wrote C# and Java and write NodeJS, we never count LoC, it's compiled and is delivered as software unto servers, but you know all this.

Besides optimization, there are bigger issues in LoC at the browser side, as this article today points out:
medium.com/@sakthishanmugam02/look...