From: davef@tsoft-inc.com   
      
   On 4/17/2025 8:58 AM, Dan Cross wrote:   
   > In article ,   
   > Arne Vajhøj wrote:   
   >> On 4/16/2025 9:29 PM, Dan Cross wrote:   
   >>> In article <67fee5b8$0$708$14726298@news.sunsite.dk>,   
   >>> Arne Vajhøj wrote:   
   >>>> There is no question that it is most accurate to only   
   >>>> count the continued line as one in your example.   
   >>>>   
   >>>> But I suspect that a lot of LOC counters just count   
   >>>> non-blank and non-comment.   
   >>>>   
   >>>> Anything else requires language knowledge.   
   >>>>   
   >>>> And while it for Fortran, Basic, Macro-32 may be relative   
   >>>> simple, then for other languages it can become more tricky.   
   >>>>   
   >>>> Let us take 4 times Pascal:   
   >>>>   
   >>>> if a = 1 then b := 2 else b := 3;   
   >>>>   
   >>>> if a = 1 then   
   >>>> b := 2   
   >>>> else   
   >>>> b := 3;   
   >>>>   
   >>>> if a = 1 then begin   
   >>>> b := 2;   
   >>>> end else begin   
   >>>> b := 3;   
   >>>> end;   
   >>>>   
   >>>> if a = 1 then   
   >>>> begin   
   >>>> b := 2;   
   >>>> end   
   >>>> else   
   >>>> begin   
   >>>> b := 3;   
   >>>> end;   
   >>>>   
   >>>> How many lines? I would say that the most correct is 3 in   
   >>>> all 4 cases. But coding the line counter to return that   
   >>>> would require it to have Pascal knowledge.   
   >>>>   
   >>>> And what about the fluent style that are so modern?   
   >>>>   
   >>>> o = f.create();   
   >>>> o.add(1);   
   >>>> o.add(2);   
   >>>> o.add(3);   
   >>>>   
   >>>> o = f.create()   
   >>>> .add(1)   
   >>>> .add(2)   
   >>>> .add(3);   
   >>>>   
   >>>> o = f.create().add(1).add(2).add(3);   
   >>>>   
   >>>> 1 1 1 or 4 1 1 or 4 4 1 or 4 4 4??   
   >>>>   
   >>>> So I think counters go for the simple approach and assume   
   >>>> that for large code bases with many developers then total   
   >>>> converge towards an "average" style.   
   >>>   
   >>> Most modern code-counting tools _are_ language aware. Whether   
   >>> they do a better or worse job for each given language may be a   
   >>> matter of debate, but most at least recognize different   
   >>> languages and have some knowledge of their semantics.   
   >>>   
   >>> Cf, https://github.com/XAMPPRocky/tokei?tab=readme-ov-file   
   >>> https://github.com/AlDanial/cloc?tab=readme-ov-file#recognized-languages-   
   >>> https://github.com/boyter/scc/blob/master/LANGUAGES.md   
   >>>   
   >>> etc.   
   >>   
   >> Their language awareness consist of recognizing comments.   
   >>   
   >> They are examples of some of those tools that simply count   
   >> non-blank non-comment lines.   
   >>   
   >> (SCC also know some keywords but that is used for complexity   
   >> calculation not for line counting)   
   >>   
   >> C:\Work>type demo.c   
   >> // C demo   
   >>   
   >> #include    
   >>   
   >> int main()   
   >> {   
   >> int a[] = {   
   >> 1,   
   >> 2,   
   >> 3   
   >> };   
   >> printf("%d %d %d\n",   
   >> a[0],   
   >> a[1],   
   >> a[2]);   
   >> return 0;   
   >> }   
   >>   
   >> C:\Work>cloc-1.96 demo.c   
   >> 1 text file.   
   >> 1 unique file.   
   >> 0 files ignored.   
   >>   
   >> github.com/AlDanial/cloc v 1.96 T=0.01 s (67.5 files/s, 1147.0 lines/s)   
   >> -------------------------------------------------------------   
   -----------------   
   >> Language files blank comment   
   >> code   
   >> -------------------------------------------------------------   
   -----------------   
   >> C 1 2 1   
   >> 14   
   >> -------------------------------------------------------------   
   -----------------   
   >>   
   >> C:\Work>scc demo.c   
   >> ───────┠  
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€   
   >> Language Files Lines Blanks Comments Code   
   >> Complexity   
   >> ───────┠  
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€   
   >> C 1 17 2 1 14   
   >> 0   
   >> ───────┠  
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€   
   >> Total 1 17 2 1 14   
   >> 0   
   >> ───────┠  
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â”   
   â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€â   
   €â”€â”€â”€â”€â”€â”€â”€   
   >> Estimated Cost to Develop (organic) $305   
   >> Estimated Schedule Effort (organic) 0.63 months   
   >> Estimated People Required (organic) 0.04   
      
   [continued in next message]   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|