Scripting C++ -- Boost.Python vs CORBA vs ???

David Abrahams david.abrahams at
Wed Feb 20 00:08:16 EST 2002

"Craig Maloney" <cmaloney at> wrote in message
news:3C7283E4.4050604 at
> Hi all.
> I'm doing some scientific computing and have
> amassed a moderate set of classes.  Due to the
> heavy computational demands, I don't think I
> can justify rewriting everything in an interperated
> language; nice as that would be now that I'm
> playing around with what I've created.
> I'm in a situation now where I've written about
> a dozen of quickie, throw away, utility routines
> that I call from the command line, and in essence,
> BASH has become my scripting environment.
> Unfortunately, the number of throw-away routines
> is exploding, and I feel like I'm loosing the advantage
> of having constructed a nice set of classes with
> which to play.
> I would, of course, like to have some sort of scripted
> environment (e.g. Python) in which to "play"
> with my objects.
> That said, I'd like to solicit opinions as to the relative
> merits of the various possible approaches.

There is a comparison of some of the choices at:

> I'm making essential use of templates and polymorphism.

One of the design goals for Boost.Python was to avoid the language support
issues that tend to plague systems which attempt to parse C++. Parsing C++
is hard; AFAIK all of the wrapping systems which try to do it break down in
some areas. Boost.Python uses the builtin type inference abilities of your
C++ compiler instead of parsing the C++ code separately. Another issue is
that the interfaces to your C++ code doesn't typically carry enough semantic
information to tell a system how it should be wrapped: if I pass you a
pointer, are you taking ownership? Are you going to hold onto it?, etc.
Boost.Python V2 currently under development addresses those issues.

Another design goal was to allow you to wrap your C++ code without intruding
on its design. One example of a relatively large scientific project using
Boost.Python is,

> I have no experience with Boost.Python, but from what I
> understand, it would not involve writing wrapper definitions
> (ala SWIG or IDL), right?  Are there other options?

Since I'm not intimately familiar with SWIG or IDL, I'm not sure what
wrapper definitions you're referring to. You do have to write a small amount
of additional code to export your C++ to Python using Boost.Python. You can
see examples of what's required to make Python modules from your C++ code
starting here:

You might also consider posting questions to the C++ sig



More information about the Python-list mailing list