Jacinda can imitate cloc by combining it with other command-line tools on the Unix command-line, viz.
@include'prelude/fn.jac'
fn count(xs) :=
(+)|0 [:1"xs;
let
val bqn := {%/.bqn$/}{`1:i}
val hs := {%/.hs$/}{`1:i}
val ja := {%/.jac$/}{`1:i}
val pl := {%/.pl$/}{`1:i}
val sed := {%/.sed$/}{`1:i}
val asm := {%/.(S|asm)$/}{`1:i}
val rb := {%/.rb$/}{`1:i}
val py := {%/.py$/}{`1:i}
val c := {%/.c$/}{`1:i}
val awk := {%/.awk$/}{`1:i}
in sprintf'Haskell:\t%i\t%i\nBQN:\t\t%i\t%i\nJacinda:\t%i\t%i\nC:\t\t%i\t%i\nPython:\t\t%i\t%i\nPerl:\t\t%i\t%i\nSed:\t\t%i\t%i\nAssembly:\t%i\t%i\nRuby:\t\t%i\t%i\nAwk:\t\t%i\t%i'
( count hs . sum hs
. count bqn . sum bqn
. count ja . sum ja
. count c . sum c
. count py . sum py
. count pl . sum pl
. count sed . sum sed
. count asm . sum asm
. count rb . sum rb
. count awk . sum awk
)
end
This is invoked like so:
fd -t f -x wc -l | ja run cloc.jac
and gives something like
Haskell: 19 3092
BQN: 0 0
Jacinda: 53 389
C: 0 0
Python: 0 0
Perl: 0 0
Sed: 0 0
Assembly: 0 0
Ruby: 0 0
Awk: 11 133
fd and wc performance are the limiting factors; this is faster than cloc though slower than better code counters.
Conclusion
I think this is one of the cases where Jacinda's expression-oriented style is superior to Awk - one would need a variable for each language that would be ticked up.
That Jacinda's performance is not the limiting
factor vindicates the underlying design - folds, lazy ByteStrings
,
a tree-walking interpreter.