My understanding is that SketchUp is written in C++. There also used to be a C++ API which has been deprecated.
What was the motivation behind ditching the C++ API and creating a C API instead?
It is so tedious and verbose to work with it… Even very simple tasks require many lines of code.
The SketchUp data structure seems to be highly object-oriented, hence C++ would seem to be a better fit. What am I missing?
I thought the C++ implementation resulted in a DLL that needed a specific version of Microsoft’s Visual Studio. The few times I have looked at the Ruby language’s source code, it was in C, not C++. That would prevent the “.so” extension files from encountering the various name mangling of C++ function overloading that compilers might have.
I think the reason to ditch the old API was that it was highly coupled to SketchUp’s internal workings, without much thought of what should even be available in an API. I’ve gotten the impression you could do things with it that wasn’t supposed to be supported by the core and could cause crashes. I don’t have any examples of this though.
I think ThomThom commented on what made C better than C++ but I can’t remember.
Yes we tried to use it a few months ago, and even contributed a couple of fixes. But at the time it wasn’t mature enough and we didn’t have time to improve it.
C++ binary compatibility is a pain. C is much more portable.
I made a C++ wrapper on top of Ruby. So instead of using VALUE variables and Ruby’s C API directly I use my C++ wrapper which introduce some type safety, easier code editing as the IDE knows what type I’m working on. Also let me inspect the values of Ruby strings and arrays etc when debugging.
I think this is the more mature C++ wrapper of the C API so far. Worth for the community to contribute.