Easiest language to make binding for?

I've been wrapping a C++ library of mine using Python and have been finding it all quite challenging. One complexity is that I'm using SWIG and my wrappers use objects that are themselves written in C++ and wrapped using SIP and something else too (I think it's called Dart). Apparently all wrapped Python objects are not truly the same in their meta-data and you need to screw around with different ways to extract the pointer to the original C/C++ objects. Anyway, I was wondering what language people thought was the easiest to construct wrappers around compiled (presumably C/C++) code in. I'll consider any paradigm, functional, imperative, OO/non-OO, whatever.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

ditto

i have wondered about that as well: previously on LtU. :-)

You can try Boost.Python

You can try Boost.Python

Boost

Isn't Boost only for Python though? I liked SWIG because it allows you to make bindings for other languages too, reusing much of the wrapper code. Allow me further explain. I'm not really asking about binding technologies per se but about how well integrated the whole concept of bindings are in each language. Perhaps integrating typemapping and so forth into the very syntax of the language so that bindings are a trivial task.

Factor?

This may not be exactly what you're looking for, but the Factor FFI, may be of interest: it looks like it may need some effort to call C++ code, though interfacing with C is pretty much painless.

Second for Boost.Python

I have found Boost.Python to be very easy to use. The most interesting thing about it to me is that it seems to use only C++ template metaprogramming to bridge between Python and C++. However, the Boost.Python folks make an interesting point: Since Python functions are data, compiled code can't call them. So that's one incompatibility that you'd be up against, and you'd probably have problems with that in any interpreted language.

Oddly enough, I've heard (though never tried it) that GNU Octave isn't too bad. Definitely not general-purpose, but if you're doing numerical computation it might be a good choice.

Back on the Boost.Python thought, I believe you can construct typemaps to automatically perform (some) conversions, though I haven't studied it that much. I would think that any language that lent itself to interfacing with C too easily would start to resemble C a lot, however, since C is much lower-level than anything you're likely to want to interface with.

List of Python tools

This might help.

- Paddy.

If you like binding for many

If you like binding for many languages, not only for Python, turn to .NET. They have IronPython and many things else.

Well no

I'm not interested in Microsoft proprietary stuff.

Too much Python

Many here seem to have fixated on Python since I mentioned that in the OP. I thank you all for your suggestions but this isn't just a Python question. I like Python but I'm interested in finding other languages that might be easier to do extensions with. I'll certainly maintain the Python bindings but I thought I'd find out if anybody had found extensions as frustrating as I have and made a language that was easier to deal with in that area.

Maybe worth to have a look at Dao

Making wrapping C/C++ codes easy was one of the primary goals when I developed Dao (www.xdao.org). I think it is sufficiently simple to create wrapper of C/C++ codes for Dao. Actually its C interface is such simple that a tool was easily developed to wrap C/C++ codes semi-automatically, which requires write module definition files for the C/C++ types and functions. Such module definition file has format very similar to C/C++ header files, so it can be created by simple copying, searching and substitution based on header files with a docent editor.

The interesting points in the wrapping for Dao are:
1. the names, types and default values of function parameters and returned value can be specified in the same way as in Dao function. So the parameter types are checked before invoking the wrapper function, which removes the need to write code to check parameter types manually;
2. Dao classes can be derived directly from C/C++ types with support to override virtual functions;
3. inheritance relationships can be preserved for C/C++ types;
4. running time wrapping is also supported using FFI.

Thanks

I'm looking into it along with Lua.

Lua

Lua is one of the few languages that have been designed with interoperability in mind from the very beginning. From About Lua:

Lua is embeddable

Lua is a fast language engine with small footprint that you can embed easily into your application. Lua has a simple and well documented API that allows strong integration with code written in other languages. It is easy to extend Lua with libraries written in other languages. It is also easy to extend programs written in other languages with Lua. Lua has been used to extend programs written not only in C and C++, but also in Java, C#, Smalltalk, Fortran, Ada, and even in other scripting languages, such as Perl and Ruby.

That's interesting

Actually I had Lua in mind but didn't want to suggest any particular languages so as not to bias the responses. I'm already looking into it in fact.