Lines of code (LOC, KLOC = 10K LOC, MLOC = 1M LOC etc., also SLOC = source LOC) is a metric of software complexity that simply counts the number of lines of program's source code. It is by no means a flawless measure but despite some soyboys shitting on it it's actually pretty good, especially when using only one language (C) with consistent formatting style. However it must also be used well -- here are the main caveats:
Of course it may also be necessary to define what a "line of code" means exactly. Usually we distinguish raw lines (every single one) and logical lines (only those that "matter", may exclude comments and empty lines). Does a long line with a line break count as a single line or two? Do we include line count of libraries we use? What if instead of lines we rather measured source code file size? Or programming language token count? Just make sure you know what you're measuring and why.
A comfy tool for counting lines is cloc
, but you can also just use wc -l
to count raw lines.
Here are (sometimes very) approximate line counts for some programs written (mainly) in C, in ascending order: hello world (~5), brainfuck interpreter (~50), Fairy-Max chess (~1000), raycastlib (~2000), dwm (~2500), SAF (~5000), Anarch (~15000), tcc (~25000), Lua (~30000), Doom (~35000), Quake (~100000), Pokemon Emerald (~500000), OpenBSD (~10000000), Linux (~30000000), Windows XP (~40000000).
Powered by nothing. All content available under CC0 1.0 (public domain). Send comments and corrections to drummyfish at disroot dot org.