Kernighan and Pike were right: Do one thing, and do it well
<p>In October 1984 two ideologues published a radical manifesto… sort of. <em>Program Design in the UNIX Environment</em>, by comp-sci legends Brian Kernighan and Rob Pike, articulated a pattern for software architecture that both men had already spent years fighting to preserve.</p>
<p> </p>
<p>Rob Pike and Brian Kernighan</p>
<p>Admittedly, as far as manifestos go, it’s about as spicy as you’d expect from two Canadian engineers. Its most pointed jab is this memorable line from the abstract:</p>
<blockquote>
<p>Old programs have become encrusted with dubious features.</p>
</blockquote>
<p>The crux of the paper is often summed up by the acronym DOTADIW, “Do One Thing And Do It Well”. Unix and its descendants are full of programs that embody this mantra: <code>ls</code> just lists files, <code>cat</code> just outputs file contents, <code>grep</code> just filters data, <code>wc</code> just counts words, etc. Each program has a few options that change its behavior, but not too many. For example: <code>wc</code> can be configured to count lines or words, but it can’t count the number of paragraphs or the occurrences of a specific phrase.</p>
<p>The power of Unix, as championed by Kernighan and Pike, was the ability to chain these simple programs together to create complex behaviors. Why add regex matching to <code>wc</code> when <code>grep</code> already does that? To count the number of functions in a rust file you could run:</p>
<p><a href="https://medium.com/source-and-buggy/do-one-thing-and-do-it-well-886b11a5d21">Click Here</a></p>