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