SWTR: Software Tools in Rust
Software Tools is Brian W. Kernighan and P. J. Plauger's classic book about how to write good programs that are good tools. It was originally published with programs presented in Ratfor, a language built on top of Fortran. Later, Kernighan and Plauger published Software Tools in Pascal, which adapted the software tools to Pascal and led Kernighan to write Why Pascal is Not My Favorite Programming Language
The programs in Software Tools are simple, but they are not trivial. They do things that real programs would have to do, and they're open-ended, leaving the programmer with room to add more useful behaviors.
Mark Jason Dominus once told me about Software Tools in Haskell, which undertook to produce the Software Tools programs in Haskell. (Obviously). It struck me that these would be good programs for getting a handle on a new language, and I kept meaning to test this out.
This repository is my attempt to finally do so, by writing (so far terrible) implementations of the Software Tools in Rust.
The contents of ./t
are basic tests for the programs, written in Perl 5. My
hope is that these tests will be useful in future Software Tools in Whatever
projects.
The Tools
This is a list, in book order, of the software tools. Names and summaries are sometimes my own, giving the more familiar UNIX name in place of the book's name.
Chapter 1: Getting Started
cp
: copy a file to a new namewc
: count the number of bytes, words, and lines in a filedetab
: expand tab characters to line up with tabstops
Chapter 2: Filters
entab
: collapse space characters into tabsoverstrike
: some sort of weird typewriter filter… better figure this outcompress
: a quick and lousy compression utilityexpand
: the opposite ofcompress
crypt
: symmetric xor-based encryptiontr
: perform character transliteration
Chapter 3: Files
diff
: compare two files and print the differencesinclude
: print a file, expanding instructions to include other filescat
: print n filesar
: archive a group of files into a single compressed archive file
Chapter 4: Sorting
sort
: print the lines of a file in sorted orderuniq
: strip adjacent duplicate lines in a streamcommon
: print lines found in only one or both of a pair of files
Chapter 5: Text Patterns
…
Chapter 6: Editing
…
Chapter 7: Formatting
…
Chapter 8: Macro Processing
…
Chapter 9: A Ratfor-Fortran Translator
…