The Design of Four
[ This is cross-posted from the Ocean of Awareness blog. ]
In the Perl world at this moment, a lot is being said about the consequences of bad design. And it is useful to study design failures. But the exercise will come to nothing without a road to good design. This post will point out four Perl-centric projects that are worth study as models of good design.
The projects are ack, cpanm, local::lib and perlbrew. Each of these is perfect in the older sense of "having all that is requisite to its nature and kind" (Webster's 1828). If you are into Perl, they are all widely useful, and looking at them as a potential or an actual user is the best way to gain an appreciation of the art behind them.
ack is a file search tool -- UNIX's grep with improvements. The improvements are influenced by a Perl sensibility, and ack is written in Perl. But while the other tools I list are of little interest unless you are into Perl, ack can help you out even if you otherwise shun Perl tools.
cpanm is for installing CPAN packages from CPAN. If you don't know what that means, you aren't interested. If you do, you want to be using it. It does everything you need and importantly, nothing more. The interface is without clutter. Like I said, perfect.
local::lib is for installing Perl modules in the directory of your choice. Even if you have root permission on a system, it is good practice to leave the delivered Perl on your system untouched except by vendor-sponsored patches and updates. local::lib allows you to do this easily and conveniently. It has every feature and convenience I want. And reading its documentation is again an encounter with perfection. Every feature described is
- something that you need today,
- something that you are worried you might need tomorrow, or
- something that you are not worried you might need, but on reading the documentation will discover that you should be.
Repeated perfection can be boring, a fact which I suspect plays no small role in making perfection an unusual thing in this world. So of perlbrew, I will simply say that it does for Perl versions and executables what local::lib does for Perl modules. perlbrew is the way to manage alternative Perl executables. And using perlbrew is a good way to study yet another perfect interface.
How much relevance does the work of Andy Lester (ack), Tatsuhiko Miyagawa (cpanm), Matt S Trout (local::lib) and Kang-min Liu (perlbrew) have to other projects, including projects that now seem larger and more complex? Certainly these four applications all seem simple, well-defined, and self-contained. But I would argue that, if these problems seem simple and well-defined today, much of that impression is the result of the design skills of Andy, Tatsuhiko, Matt and Kang-min. And if, to an extent, they did benefit from having the good fortune to pick the the right problem at the right time, it is useful to recall Ben Hogan's comment on his profession:
Golf is a game of luck. The more I practice, the luckier I get.
I don't know if that's meant to be meta-irony, but the part of the article that begins with "Repeated perfection can be boring," seems to have been double-pasted. :-)
The weird sense of irony may be in your browser. I've looked at this post via a couple of browsers and there seems to be no problem.
@yanick: Checking these comments, I see the duplication. I think blogs.perl.org may be having difficulties. If you click through to the original at the Ocean of Awareness blog, you can see the post as intended. Thanks!
I'm sorry, I accidentally caused the repetition. I was trying to cut down the amount of text that appeared on the front page of the site, but somehow got it wrong.
I've fixed it now. Sorry about that.