4 ms·
I will go as far as to say (from experience) that releasing a library in C++ to others is completely foolish due to the major problems it can create when design
by makecheck 15y ago
I will go as far as to say (from experience) that releasing a library in C++ to others is completely foolish due to the major problems it can create when design changes are inevitably needed. Other languages do APIs better.
C++ is useful for implementing the guts of things. And when implementing, having your own library of shared C++ code is useful, as long as you completely control it and always compile it with your project from scratch (a library of templates, for instance). The last thing you want is to link to someone else's compiled C++ library because that's where the pain begins.
To expose a C++ implementation, use a plain C interface; the C application binary interface works very well across compilers. If you feel it absolutely necessary to expose something like the inheritance scheme of an object-oriented design, you had better do it in a language like Objective-C that can at least implement objects in a very forward-compatible way (or use tricks like exposing pointer parameters in C functions).
- joe_the_user 15y agoI'm using both QT and some gnome/gtk C libraries. Both work but the c libraries have a more inconsistent object model and require multi-stage processes for the construction of their c-objects. Once a c-based project is large enough that it needs objects in user space, not have a c++ interface is counter-productive and backporting to c++ project to c would doubly counter-productive here.
- asher 15y agoI agree. Also, the pure-C interface is easier to wrap from scripting languages.
- cbs 15y agoIf you haven't heard of it before, swig (swig.org) is pretty nice for generating code to bridge C and C++ code to a scripting language for you.