Chapter 71. Microperl

Simon Cozens

Perl 5.7.0 shipped with an obscure and barely announced new feature— microperl. microperl is something I’ve worked on for quite a few months now and, while I expect it to be useful to only a tiny fraction of Perl users, I’d like to explain why it’s included and what’s so cool about it.

First, though, what is it? Well, when you compile a version of Perl, the first thing that gets built is a program called miniperl. miniperl is more or less just like ordinary perl, except that it doesn’t have the Dynaloader XS module linked in. An XS module is a C extension module, allowing Perl to run C code, and it’s usually written in a special glue language, XS, rather than in C.

What makes Dynaloader special is that it’s the module that allows Perl to load other XS modules dynamically—without that, you can’t use modules like IO::File, your DBM database library (DB_File, SDBM_File or equivalent), or any of the modules on CPAN with XS components.

miniperl, however, has just enough brains to run a program which translates the XS language in which Dynaloader is written into a C program; once we’ve done that, we can compile Dynaloader and link it into perl. In effect, we’re building perl in stages: first without XS support, and then using that first effort to help build the next stage with XS support.

Bootstrapping

This process—starting small and using the result to build up to the next stage—is called "bootstrapping,” since you’ve started from the ground and are pulling ...

Get Computer Science & Perl Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.