Closing "Embedding Perl into C++ Applications" Grant

Leon Timmermans finished his grant and shared with us the report below.

What has been achieved

The Good

At the start of this grant I set myself 6 goals. 5 of them have been achieved (with one caveat that I will get into later).

  • Document the API
  • Add unit tests
  • Port to 5.10
  • Add regexp support
  • Improve support for exporting functions, methods and variables.

At popular request, I did implement another mojor feature that I initially was planning to postpone: extention loading.

The bad

In one word: portability to Windows. The problem isn't the code, but building it. The perl building toolchain doesn't have much support for C++, and especially on Windows this shows. Something as simple as ExtUtils::CBuilder->new->have_cplusplus will actually blow up in your face. Yeah nice. After a lot of debugging and some patching to [EU::CB], I almost got a working library.

Making this work properly will probably require some significant work in the toolchain. I'm planning to do that at some point (and fortunately I'm not the only one), but that falls well out of the scope of this grant.

The Ugly

Perl 5 version 10 and higher have a regexp API and I was planning to use it. Unfortunately, that turned out to be not very realistical: the [reapi] is intended for regexp implementors, not end users. Implementing qr// on them is quite trivial, but m// and s/// turn out to be illusive. In the end I had to implement them as perl subs, not very pretty or efficient but it works.

Why it took so long

I was expecting to finish this grant late 2008 or otherwise early 2009. Obviously that didn't quite work out, despite a pretty rapid start. This had a number of reasons.

Personal

For reasons I don't feel comfortable publishing online, my professional life (in other words, both my my study and this) was pretty much in hibernation for an entire year. There wasn't much I could do about that, though I could have communicated it better. I did consider giving it up altogether a few times, and if my grant manager hadn't gone MIA around the same time I did I probably would have done so. Mea culpa for all of that. Even when I came back, I had to reboot my study at the same time I rebooted this project, which didn't exactly help with getting things done ASAP.

Technical

I definitely underestimated the amount of work it would take to do what I was planning to do, and I probably caused much of thay myself by setting myself one high standard: that my code should buildable in the CPAN infrastructure. On the long term, I definitely think this is a good thing, but it did cause me a lot of extra work that I would not have had otherwise. On the positive side, that did result in two rather useful pieces of code.

libtap++

[libtap++] is a TAP library written in C++. It is best described as a port of Test::More to C++, to the point that most of the documentation is stolen from it. I'm quite satisfied with how it turned out: it's rather intuitive, supports most of T::M's core functionality and some of its own.

Library::Build

Library::Build is a [Build.PL compatible] building tool. It grew out of a custom script I wrote in order to build libperl++. Now, when you read this there's probably a question going through your head: Why?

To put it simple, ExtUtils::MakeMaker is only sitting in the way if what you want to do isn't building a Perl module. Module::Build is more suitable, but when you are using neither its build or test actions, there's little left to reuse. Quite frankly I found it a bitch to work with, so I set out and and implemented something of my own based on ExtUtils::CBuilder and other core modules. To my own surprise, I ended up with something that appears to be reusable with a little refactoring. It's not ready yet for prime-time, but it's getting there.

Future directions

In the near future I'm probably going to create some more packages, both new and splitoffs. For starters, Library::Build deserves its own package. Installation of libperl++ using CPAN.pm and friends would be a lot easier if there was an Alien::Boost package (Boost::Graph could also benefit from that).

About TPF

The Perl Foundation - supporting the Perl community since 2000. Find out more at www.perlfoundation.org.

About this Entry

This page contains a single entry by Alberto Simões published on November 7, 2010 12:53 AM.

2010Q4 Grant Proposal: AnyEvent::HTTPBenchmark was the previous entry in this blog.

Perl 6 Tablets: First Progress Report is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.38