Updated 2012-09-11 01:08:16 by RLE

Source Lines of Code


Counting of SLOC is used for "software metrics tool" or "software measurement tool". Many software programs are quoted based on SLOC count.

There are two possible SLOC definitions, physical or logical. The physical SLOC definition is based on Dr. Barry Boehm's [1] Deliverable Source Instruction (DSI). It is programming language syntax independent, which enables it to collect other useful information such as comments, blank lines, and overall size, all independent of information content. The logical SLOC definitions will vary depending on the programming language due to language-specific syntax. The logical SLOC definitions are derived from the SEI's Code Counting Standard [2].


EZ-Metrix [3] supports all line-based languages (including Tcl) and is an internet-based commercial utility. Counts only physical SLOC.

SLOCCount [4] supports 27 different languages (including Tcl) and comes in source and RPMs (a MsWindows install requires Cygwin). Counts only physical SLOC.

CodeCount [5] supports 9+ different languages (not Tcl) and is distributed as ANSI C code under a USC Limited Public License. Counts physical and logical SLOC.

TSA [6] which comes as part of the new fickle package counts physical lines of comments, logical lines of code, and function invocations in Tcl code. (This is the only pure Tcl package that I know that does Tcl SLOC.) Jason Tang: TSA has a few errors in it. It can be tricked by interp, regexp, eval, et al. See if you can improve the code recognizer.

RamDebugger has a function to count number of lines of code.

See also Counting comments in a source.