23 ms·
Why not a C++ library with an optional C API?
by rienbdj 7y ago
Why not a C++ library with an optional C API?
- LessDmesg 7y agoBecause C++ is one of the most complex languages in the world, hence a pain to interop with. C FFIs, on the other hand, are ubiquitous.
- izacus 7y agoThe idea (and one that worked well in several projects I've worked on) is that you use C++ as main language of the library and make outside bindings C. It does require some discipline, but C++ has many portable constructs that make life significantly easier when writing business logic.
- pnako 7y agoIt's possible to use the "hourglass" pattern where your implementation is written in C++, you export a C API (and ABI), and then you can provide an additional, light C++ wrapper based on the C API.