Are there downsides to using a wrapper/bindings for a library?

7    21 Aug 2015 21:33 by u/Massmoment

I want to learn working with OpenCV (a library written in C++), and I want to learn working with Go. Now, the library is written in C++ with interfaces in Java, Python and Matlab, but not Go.

I found a wrapper (that uses SWIG) that binds the library to Go, perfect! But something tells me it's gonna bring me a lot of pain and struggling. Is this a correct feeling or do I worry too much?

Link to the wrapper: https://github.com/lazywei/go-opencv

2 comments

1

If the wrapper is pretty much 1:1 then you shouldn't have any problems with it, except for the fact that sometimes 1:1 wrappers can be a little slow.

If it tries to abstract the underlying lib then it can be prone to errors, like all code, but I'd say just try it and see.

1

I've used swig before with minimal effort, albeit not for Go. It worked pretty well, wasn't hard to set up makefiles, although it was fairly slow in some cases.

I used it to cross compile a C API I had built into a perl module so my users could code in perl instead of C. I later tried rewriting the API in C++, and found that the swig cross compile module was much much slower.