Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

Building Perl projects with MakeMaker

By Sean Dague
2005-05-01


Programming Products vs. Programs

In Frederick Brooks' The Mythical Man-Month he asks the question: Why are there all these stories about a couple of people in a garage creating a new program in significantly less time than it takes a larger entity or corporation to produce the same program, with the same amount of function? To describe this conundrum he distinguishes between two types of software: the program, and the programming product.

A program is a piece of software that is functional within one environment. This could be the set of scripts lying around in your local bin directory. A programming product requires taking a program and adding a number of additional items. This includes thorough and usable documentation, an easy installation procedure, and a set of test cases to ensure the program does what it is supposed to do. Brooks theorizes that creating a programming product requires at least thee times more effort than creating a program. Although this may seem like a great deal of work, this effort is rarely in vain. The program now becomes useful to significantly more people, and even more useful to yourself. How many times have you found that you need to read the source code of your scripts every time you try to use them? Wouldn't it be easier to consult a man page for each of your scripts?

Perl is often thought of as a Swiss Army Knife or a large roll of duct tape. No one who works with UNIX for any length of time can avoid eventually writing some Perl code. Unfortunately, many people don't realize that Perl also contains a robust infrastructure for building programming products in the Brooksian sense. The heart of this infrastructure is a Perl module called ExtUtils::MakeMaker. At its core, MakeMaker provides a Perl interface to generating Makefiles. However, it does much more than this. The Makefiles created by MakeMaker will not only build and install the project, but will also generate documentation in man page or HTML formats, and run an automated set of test cases against the entire application.

Because this function is so tightly bound to the core Perl infrastructure, the overhead in learning and using it is small. The advantages, however, are vast. Once proper test cases have been created for your application, your project will never regress without your knowledge. Any change that breaks old function will abruptly throw up red flags. This gives you a much greater assurance that you are not reintroducing old bugs with each new patch you add to your code.

In contrast to Brooks' factor of three work increase, I have found that by using these methodologies I actually save considerable time. Once a bug is fixed it is probably fixed. Documentation that is embedded alongside the code that it describes is easier to keep up to date than documentation that exists externally. Plus, you get an installation script for free.

This article will not teach you how to write Perl, but it will show you how to turn a Perl program into a far more robust programming project. That project will be generic enough to be widely distributed across many disparate platforms.

Tutorial Pages:
» The Module that Makes Makefiles and Much More
» Programming Products vs. Programs
» Anatomy of a MakeMaker Project
» Your First MakeMaker Project (make)
» Building Test Cases (make test)
» Installation (make install)
» Distributing Your Code (make dist)
» Conclusion
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» Random subroutines in Perl
» Log Script Use
» Creating Perl Modules for Web Sites
» Bit Vector, Using Perl Vec
» Build a Perl/CGI Voting System
» Perl Range Operator

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources