Python, JavaScript, and Boost
February 22, 2006 – 2:28 pmA few days ago, Brendan Eich wrote a thoughtful
post on incorporating a few ideas from Python into JS 2.0
(specifically iterators, generators, and comprehensions, but that’s
beside the point for the moment). I replied:
t would be tremendously helpful if JS2 could standardize plugin APIs
in both C and C++ (and do the latter in a template-smart way). Having
simple C APIs accelerated the growth of Python and Ruby tremendously,
and (I believe) is crucial to getting JS accepted as a “traditional”
scripting and glue language. Standardizing “one way to do it” for C++
(esp. templated C++) would avoid a lot of the grief P&R have gone
through.
Brendan’s response was:
…for Mozilla, XPIDL and XPCOM (http://www.mozilla.org/scriptable/)
are the way to interface to “plugins” (generally construed)
implemented in other languages, not just C++ but also Python (a C
XPCOM binding could be done, and one was started, but there hasn’t
been much interest). A truly painless C or C++ binding should work as
with OCaml — that is,
ocamlc foo.c
This is a fine goal, but not something for ECMA TG1 to standardize
just yet. I would welcome a prototype for SpiderMonkey, if volunteers
capable of pulling it off are motivated.
Plugins loaded from the net are a different animal, requiring lots of
trust as well as highly compatible, stable APIs on both plugin and
browser sides of the fence.
I’ve argued elsewhere
that Javascript could be the dominant scripting language five years
from now: it’s sexy, it’s (relatively) simple, and it’s one of the two
languages every programmer has to learn (the other being C). An easy
way to wrap and call legacy C/C++ code—one that handles C++ objects
and templates, rather than requiring programmers to pretend they’re
C functions—would be a big step toward this. Boost.Python
is the closest thing I’ve seen yet to a usable solution; if anyone out
there wants to be rich, famous, and popular, Boost.Javascript is just
begging to be created.
One Response to “Python, JavaScript, and Boost”
I’m working on a bridge between the .NET platform and the SpiderMonkey JavaScript engine. This would be able to target managed C++ code. If you’re interested take a look here: http://codepraxis.com.
By Derek Petillo on Aug 18, 2006