=head1 NAME
perlhack - How to hack at the Perl internals
=head1 DESCRIPTION
This document attempts to explain how Perl development takes place,
and ends with some suggestions for people wanting to become bona fide
porters.
The perl5-porters mailing list is where the Perl standard distribution
is maintained and developed. The list can get anywhere from 10 to 150
messages a day, depending on the heatedness of the debate. Most days
there are two or three patches, extensions, features, or bugs being
discussed at a time.
A searchable archive of the list is at either:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/
or
http://archive.develooper.com/perl5-porters@perl.org/
List subscribers (the porters themselves) come in several flavours.
Some are quiet curious lurkers, who rarely pitch in and instead watch
the ongoing development to ensure they're forewarned of new changes or
features in Perl. Some are representatives of vendors, who are there
to make sure that Perl continues to compile and work on their
platforms. Some patch any reported bug that they know how to fix,
some are actively patching their pet area (threads, Win32, the regexp
engine), while others seem to do nothing but complain. In other
words, it's your usual mix of technical people.
Over this group of porters presides Larry Wall. He has the final word
in what does and does not change in the Perl language. Various
releases of Perl are shepherded by a "pumpking", a porter
responsible for gathering patches, deciding on a patch-by-patch,
feature-by-feature basis what will and will not go into the release.
For instance, Gurusamy Sarathy was the pumpking for the 5.6 release of
Perl, and Jarkko Hietaniemi was the pumpking for the 5.8 release, and
Rafael Garcia-Suarez holds the pumpking crown for the 5.10 release.
In addition, various people are pumpkings for different things. For
instance, Andy Dougherty and Jarkko Hietaniemi did a grand job as the
I pumpkin up till the 5.8 release. For the 5.10 release
H.Merijn Brand took over.
Larry sees Perl development along the lines of the US government:
there's the Legislature (the porters), the Executive branch (the
pumpkings), and the Supreme Court (Larry). The legislature can
discuss and submit patches to the executive branch all they like, but
the executive branch is free to veto them. Rarely, the Supreme Court
will side with the executive branch over the legislature, or the
legislature over the executive branch. Mostly, however, the
legislature and the executive branch are supposed to get along and
work out their differences without impeachment or court cases.
You might sometimes see reference to Rule 1 and Rule 2. Larry's power
as Supreme Court is expressed in The Rules:
=over 4
=item 1
Larry is always by definition right about how Perl should behave.
This means he has final veto power on the core functionality.
=item 2
Larry is allowed to change his mind about any matter at a later date,
regardless of whether he previously invoked Rule 1.
=back
Got that? Larry is always right, even when he was wrong. It's rare
to see either Rule exercised, but they are often alluded to.
New features and extensions to the language are contentious, because
the criteria used by the pumpkings, Larry, and other porters to decide
which features should be implemented and incorporated are not codified
in a few small design goals as with some other languages. Instead,
the heuristics are flexible and often difficult to fathom. Here is
one person's list, roughly in decreasing order of importance, of
heuristics that new features have to be weighed against:
=over 4
=item Does concept match the general goals of Perl?
These haven't been written anywhere in stone, but one approximation
is:
1. Keep it fast, simple, and useful.
2. Keep features/concepts as orthogonal as possible.
3. No arbitrary limits (platforms, data sizes, cultures).
4. Keep it open and exciting to use/patch/advocate Perl everywhere.
5. Either assimilate new technologies, or build bridges to them.
=item Where is the implementation?
All the talk in the world is useless without an implementation. In
almost every case, the person or people who argue for a new feature
will be expected to be the ones who implement it. Porters capable
of coding new features have their own agendas, and are not available
to implement your (possibly good) idea.
=item Backwards compatibility
It's a cardinal sin to break existing Perl programs. New warnings are
contentious--some say that a program that emits warnings is not
broken, while others say it is. Adding keywords has the potential to
break programs, changing the meaning of existing token sequences or
functions might break programs.
=item Could it be a module instead?
Perl 5 has extension mechanisms, modules and XS, specifically to avoid
the need to keep changing the Perl interpreter. You can write modules
that export functions, you can give those functions prototypes so they
can be called like built-in functions, you can even write XS code to
mess with the runtime data structures of the Perl interpreter if you
want to implement really complicated things. If it can be done in a
module instead of in the core, it's highly unlikely to be added.
=item Is the feature generic enough?
Is this something that only the submitter wants added to the language,
or would it be broadly useful? Sometimes, instead of adding a feature
with a tight focus, the porters might decide to wait until someone
implements the more generalized feature. For instance, instead of
implementing a "delayed evaluation" feature, the porters are waiting
for a macro system that would permit delayed evaluation and much more.
=item Does it potentially introduce new bugs?
Radical rewrites of large chunks of the Perl interpreter have the
potential to introduce new bugs. The smaller and more localized the
change, the better.
=item Does it preclude other desirable features?
A patch is likely to be rejected if it closes off future avenues of
development. For instance, a patch that placed a true and final
interpretation on prototypes is likely to be rejected because there
are still options for the future of prototypes that haven't been
addressed.
=item Is the implementation robust?
Good patches (tight code, complete, correct) stand more chance of
going in. Sloppy or incorrect patches might be placed on the back
burner until the pumpking has time to fix, or might be discarded
altogether without further notice.
=item Is the implementation generic enough to be portable?
The worst patches make use of a system-specific features. It's highly
unlikely that non-portable additions to the Perl language will be
accepted.
=item Is the implementation tested?
Patches which change behaviour (fixing bugs or introducing new features)
must include regression tests to verify that everything works as expected.
Without tests provided by the original author, how can anyone else changing
perl in the future be sure that they haven't unwittingly broken the behaviour
the patch implements? And without tests, how can the patch's author be
confident that his/her hard work put into the patch won't be accidentally
thrown away by someone in the future?
=item Is there enough documentation?
Patches without documentation are probably ill-thought out or
incomplete. Nothing can be added without documentation, so submitting
a patch for the appropriate manpages as well as the source code is
always a good idea.
=item Is there another way to do it?
Larry said "Although the Perl Slogan is I, I hesitate to make 10 ways to do something". This is a
tricky heuristic to navigate, though--one man's essential addition is
another man's pointless cruft.
=item Does it create too much work?
Work for the pumpking, work for Perl programmers, work for module
authors, ... Perl is supposed to be easy.
=item Patches speak louder than words
Working code is always preferred to pie-in-the-sky ideas. A patch to
add a feature stands a much higher chance of making it to the language
than does a random feature request, no matter how fervently argued the
request might be. This ties into "Will it be useful?", as the fact
that someone took the time to make the patch demonstrates a strong
desire for the feature.
=back
If you're on the list, you might hear the word "core" bandied
around. It refers to the standard distribution. "Hacking on the
core" means you're changing the C source code to the Perl
interpreter. "A core module" is one that ships with Perl.
=head2 Keeping in sync
The source code to the Perl interpreter, in its different versions, is
kept in a repository managed by the git revision control system. The
pumpkings and a few others have write access to the repository to check in
changes.
How to clone and use the git perl repository is described in L.
You can also choose to use rsync to get a copy of the current source tree
for the bleadperl branch and all maintenance branches :
$ rsync -avz rsync://perl5.git.perl.org/APC/perl-current .
$ rsync -avz rsync://perl5.git.perl.org/APC/perl-5.10.x .
$ rsync -avz rsync://perl5.git.perl.org/APC/perl-5.8.x .
$ rsync -avz rsync://perl5.git.perl.org/APC/perl-5.6.x .
$ rsync -avz rsync://perl5.git.perl.org/APC/perl-5.005xx .
(Add the C<--delete> option to remove leftover files)
You may also want to subscribe to the perl5-changes mailing list to
receive a copy of each patch that gets submitted to the maintenance
and development "branches" of the perl repository. See
http://lists.perl.org/ for subscription information.
If you are a member of the perl5-porters mailing list, it is a good
thing to keep in touch with the most recent changes. If not only to
verify if what you would have posted as a bug report isn't already
solved in the most recent available perl development branch, also
known as perl-current, bleading edge perl, bleedperl or bleadperl.
Needless to say, the source code in perl-current is usually in a perpetual
state of evolution. You should expect it to be very buggy. Do B use
it for any purpose other than testing and development.
=head2 Perlbug administration
There is a single remote administrative interface for modifying bug status,
category, open issues etc. using the B