Made putting serviceable graphical interfaces to some of the CLI apps we were using.
Swig – Connect C/C++ programs with high-level programming languages
71–80 of 90 posts
Re: Swig – Connect C/C++ programs with high-level programming languages
#72Who classifies C++ as a low-level programming language? Even C is only being called low-level relatively recently, and it's not universally accepted as such.
You could argue IS NOT (high-level) does not necessarily imply IS (low-level), in which case no-one classified C++ as low-level. I guess for the large part the inter-op here is from (mostly) interpreted languages, which are certainly higher level than C++. Maybe instead of it being a binary choice between high-level and low-level languages, there is a middle ground. Fairly easy to argue that as the case.
After reading the first sentence on the site, though, I think this was just a somewhat clumsy rephrasing. "SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages." "A variety of high-level programming languages" implies there are some high-level languages that SWIG cannot connect C/++ with, and it's open to interpretation whether C/++ are among the high-level languages that SWIG doesn't connect C/++ with.
Re: Swig – Connect C/C++ programs with high-level programming languages
#73I've used Swig to inherit from base classes in Java to implementations in C++. Swig generated the JNI and C++ bindings. Fun times.
Swig is kind of clunky. But it is so much better than writing JNI yourself. JNI is gouge-your-eyeballs-out awful; SWIG is at least tolerable, and it works.
Re: Swig – Connect C/C++ programs with high-level programming languages
#74I've used Swig for C++ to Python interop and let me warn you it is a nightmare. The syntax is absurdly terse and convoluted, documentation sucks and good luck trying to search the web for constructs made only of special characters. CLIF is way nicer for C++/Python. If you need other languages then best of luck (Zig, Rust and D are easier than Java and Go at least).
I'd recommend pybind11 for c/c++ python bridge. Though you have to compile your wheel for every minor python version separately.
Re: Swig – Connect C/C++ programs with high-level programming languages
#75I've used Swig for C++ to Python interop and let me warn you it is a nightmare. The syntax is absurdly terse and convoluted, documentation sucks and good luck trying to search the web for constructs made only of special characters. CLIF is way nicer for C++/Python. If you need other languages then best of luck (Zig, Rust and D are easier than Java and Go at least).
All of that works, especially for Google internally, which uses CLIF quite extensively, but that makes it not so great for external projects.
Re: Swig – Connect C/C++ programs with high-level programming languages
#76Yeah, I'm never doing that again. I created a binding for the Irrlicht rendering engine with Lua using swig. There were always parsing errors with the header files so I had to create definition files for almost everything. It was a lot of work, but I did finally get it to function. And then a new version of Irrlicht came out, and I basically had to start from scratch. All the definition files no longer matched the he…
> create a proper C binding to the C++ interface That's the generally recommended way of exposing your C++ library to any kind of non-C++ code. I'm not aware of any software which directly helps with that, unfortunately. You either do it manually or write a custom script. Here's a recent example of the latter, from Dear ImGui: https://github.com/dearimgui/dear_bindings
If the API surface is not too large that’s one of the things ChatGPT is usually competent enough to ‘type out’ for you most of the way (delta some errors).
Re: Swig – Connect C/C++ programs with high-level programming languages
#77There are probably better/easier ways to do that now, but back then Swig was the only game in town and for us it worked out pretty well.