Ocean of Awareness

Jeffrey Kegler's blog about Marpa, his new parsing algorithm, and other topics of interest

Jeffrey's personal website

Google+

Marpa resources

The Marpa website

The Ocean of Awareness blog: home page, chronological index, and annotated index.

Fri, 31 May 2013


The Design of Four

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

Aside from that, there is nothing else. Clutter-free. Perfect.

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.

posted at: 10:20 | direct link to this entry

§         §         §