zlacker

[return to "The Source History of Cat"]
1. akkart+Xp[view] [source] 2018-11-13 03:38:42
>>janvdb+(OP)
Interesting to think what a different conclusion the article would have arrived at if he'd chosen to look at GNU cat on Linux. A few sample points:

* 2002: 833 LoC (http://landley.net/aboriginal/history.html)

* 2013: 36kLoC, 2/3rds of them .h files (https://news.ycombinator.com/item?id=11340510#11341175)

* 2018: 37kLoC of .c file dependencies going into libcoreutils.a and some LoC of .h files (coreutils has 60kLoC of .h files)

The methodology for counting lines likely isn't consistent across those data points. But the trend is still unmistakeable. Maybe I'll tree-shake all the dead code out and come up with an accurate line count one of these days..

◧◩
2. akkart+k42[view] [source] 2018-11-13 20:41:34
>>akkart+Xp
I just performed an ad hoc file-level tree-shaking for 'src/cat.c' in GNU coreutils 8.30, starting with `gcc src/cat.c` and gradually adding arguments until I got it to build. Here's the command I ended up with.

    gcc -I. -I./lib /
      src/version.c /
      lib/progname.c /
      lib/safe-read.c /
      lib/safe-write.c /
      lib/quotearg.c /
      lib/xmalloc.c /
      lib/localcharset.c /
      lib/c-strcasecmp.c /
      lib/mbrtowc.c /
      lib/xalloc-die.c /
      lib/c-ctype.c /
      lib/hard-locale.c /
      lib/exitfail.c /
      lib/closeout.c /
      lib/close-stream.c /
      lib/fclose.c /
      lib/fflush.c /
      lib/fseeko.c /
      lib/version-etc.c /
      lib/xbinary-io.c /
      lib/version-etc-fsf.c /
      lib/binary-io.c /
      lib/fadvise.c /
      lib/full-write.c /
      src/cat.c
Those .c files add up to 5021 lines.

The .c files include 44 header files:

    lib/binary-io.h
    lib/c-ctype.h
    lib/closeout.h
    lib/close-stream.h
    lib/config.h
    lib/c-strcaseeq.h
    lib/c-strcase.h
    lib/ctype.h
    lib/error.h
    lib/exitfail.h
    lib/fadvise.h
    lib/fcntl.h
    lib/fpending.h
    lib/freading.h
    lib/full-write.h
    lib/gettext.h
    lib/hard-locale.h
    lib/ignore-value.h
    lib/limits.h
    lib/localcharset.h
    lib/locale.h
    lib/minmax.h
    lib/progname.h
    lib/quotearg.h
    lib/quote.h
    lib/safe-read.h
    lib/stdio.h
    lib/stdio-impl.h
    lib/stdlib.h
    lib/string.h
    lib/sys/ioctl.h
    lib/sys-limits.h
    lib/sys/types.h
    lib/unistd.h
    lib/unused-parameter.h
    lib/verify.h
    lib/version-etc.h
    lib/wchar.h
    lib/wctype.h
    lib/xalloc.h
    lib/xbinary-io.h
    src/die.h
    src/ioblksize.h
    src/system.h
The header files add up to 19.7k lines.

So the total line count for files GNU cat actually needs to build is at least ~25k.

(I didn't bother checking for headers including other headers.)

Next step: do this for various versions of GNU coreutils.

[go to top]