<p>What's the best framework for writing modules -- <a href="http://search.cpan.org/perldoc/ExtUtils::MakeMaker" rel="noreferrer">ExtUtils::MakeMaker</a> (h2xs) or <a href="http://search.cpan.org/perldoc/Module::Build" rel="noreferrer">Module::Build</a>?</p>

[{'answer_id': 73911, 'author': 'Frank Wiles', 'author_id': 12568, 'author_profile': 'https://Stackoverflow.com/users/12568', 'pm_score': 2, 'selected': False, 'text': '<p>There are pros and cons to both.  These days I use and recommend Module::Build and Module::Starter.</p>\n'}, {'answer_id': 73931, 'author': 'amoore', 'author_id': 7573, 'author_profile': 'https://Stackoverflow.com/users/7573', 'pm_score': 0, 'selected': False, 'text': '<p>EU::MM still seems to be the most widely supported and popular one, but Module::Build is catching up. Also, check out <a href="http://search.cpan.org/dist/Module-Starter/" rel="nofollow noreferrer">Module::Starter</a> for a module that will help you get started.</p>\n'}, {'answer_id': 74090, 'author': 'cjm', 'author_id': 8355, 'author_profile': 'https://Stackoverflow.com/users/8355', 'pm_score': 2, 'selected': False, 'text': '<p>I also recommend Module::Build and Module::Starter (with the <a href="http://search.cpan.org/perldoc?Module::Starter::Plugin::TT2" rel="nofollow noreferrer">TT2 plugin</a>).</p>\n'}, {'answer_id': 74133, 'author': 'Leon Timmermans', 'author_id': 4727, 'author_profile': 'https://Stackoverflow.com/users/4727', 'pm_score': 2, 'selected': False, 'text': "<p>Module::Build is better by any means, but it is less widely supported than ExtUtils::MakeMaker (more specifically, older versions of Perl don't support it out of the box). It depends on your needs.</p>\n"}, {'answer_id': 74216, 'author': 'Dave Rolsky', 'author_id': 9832, 'author_profile': 'https://Stackoverflow.com/users/9832', 'pm_score': 5, 'selected': False, 'text': '<p>There are two questions here.</p>\n\n<p>First, never use h2xs. It\'s old outdated nastiness, though I suppose if you\'re actually trying to turn a header file into XS code, it might be useful (never done that myself).</p>\n\n<p><strong>2011 update: I strongly recommend taking a look at <a href="http://dzil.org" rel="noreferrer">Dist::Zilla</a>, especially if you think you\'ll be maintaining more than one module.</strong></p>\n\n<p>For creating a new module, use Module::Starter. It works great, and has some nice plugins for customizing the output.</p>\n\n<p>Second, you\'re asking what build system you should use. The three contenders are ExtUtils::MakeMaker (EUMM), Module::Build (MB), and Module::Install (MI).</p>\n\n<p>EUMM is a horrid nasty piece of work, but it works, and if you\'re not customizing your build process at all, works just fine.</p>\n\n<p>MB is the new kid, and it has its detractors. It\'s big plus is that if you want to heavily customize your install and build process, it\'s quite possible to do this sanely (and in a cross-platform manner) using MB. It\'s really not possible using EUMM.</p>\n\n<p>Finally, MI is basically a declarative wrapper on top of EUMM. It also packages itself along with your distro, in an attempt to work around problems with users trying to install modules with old toolchain modules. The downside of the "package self" trick is that if there\'s a bug in MI itself, you have to re-release all your modules just to fix it.</p>\n\n<p>As far as customization goes, there are some plugins for MI, but if you want to go beyond them you\'ll be back at the problem of dealing with Makefiles and build tools across a dozen+ platforms, so it really isn\'t going to help you too much in that realm.</p>\n'}, {'answer_id': 74628, 'author': 'brian d foy', 'author_id': 2766176, 'author_profile': 'https://Stackoverflow.com/users/2766176', 'pm_score': 4, 'selected': False, 'text': '<p>I just uploaded <a href="http://search.cpan.org/dist/Distribution-Cooker" rel="nofollow noreferrer">Distribution::Cooker</a> to CPAN. It\'s what I use to make new distributions. The nice thing about it is that your distributions can be whatever you like: you\'re just cooking some templates. I don\'t care if anyone uses it. For me it\'s simple, low tech, and doesn\'t cause extra problems.</p>\n\n<p>You might start with something like <a href="http://search.cpan.org/dist/Module-Starter" rel="nofollow noreferrer">Module::Starter</a> to make your starter templates then add your own boilerplate and favorite way of doing things. You choose not only whatever you want in each file, but which files show up in the distro. As you figure out how you like to do things, you simply update your own templates.</p>\n\n<p>As for Makemaker and Module::Build, <s>the future is Module::Build</s>. It\'s only us old guys using Makemaker anymore. :) There are ways to use both (or pretend to use both) at the same time. <s>Look at the Module::Build, Module::Build::Compat, and Module::Install docs</s>. Module::Build was kicked out of Perl\'s Standard Library and it\'s future is uncertain. It\'s back to Makemaker as a build system. </p>\n\n<p>Although this is a bit of a cop-out answer, try using each just to get a little experience with each.</p>\n'}, {'answer_id': 74840, 'author': 'Penfold', 'author_id': 11952, 'author_profile': 'https://Stackoverflow.com/users/11952', 'pm_score': 2, 'selected': False, 'text': '<p>Personally, I recommend Module::Install, as do a lot of folks I know - the likes of the Catalyst and Moose folks also use it. </p>\n'}, {'answer_id': 75295, 'author': 'Michael Carman', 'author_id': 8233, 'author_profile': 'https://Stackoverflow.com/users/8233', 'pm_score': 2, 'selected': False, 'text': '<p>Here\'s a little clarification of the direction I hoped the responses would take:</p>\n\n<ul>\n<li>pros/cons of various of frameworks</li>\n<li>compatibility/install base of frameworks</li>\n<li>suitability for internal (local) vs. external (CPAN) releases</li>\n<li><em>not</em> bare "use X" answers</li>\n</ul>\n\n<p><a href="https://stackoverflow.com/questions/73889/which-framework-should-i-use-to-write-modules#74216">Dave\'s answer</a> has some good pro/con info. <a href="https://stackoverflow.com/questions/73889/which-framework-should-i-use-to-write-modules#74133">Leon\'s answer</a> alludes to compatibility but isn\'t explicit. As <a href="https://stackoverflow.com/questions/73889/which-framework-should-i-use-to-write-modules#74628">brian d foy mentioned</a>, only the old hats use EUMM, but I\'m not convinced that MB is a good framework for things destined for CPAN due to it not being part of the core until 5.9.</p>\n'}, {'answer_id': 80207, 'author': 'Eric Wilhelm', 'author_id': 11580, 'author_profile': 'https://Stackoverflow.com/users/11580', 'pm_score': 3, 'selected': False, 'text': "<p>The only trouble with compatibility regarding Module::Build is when a user tries to install modules without updating their CPAN client (CPAN.pm or CPANPLUS.pm)  If they are installing your module from the CPAN, they can just as easily upgrade their client from the same mirror.</p>\n\n<p>If you don't want to do <em>anything</em> complicated in your build process, sure: use EUMM.  But if you have a build problem on a different target platform, you might end up in the Makefile, which is different on every variation of make.</p>\n\n<p>Module::Build gives you lots of features (anything you can think of if you extend it) and is all perl so you never end up debugging a makefile.  Module::Install gives you features, but you have to bundle it and everything ends up running through 'make' in the end.</p>\n"}, {'answer_id': 214717, 'author': 'Schwern', 'author_id': 14660, 'author_profile': 'https://Stackoverflow.com/users/14660', 'pm_score': 7, 'selected': True, 'text': '<p><strong>NOTE</strong> This advice is out of date.  <a href="http://www.dagolden.com/index.php/2140/paying-respect-to-modulebuild/" rel="nofollow noreferrer">Module::Build has been removed from the Perl core</a> but lives on as a CPAN module.  The pros and cons still stand, and my opinions about MakeMaker still stand.</p>\n\n<hr>\n\n<p>As the former maintainer of ExtUtils::MakeMaker, I like to recommend Module::Build because MakeMaker is a horror show.  Module::Build is so much better put together.  But those aren\'t your concerns and I\'ll present my "least hassle for you" answer.</p>\n\n<h2>Executive Summary:</h2>\n\n<p>Because Module::Build support is not 100% in place through all of Perl, start with MakeMaker.  If you want to do any customization at all, switch to Module::Build.  Since their basic layout, options and interface are almost identical this will be painless.  As seductive as it looks, avoid Module::Install.</p>\n\n<p>Fortunately, Module::Build can emulate MakeMaker which helps some, but doesn\'t help if you\'re going to do any customization.  See <a href="http://search.cpan.org/perldoc?Module::Build::Compat" rel="nofollow noreferrer">Module::Build::Compat</a>.</p>\n\n<p>For CPAN releases using Module::Build is fine.  There\'s enough Module::Build stuff on CPAN now that everyone\'s dealt with getting it bootstrapped already.</p>\n\n<p>Finally, the new <a href="http://module-build.sourceforge.net/META-spec.html#configure_requires" rel="nofollow noreferrer"><code>configure_requires</code></a> option lets CPAN shells know to install Module::Build before they can start building the module.  Unfortunately only the latest CPAN shells know about configure_requires.</p>\n\n<p>Oh, whatever you do don\'t use h2xs (unless you\'re writing XS code... and even then think about it).</p>\n\n<h2>MakeMaker Pros:</h2>\n\n<ul>\n<li>Comes with Perl and used by the Perl core (therefore it is actively\nmaintained and will remain so forever)</li>\n<li>Everything knows what to do with a Makefile.PL.</li>\n<li>Most module authoring documentation will cover MakeMaker.</li>\n<li>Uses make (those who know make can debug and patch the build\nprocess)</li>\n</ul>\n\n<h2>MakeMaker Cons:</h2>\n\n<ul>\n<li>Requires make (think Windows)</li>\n<li>Difficult to customize</li>\n<li>Even harder to customize and make cross platform</li>\n<li>Difficult to debug when something goes wrong (unless you understand make)</li>\n</ul>\n\n<h2>Module::Build Pros:</h2>\n\n<ul>\n<li>Easier to customize/subclass</li>\n<li>Pure Perl</li>\n<li>Easier to debug (it\'s Perl)</li>\n<li>Can emulate MakeMaker in several ways</li>\n<li>The CPAN shell will install Module::Build for you</li>\n</ul>\n\n<h2>Module::Build Cons:</h2>\n\n<ul>\n<li>The Module::Build maintainers (and indeed all of the Perl Toolchain Gang) hate it </li>\n<li>Older versions of CPAN clients (including CPANPLUS) don\'t know anything about Module::Build.</li>\n</ul>\n\n<h2>Module::Install Pros:</h2>\n\n<ul>\n<li>Slick interface</li>\n<li>Bundles itself, you have a known version</li>\n<li>Everything knows how to deal with a Makefile.PL</li>\n</ul>\n\n<h2>Module::Install Cons:</h2>\n\n<ul>\n<li>Requires make</li>\n<li>Always uses bundled version, vulnerable to external breakage</li>\n<li>Difficult to customize outside its interface</li>\n<li>Mucks with the guts of MakeMaker so a new MakeMaker release will eventually break it.</li>\n<li>Does not know how to generate a META file using the v2 meta-spec\n(increasingly a problem with newer tools)</li>\n</ul>\n'}, {'answer_id': 214720, 'author': 'Schwern', 'author_id': 14660, 'author_profile': 'https://Stackoverflow.com/users/14660', 'pm_score': 4, 'selected': False, 'text': '<p>You also might want to look at <a href="http://search.cpan.org/dist/Dist-Zilla/" rel="nofollow noreferrer">Dist-Zilla</a> which is a new author-only tool to create distributions.  Because it just helps build the distribution, it doesn\'t ship with your code or do any installation, it can do a lot of powerful stuff.</p>\n'}]
['https://Stackoverflow.com/questions/73889', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8233/']