Double-posting here... I felt like actually responding to computerquip:
computerquip wrote: |
---|
It's not the verbosity that is simple in my opinion, it's actually how explicit it is. |
I wouldn't equate 'explicitness' to 'simplicity'. But I see your point.
That said.. there is literally no reason why a C++ interface could not be as explicit as a C interface. Remember that any style you adopt in C could be adopted in C++ as well... and you're talking more of a style standpoint than a language standpoint.
Furthermore, if you want to have explicit construction/destruction of an RAII object in C++... the C++ interface is
still just as simple/explicit as the C interface:
1 2 3 4 5 6 7 8 9
|
// C interface
type* obj = lib_Create();
// ...
lib_Destroy(obj);
// C++ interface (verbose)
auto* ptr = new lib::type;
// ...
delete ptr;
|
So I still fail to see where this claim of simplicity is coming from.
I don't mind RAII but it's not always the best solution when it causes things to be unobvious like certain things being destructed without you knowing about it. |
How can you not know if something has been destructed? It's destructed when it goes out of scope. If anything it's harder to know when an object
hasn't been destructed (ie: memory leak).
And I'd say that RAII literally
IS the best solution (in a non-GC language) for anything which requires allocation of resources that must be deallocated at a future time.
Especially in C++ where you have exception safety to consider.
(but no... exception safety is not a C-lib vs. C++-lib issue... it's a C vs. C++ language issue... so yeah if you prefer C because it lacks exceptions, then that's one thing.... but don't try to pin that thing on a lib interface because it's totally unrelated)
Often a time, a C++ library can be deep into C++ style coding that you have to read into how that general concept works like PIMPL, types of template programming, etc. |
If you want to compare the most complex C++ libs against the simplest C libs, that's completely unfair.
If you want, I can find and show you plenty of C libs which are frustratingly complex, even without templates.
And BTW.. the PIMPL idiom is practiced more often in C than it is in C++ (as it is the only way to hide access to 'private' members in C)... so I don't know what you were trying to get at with that point.
It also has nothing to do with the lib interface, because the impl is the implementation not the interface. The whole point of pimpl is to hide the implementation from the interface.
If you've ever started trying the Boost Spirit parser, most people look at that and just leave because they can't make heads or tails of it. |
Yes, boost is a hornet's nest of complexity. I never said otherwise. But again you are picking unfair examples.
Let's stick with Apples to Apples comparisons here... and since the original topic was about libs like SDL.... explain to me how SDL's interface is simpler than SFML's interface... because these are two very comparable libs and it's a reasonably fair comparison.