Why Perl needs a VM

Matt S Trout dbix-class at trout.me.uk
Tue Sep 4 16:39:40 BST 2007

On Tue, Sep 04, 2007 at 06:28:42AM -0700, ben at bpfh.net wrote:
> I've got to thinking recently about the issue of whether 
> Perl (and dynamic languages in general) need VMs.
> I'd been increasingly coming to the conclusion that they do, and
> then someone in my team performed a piece of performance analysis
> which really made me think.
> Our application is a large (currently all-Perl) mail sending pipeline.
> Having profiled it, we know that in the critical sending section, the
> application is spending most of its time either doing regex or scanning
> XML using XPaths.
> The former task has Perl showing a minor, but significant performance 
> advantage over Java, presumably because so much of the real work is taking
> place in optimised C code, down below the runops dispatch.
> The latter task is performed in pure Perl, and here Java out-performs by
> a large factor (I've heard 20-100x, but I need to dig into those numbers
> more - I don't think I want to take them on face value).
> I think I'm coming round to the point of view which says that VMs should
> be the natural target for dynamic languages because you can then separate
> the VM-level optimisation and JITing from the higher-level improvements.
> The VM should offer the right sort of hooks to aid dynamic language 
> implementors and should be cleanly and publicly specified, so as not to
> provide a fast-moving target for anyone trying to target it.

For various reasons I'm toying with the idea of trying to get a perl
parser/compiler going in pure perl - the main one being I want to do
macro-y stuff via readahead in the source stream and some fuckery with
the lexer, and I'm effectively finding myself writing a very small
implementation of a fragment of the parser every time so it seems silly.

But assuming we had that, and I think we should just on principle if nothing
else, other backends would become much more easily possible. One I'd love
to see is Bigloo Scheme, since that compiles to C, JVM and MSIL already.

The solution to your problem is, however, almost certainly to use a better
XML module for the xpath stuff.

      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/                    http://www.shadowcat.co.uk/ 

More information about the london.pm mailing list