Embedded Perl or Python (XPost)

Alex Martelli aleax at aleax.it
Sat Sep 6 02:55:33 EDT 2003


Chris wrote:

> LOL
> 
> thanks for the heads up on Boost

You're welcome.


> I have just downloaded Swig and am beginning to explore that, So boost
> also sounds like a good idea.

Personally, I prefer SWIG when what I have to interface to is basically
C code.  In that case, SWIG does have the advantage of being able to
interface a C library to _several_ HLLs and VHLLs.  But for C++ I never
really got the hang of it, while Boost and pyste are a snap to use (for
Python, which coversa basically all I need).


> I think with my penchant for small things I may be getting carried away.

"Small binary size" is a perfectly respectable target when one's
target requires it (mobile phones, small palmtops, etc).  Otherwise,
personally, I consider it way less important than productivity,
maintainability, correctness, and even speed.  But if your priorities
are otherwise, you might consider LUA -- it probably won't do all you
want, but it may come near and it WILL be far smaller anyway.

Some scripting languages are designed for power, others focus on
being small.  Perl and Python definitely consider power, ease of
use (by their very different criteria), and so on, far more crucial
than saving some bytes of disk.  When that disk saving is crucial,
you may choose scripting languages designed to be small, even if
that sacrifices a lot of power -- after all, many scripting tasks
don't really require all that power.


> I guess suck it and see is my best option, I have explored the source
> code for perl 5.8 and got considerably lost :(

Ah, yes, I remember that feeling from back when I wrested with it
(Python's C source code I find very readable, and anyway you do not
need to look at it to use Boost or pyste).


> I will have to try python and see if I come out any wiser

Another option you may want to consider is Ruby.  I don't know
how easy it is to interface it specifically to C++, and in
particular to get the cross-language subclassing and overriding
effect you want (which Boost provides so smoothly) -- but it's
basically the same power as Perl or Python, a distinctive style
of its own that along some axes lies in-between the two P's,
and a small but enthusiastic community.  Size-wise, though, I
don't think it will significantly help you.


Alex






More information about the Python-list mailing list