This is a live mirror of the Perl 5 development currently hosted at
add perlhack.pod from Nathan Torkington <>
[perl5.git] / pod / perlhack.pod
1=head1 NAME
3perlhack - How to hack at the Perl internals
7This document attempts to explain how Perl development takes place,
8and ends with some suggestions for people wanting to become bona fide
11The perl5-porters mailing list is where the Perl standard distribution
12is maintained and developed. The list can get anywhere from 10 to 150
13messages a day, depending on the heatedness of the debate. Most days
14there are two or three patches, extensions, features, or bugs being
15discussed at a time.
17A searchable archive of the list is at:
21The list is also archived under the usenet group name
22C<perl.porters-gw> at:
26List subscribers (the porters themselves) come in several flavours.
27Some are quiet curious lurkers, who rarely pitch in and instead watch
28the ongoing development to ensure they're forewarned of new changes or
29features in Perl. Some are representatives of vendors, who are there
30to make sure that Perl continues to compile and work on their
31platforms. Some patch any reported bug that they know how to fix,
32some are actively patching their pet area (threads, Win32, the regexp
33engine), while others seem to do nothing but complain. In other
34words, it's your usual mix of technical people.
36Over this group of porters presides Larry Wall. He has the final word
37in what does and does not change in the Perl language. Various releases
38of Perl are shepherded by a ``pumpking'', a porter responsible for
39gathering patches, deciding on a patch-by-patch feature-by-feature
40basis what will and will not go into the release. For instance,
41Gurusamy Sarathy is the pumpking for the 5.6 release of Perl.
43In addition, various people are pumpkings for different things. For
44instance, Andy Dougherty and Jarkko Hietaniemi share the I<Configure>
45pumpkin, and Tom Christiansen is the documentation pumpking.
47Larry sees Perl development along the lines of the US government:
48there's the Legislature (the porters), the Executive branch (the
49pumpkings), and the Supreme Court (Larry). The legislature can
50discuss and submit patches to the executive branch all they like, but
51the executive branch is free to veto them. Rarely, the Supreme Court
52will side with the executive branch over the legislature, or the
53legislature over the executive branch. Mostly, however, the
54legislature and the executive branch are supposed to get along and
55work out their differences without impeachment or court cases.
57You might sometimes see reference to Rule 1 and Rule 2. Larry's power
58as Supreme Court is expressed in The Rules:
60=over 4
62=item 1
64Larry is always by definition right about how Perl should behave.
65This means he has final veto power on the core functionality.
67=item 2
69Larry is allowed to change his mind about any matter at a later date,
70regardless of whether he previously invoked Rule 1.
74Got that? Larry is always right, even when he was wrong. It's rare
75to see either Rule exercised, but they are often alluded to.
77New features and extensions to the language are contentious, because
78the criteria used by the pumpkings, Larry, and other porters to decide
79which features should be implemented and incorporated are not codified
80in a few small design goals as with some other languages. Instead,
81the heuristics are flexible and often difficult to fathom. Here is
82one person's list, roughly in decreasing order of importance, of
83heuristics that new features have to be weighed against:
85=over 4
87=item Does concept match the general goals of Perl?
89These haven't been written anywhere in stone, but one approximation
92 1. Keep it fast, simple, and useful.
93 2. Keep features/concepts as orthogonal as possible.
94 3. No arbitrary limits (platforms, data sizes, cultures).
95 4. Keep it open and exciting to use/patch/advocate Perl everywhere.
96 5. Either assimilate new technologies, or build bridges to them.
98=item Where is the implementation?
100All the talk in the world is useless without an implementation. In
101almost every case, the person or people who argue for a new feature
102will be expected to be the ones who implement it. Porters capable
103of coding new features have their own agendas, and are not available
104to implement your (possibly good) idea.
106=item Backwards compatibility
108It's a cardinal sin to break existing Perl programs. New warnings are
109contentious--some say that a program that emits warnings is not
110broken, while others say it is. Adding keywords has the potential to
111break programs, changing the meaning of existing token sequences or
112functions might break programs.
114=item Could it be a module instead?
116Perl 5 has extension mechanisms, modules and XS, specifically to avoid
117the need to keep changing the Perl interpreter. You can write modules
118that export functions, you can give those functions prototypes so they
119can be called like built-in functions, you can even write XS code to
120mess with the runtime data structures of the Perl interpreter if you
121want to implement really complicated things. If it can be done in a
122module instead of in the core, it's highly unlikely to be added.
124=item Is the feature generic enough?
126Is this something that only the submitter wants added to the language,
127or would it be broadly useful? Sometimes, instead of adding a feature
128with a tight focus, the porters might decide to wait until someone
129implements the more generalized feature. For instance, instead of
130implementing a ``delayed evaluation'' feature, the porters are waiting
131for a macro system that would permit delayed evaluation and much more.
133=item Does it potentially introduce new bugs?
135Radical rewrites of large chunks of the Perl interpreter have the
136potential to introduce new bugs. The smaller and more localized the
137change, the better.
139=item Does it preclude other desirable features?
141A patch is likely to be rejected if it closes off future avenues of
142development. For instance, a patch that placed a true and final
143interpretation on prototypes is likely to be rejected because there
144are still options for the future of prototypes that haven't been
147=item Is the implementation robust?
149Good patches (tight code, complete, correct) stand more chance of
150going in. Sloppy or incorrect patches might be placed on the back
151burner until the pumpking has time to fix, or might be discarded
152altogether without further notice.
154=item Is the implementation generic enough to be portable?
156The worst patches make use of a system-specific features. It's highly
157unlikely that nonportable additions to the Perl language will be
160=item Is there enough documentation?
162Patches without documentation are probably ill-thought out or
163incomplete. Nothing can be added without documentation, so submitting
164a patch for the appropriate manpages as well as the source code is
165always a good idea. If appropriate, patches should add to the test
166suite as well.
168=item Is there another way to do it?
170Larry said ``Although the Perl Slogan is I<There's More Than One Way
171to Do It>, I hesitate to make 10 ways to do something''. This is a
172tricky heuristic to navigate, though--one man's essential addition is
173another man's pointless cruft.
175=item Does it create too much work?
177Work for the pumpking, work for Perl programmers, work for module
178authors, ... Perl is supposed to be easy.
182If you're on the list, you might hear the word ``core'' bandied
183around. It refers to the standard distribution. ``Hacking on the
184core'' means you're changing the C source code to the Perl
185interpreter. ``A core module'' is one that ships with Perl.
187The source code to the Perl interpreter, in its different versions, is
188kept in a repository managed by a revision control system (which is
189currently the Perforce program, see The
190pumpkings and a few others have access to the repository to check in
191changes. Periodically the pumpking for the development version of Perl
192will release a new version, so the rest of the porters can see what's
193changed. Plans are underway for a repository viewer, and for
194anonymous CVS access to the latest versions.
196Always submit patches to I<>. This lets other
197porters review your patch, which catches a surprising number of errors
198in patches. Either use the diff program (available in source code form
199from I<>), or use Johan Vromans' I<makepatch>
200(available from I<CPAN/authors/id/JV/>). Unified diffs are preferred,
201but context diffs are ok too. Do not send RCS-style diffs or diffs
202without context lines. More information is given in the
203I<Porting/patching.pod> file in the Perl source distribution. Please
204patch against the latest B<development> version (e.g., if you're fixing
205a bug in the 5.005 track, patch against the latest 5.005_5x version).
206Only patches that survive the heat of the development branch get
207applied to maintenance versions.
209Your patch should update the documentation and test suite.
211To report a bug in Perl, use the program I<perlbug> which comes with
212Perl (if you can't get Perl to work, send mail to the address
213I<> or I<>). Reporting bugs through
214I<perlbug> feeds into the automated bug-tracking system, access to
215which is provided through the web at I<>. It
216often pays to check the archives of the perl5-porters mailing list to
217see whether the bug you're reporting has been reported before, and if
218so whether it was considered a bug. See above for the location of
219the searchable archives.
221The CPAN testers (I<>) are a group of
222volunteers who test CPAN modules on a variety of platforms. Perl Labs
223(I<>) automatically tests modules and Perl source
224releases on platforms and gives feedback to the CPAN testers mailing
225list. Both efforts welcome volunteers.
227To become an active and patching Perl porter, you'll need to learn how
228Perl works on the inside. Chip Salzenberg, a pumpking, has written
229articles on Perl internals for The Perl Journal
230(I<>) which explain how various parts of the Perl
231interpreter work. The C<perlguts> manpage explains the internal data
232structures. And, of course, the C source code (sometimes sparsely
233commented, sometimes commented well) is a great place to start (begin
234with C<perl.c> and see where it goes from there). A lot of the
235style of the Perl source is explained in the I<Porting/pumpkin.pod>
236file in the source distribution.
238It is essential that you be comfortable using a good debugger
239(e.g. gdb, dbx) before you can patch perl. Stepping through perl
240as it executes a script is perhaps the best (if sometimes tedious)
241way to gain a precise understanding of the overall architecture of
242the language.
244If you build a version of the Perl interpreter with C<-DDEBUGGING>,
245Perl's B<-D> commandline flag will cause copious debugging information
246to be emitted (see the C<perlrun> manpage). If you build a version of
247Perl with compiler debugging information (e.g. with the C compiler's
248C<-g> option instead of C<-O>) then you can step through the execution
249of the interpreter with your favourite C symbolic debugger, setting
250breakpoints on particular functions.
252It's a good idea to read and lurk for a while before chipping in.
253That way you'll get to see the dynamic of the conversations, learn the
254personalities of the players, and hopefully be better prepared to make
255a useful contribution when do you speak up.
257If after all this you still think you want to join the perl5-porters
258mailing list, send mail to I<> with the
259body of your message reading I<subscribe>. To unsubscribe, either
260send mail to the same address with the body reading I<unsubscribe>, or
261send mail to I<>.
263=head1 AUTHOR
265This document was written by Nathan Torkington, and is maintained by
266the perl5-porters mailing list.